org.proteinshader.structure
Class Residue

java.lang.Object
  extended by org.proteinshader.structure.Residue
All Implemented Interfaces:
IDTest, Visitable
Direct Known Subclasses:
AminoAcid, Heterogen, Water

public abstract class Residue
extends Object
implements IDTest, Visitable

This abstract class serves as a container for one or more Atoms.

The known subclasses are AminoAcid, Heterogen, and Water, but a Nucleotide subclass will be added at some future date (beyond the scope of this thesis).


Constructor Summary
Residue(String residueID, String chainID, String modelID, String structureID)
          Constructor for use by subclasses.
 
Method Summary
abstract  void accept(Visitor visitor)
          Accepts a Visitor and does a callback.
 Atom addNewAtom(int serialNo, AtomEnum type, String atomID, double temperature, int charge, double occupancy, String altLocation, double x, double y, double z, VisibilityEnum visibility)
          Creates a new Atom with the type and Atom ID given as arguments, adds the Atom to the Residue's collection of Atoms, and returns a reference to the new Atom.
 Atom getAtom(String atomID)
          Returns the Atom with the atomID given as an argument, or returns null if the Atom is not found.
 String getChainID()
          Returns the ID of the Chain that this Residue belongs to.
 String getModelID()
          Returns the ID of the Model that this Residue belongs to.
 String getResidueID()
          Returns the ID of this Residue.
 String getStructureID()
          Returns the ID of the Structure that this Residue belongs to.
 Iterator<Atom> iteratorAtoms()
          Returns an Iterator for the Atoms held by this Residue.
 int numberOfAtoms()
          Returns the number of Atoms held by this Residue.
 String processID(String id, String typeOfID)
          Returns the ID after trimming any leading or trailing whitespace.
 String toString()
          Returns the ID of this Residue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Residue

public Residue(String residueID,
               String chainID,
               String modelID,
               String structureID)
        throws InvalidIDException
Constructor for use by subclasses. For a PDB entry, a residue is identified within a chain by a name (1 to 3 characters), a sequence number (an integer), and an optional insertion code (a single alphabetical character). The residueID combines these three fields with a blank space between fields. For example, 'GLY 23 B' is a glycine residue at sequence position 23 with an insertion code of B. However, if a residue is a heterogen, that should be made explicit by adding 'HET_' to the front of the residue name. For example, 'HET_RTL 1' is a retinol molecule with a sequence number of 1 and no insertion code, and 'HET_HIS 1' could be used to indicate an individual histidine amino acid that was bound (as a ligand) by some protein, but was not a standard residue in a chain.

Any leading or trailing whitespace will be trimmed from residueID.

Parameters:
residueID - the ID of the Residue.
chainID - the ID of the Chain.
modelID - the ID of the Model.
structureID - the ID of the Structure.
Throws:
InvalidIDException - if residueID is null or does not have at least one non-whitespace character.
Method Detail

accept

public abstract void accept(Visitor visitor)
                     throws VisitorException
Accepts a Visitor and does a callback.

Specified by:
accept in interface Visitable
Parameters:
visitor - the Visitor to do a callback with.
Throws:
VisitorException - if an error occurs while an object is being visited.

getResidueID

public String getResidueID()
Returns the ID of this Residue. The String returned cannot be null or empty, because the constructor checks that this read-only attribute has at least one character.

Returns:
The Residue ID as a String.

getChainID

public String getChainID()
Returns the ID of the Chain that this Residue belongs to.

Returns:
The Chain ID as a String.

getModelID

public String getModelID()
Returns the ID of the Model that this Residue belongs to.

Returns:
The Model ID as a String.

getStructureID

public String getStructureID()
Returns the ID of the Structure that this Residue belongs to.

Returns:
The Structure ID as a String.

addNewAtom

public Atom addNewAtom(int serialNo,
                       AtomEnum type,
                       String atomID,
                       double temperature,
                       int charge,
                       double occupancy,
                       String altLocation,
                       double x,
                       double y,
                       double z,
                       VisibilityEnum visibility)
                throws MissingAtomTypeException,
                       InvalidIDException
Creates a new Atom with the type and Atom ID given as arguments, adds the Atom to the Residue's collection of Atoms, and returns a reference to the new Atom.

The Atom type (an AtomEnum) will be used to set a default radius and CPK color. The new Atom will be stamped with the residueID, chainID, modelID, and structureID of the Residue.

Parameters:
serialNo - the Atom serial number.
type - the Atom type as an AtomEnum.
atomID - the ID of the Atom.
temperature - x-ray crystallography the temperature factor.
charge - optional measure of electric charge on the atom.
occupancy - less than 1.0 if atom has more than one location.
altLocation - alternate location if occupancy less than 1.
x - coordinate of the Drawable's center.
y - coordinate of the Drawable's center.
z - coordinate of the Drawable's center.
visibility - visibility status (OPAQUE, TRANSLUCENT, or INVISIBLE).
Returns:
The newly created Atom.
Throws:
MissingAtomTypeException - if type is null.
InvalidIDException - if atomID is null or does not have at least one non-whitespace character.

getAtom

public Atom getAtom(String atomID)
Returns the Atom with the atomID given as an argument, or returns null if the Atom is not found.

Parameters:
atomID - the unique ID for the desired Atom.
Returns:
The requested Atom (or null if not found).

iteratorAtoms

public Iterator<Atom> iteratorAtoms()
Returns an Iterator for the Atoms held by this Residue. The order of iteration is the same as the order in which Atoms were added to the Residue. In the rare case where an Atom was replaced (by adding an Atom with the same atomID), the replacement would not change the iteration order in any way.

Returns:
An Iterator for the Atoms held by this Residue.

numberOfAtoms

public int numberOfAtoms()
Returns the number of Atoms held by this Residue.

Returns:
The total number of Atoms.

processID

public String processID(String id,
                        String typeOfID)
                 throws InvalidIDException
Returns the ID after trimming any leading or trailing whitespace. An ID must have at least one non-whitespace character.

This method may be overridden in a subclass to add additional testing.

Specified by:
processID in interface IDTest
Parameters:
id - the ID to process.
typeOfID - the type of ID (for possible inclusion in error message).
Returns:
The trimmed ID.
Throws:
InvalidIDException - if the trimmed ID does not have at least one character.

toString

public String toString()
Returns the ID of this Residue. The String returned cannot be null or empty, because the constructor checks that this read-only attribute has at least one character.

Overrides:
toString in class Object
Returns:
The Residue ID as a String.


Copyright © 2007-2008