org.proteinshader.structure
Class Model

java.lang.Object
  extended by org.proteinshader.structure.Model
All Implemented Interfaces:
IDTest, Visitable

public class Model
extends Object
implements IDTest, Visitable

A Model serves as a container for one or more Chains.

If a protein structure is determined by x-ray crystallography, there is usually only a single model. However, if NMR (Nuclear Magnetic Resonance imaging) is used, there are normally several possible models that fit the data. The atomic coordinates will differ between the models, but all other information is the same, so the models are all stored in one PDB structure entry.


Constructor Summary
Model(String modelID, String structureID)
          Constructs a Model with the requested modelID and structureID.
 
Method Summary
 void accept(Visitor visitor)
          Accepts a Visitor and does a callback.
 void addLoop(Loop loop)
          Adds a Loop to the Model.
 void addNewBetaStrand(String chainID, String betaStrandID, String betaStrandNumber, String sheetID, String startResidueID, String endResidueID, int sense, int strandsInSheet)
          The BetaStrand will be added to the Chain only if the sequence of Residues that the BetaStrand refers to has already been added.
 Chain addNewChain(String chainID)
          Creates a new Chain with the chainID given as an argument, adds the Chain to the Model's collection of Chains, and returns a reference to the new Chain.
 void addNewHelix(String chainID, String helixID, String serialNo, String startResidueID, String endResidueID, HelixEnum type)
          The Helix will be added to the Chain only if the sequence of Residues that the Helix refers to has already been added.
 void clearListsOfVisibles()
          Clears the lists of opaque and translucent Drawable objects.
 BetaStrand getBetaStrand(String betaStrandID)
          Returns the BetaStrand with the betaStrandID given as an argument.
 Chain getChain(String chainID)
          Returns the Chain with the chainID given as an argument.
 double getDepth()
          Returns the depth of the Model (maxZ - minZ).
 double getHeight()
          Returns the height of the Model (maxY - minY).
 Helix getHelix(String helixID)
          Returns the Helix with the helixID given as an argument.
 Loop getLoop(String loopID)
          Returns the Loop with the loopID given as an argument.
 double getMaxDimension()
          Returns the maximum dimension (the greatest of width, height, or depth).
 double getMaxX()
          Returns the maximum x-coordinate value.
 double getMaxY()
          Returns the maximum y-coordinate value.
 double getMaxZ()
          Returns the maximum z-coordinate value.
 double getMinX()
          Returns the minimum x-coordinate value.
 double getMinY()
          Returns the minimum y-coordinate value.
 double getMinZ()
          Returns the minimum z-coordinate value.
 String getModelID()
          Returns the modelID, which is the Model's number.
 Drawable[] getOpaqueAtomsAndBonds()
          Copies the list of opaque Atoms and Bonds into an array and returns the array.
 Segment[] getOpaqueSegments()
          Copies the list of opaque Segments into an array and returns the array.
 Segment getSegment(String segmentID, String regionID, RegionEnum regionType)
          Returns the requested Segment if it exists.
 String getStructureID()
          Returns the structureID of the Structure this Model belongs to.
 Drawable[] getTranslucentDrawables()
          Copies the list of translucent Drawables into an array and returns the array.
 double getWidth()
          Returns the width of the Model (maxX - minX).
 double getX()
          Returns the x-coordinate for the center of gravity of the Model.
 double getY()
          Returns the y-coordinate for the center of gravity of the Model.
 double getZ()
          Returns the z-coordinate for the center of gravity of the Model.
 boolean hasAminoAcids()
          Returns true if the model holds any AminoAcids.
 boolean hasHeterogens()
          Returns true if the model holds any Heterogens.
 boolean hasWaters()
          Returns true if the model holds any Waters.
 Iterator<BetaStrand> iteratorBetaStrands()
          Returns an Iterator for the BetaStrands held by this Model.
 Iterator<Chain> iteratorChains()
          Returns an Iterator for the Chains held by this Model.
 Iterator<Helix> iteratorHelices()
          Returns an Iterator for the Helices held by this Model.
 Iterator<Loop> iteratorLoops()
          Returns an Iterator for the Loops held by this Model.
 int numberOfBetaStrands()
          Returns the number of BetaStrands held by this Model.
 int numberOfChains()
          Returns the number of Chains held by this Model.
 int numberOfHelices()
          Returns the number of Helices held by this Model.
 int numberOfLoops()
          Returns the number of Loops held by this Model.
 String processID(String id, String typeOfID)
          Returns the Model ID after trimming any leading or trailing whitespace.
 void setMinMaxXYZ(double minX, double maxX, double minY, double maxY, double minZ, double maxZ)
          Sets the minimum and maximum values for the xyz-coordinates.
 void sortBetaStrands()
          Iterates through all Chains of the Model and modifies the linked hash map of beta-strands so that when an iterator for beta-strands is handed over (based on the linked list part) the beta-strands will be ordered according to the starting amino acid.
 String toString()
          Returns the modelID, which is the Model's number.
 void updateListsOfVisibles(boolean includeAtoms, boolean includeBonds, boolean includeAminoAcids, boolean includeHeterogens, boolean includeWaters, boolean includeSegments)
          Finds visible Drawable objects and transfers them to a list of opaque Segments, opaque Atoms and Bonds, or a list of translucent Drawables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Model

public Model(String modelID,
             String structureID)
      throws InvalidIDException
Constructs a Model with the requested modelID and structureID. The modelID is the model number from the PDB structure entry. The numbering of models in a PDB entry is sequential and always starts at 1. This constructor will check that the modelID can be converted to a positive integer, but the ID will be stored as a String representation so that it can be used as a hash key. The structureID is not checked because it must have already been checked by the Structure that creates this Model.

Parameters:
modelID - the Model number.
structureID - the ID code assigned by the Protein Data Bank.
Throws:
InvalidIDException - if the Model ID is null or cannot be converted to a positive integer.
Method Detail

accept

public 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.

updateListsOfVisibles

public void updateListsOfVisibles(boolean includeAtoms,
                                  boolean includeBonds,
                                  boolean includeAminoAcids,
                                  boolean includeHeterogens,
                                  boolean includeWaters,
                                  boolean includeSegments)
                           throws VisitorException
Finds visible Drawable objects and transfers them to a list of opaque Segments, opaque Atoms and Bonds, or a list of translucent Drawables.

Parameters:
includeAtoms - true if Atoms should be included in lists.
includeBonds - true if Bonds should be included in lists.
includeAminoAcids - true if AminoAcids should be included.
includeHeterogens - true if Heterogens should be included.
includeWaters - true if Waters should be included.
includeSegments - true if Segments should be included.
Throws:
VisitorException

getOpaqueSegments

public Segment[] getOpaqueSegments()
Copies the list of opaque Segments into an array and returns the array. A reference to the array is not kept by this Model.

Returns:
An array of opaque Segments.

getOpaqueAtomsAndBonds

public Drawable[] getOpaqueAtomsAndBonds()
Copies the list of opaque Atoms and Bonds into an array and returns the array. A reference to the array is not kept by this Model.

Returns:
An array of opaque Atoms and Bonds.

getTranslucentDrawables

public Drawable[] getTranslucentDrawables()
Copies the list of translucent Drawables into an array and returns the array. A reference to the array is not kept by this Model.

Returns:
An array of translucent Drawables.

addNewHelix

public void addNewHelix(String chainID,
                        String helixID,
                        String serialNo,
                        String startResidueID,
                        String endResidueID,
                        HelixEnum type)
                 throws InvalidRegionException,
                        InvalidIDException
The Helix will be added to the Chain only if the sequence of Residues that the Helix refers to has already been added. In addition to adding the Helix to the Chain, the Model will also keep a reference to the Helix, so that it can return an iterator to all Helices in the Model.

Region (the superclass of Helix) will cache the Residues from startResidueID to endResidueID (or throw an exception) so that an iterator to the Region's sequence can be easily obtained.

The Helix shape (a HelixShapeEnum) will be set to Helix.DEFAULT_SHAPE. If the type argument is null, the type will be set to Helix.DEFAULT_TYPE.

Any leading or trailing whitespace in the helixID, serialNo startResidueID, or endResidueID will be trimmed. The Helix will be stamped with the chainID, modelID, and structureID of the Chain it belongs to.

Parameters:
chainID - ID of the Chain to add the Helix to.
helixID - Helix identifier from a PDB HELIX record.
serialNo - serial number of the Helix.
startResidueID - ID of the first AminoAcid in the sequence.
endResidueID - ID of the last AminoAcid in the sequence.
type - type of Helix as a HelixEnum.
Throws:
InvalidRegionException - if the sequence of AminoAcids (with at least two Residues) cannot be found on the Chain.
InvalidIDException - if the helixID, serialNo, startResidueID, or endResidueID is null or does not have at least one non-whitespace character.

addNewBetaStrand

public void addNewBetaStrand(String chainID,
                             String betaStrandID,
                             String betaStrandNumber,
                             String sheetID,
                             String startResidueID,
                             String endResidueID,
                             int sense,
                             int strandsInSheet)
                      throws InvalidRegionException,
                             InvalidIDException
The BetaStrand will be added to the Chain only if the sequence of Residues that the BetaStrand refers to has already been added. In addition to adding the BetaStrand to the Chain, the Model will also keep a reference to the BetaStrand, so that it can return an iterator to all BetaStrands in the Model.

Region (the superclass of BetaStrand) will cache the Residues from startResidueID to endResidueID (or throw an exception) so that an iterator to the Region's sequence can be easily obtained.

The sense (orientation) of an individual BetaStrand is 0 if it is the first strand in a sheet, 1 if the strand is parallel to the previous strand in the sheet, and -1 if the strand is anti-parallel to the previous strand in the sheet.

Any leading or trailing whitespace in the betaStrandID, sheetID, startResidueID, or endResidueID will be trimmed. The BetaStrand will be stamped with the chainID, modelID, and structureID of the Chain it belongs to.

Parameters:
chainID - ID of the Chain to add the BetaStrand to.
betaStrandID - unique ID (betaStrandNumber plus sheetID).
betaStrandNumber - Strand identifier from PDB SHEET record.
sheetID - sheet identifier from a PDB SHEET record.
startResidueID - ID of the first AminoAcid in the sequence.
endResidueID - ID of the last AminoAcid in the sequence.
sense - strand sense (0, 1, or -1).
strandsInSheet - total number of BetaStrands in the sheet.
Throws:
InvalidRegionException - if the sequence of AminoAcids (with at least two Residues) cannot be found on the Chain.
InvalidIDException - if the betaStrandID, sheetID, startResidueID, or endResidueID is null or does not have at least one non-whitespace character.

addLoop

public void addLoop(Loop loop)
Adds a Loop to the Model.

This method will be called by the LoopGeneratorVisitor that is used to add Loops to each Chain. When a Loop is added to a Chain, a reference to the Loop should also be added here to the Model so that the Model can return an iterator to all of its Loops.

Parameters:
loop - the Loop reference to add to the Loop hash.

clearListsOfVisibles

public void clearListsOfVisibles()
Clears the lists of opaque and translucent Drawable objects.


getModelID

public String getModelID()
Returns the modelID, which is the Model's number. The String returned cannot be null or empty, because the constructor checks that this read-only attribute has at least one non-whitespace character.

Returns:
The Model's ID number.

getStructureID

public String getStructureID()
Returns the structureID of the Structure this Model belongs to.

Returns:
The ID of the Structure.

addNewChain

public Chain addNewChain(String chainID)
                  throws InvalidIDException
Creates a new Chain with the chainID given as an argument, adds the Chain to the Model's collection of Chains, and returns a reference to the new Chain. The new Chain will be stamped with the modelID and structureID of the Model.

Parameters:
chainID - the ID of the Chain.
Returns:
The new Chain.
Throws:
InvalidIDException - if chainID is null or does not have at least one non-whitespace character.

getChain

public Chain getChain(String chainID)
Returns the Chain with the chainID given as an argument.

Parameters:
chainID - the ID for the desired Chain.
Returns:
The requested Chain (or null if not found).

iteratorChains

public Iterator<Chain> iteratorChains()
Returns an Iterator for the Chains held by this Model. The order of iteration is the same as the order in which Chains were added to the Model. In the rare case where a Chans was replaced (by adding a Chain with the same chainID), the replacement would not change the iteration order in any way.

Returns:
An Iterator for the Chains held by this Model.

numberOfChains

public int numberOfChains()
Returns the number of Chains held by this Model.

Returns:
The total number of Chains.

getHelix

public Helix getHelix(String helixID)
Returns the Helix with the helixID given as an argument.

Parameters:
helixID - the ID for the desired Helix.
Returns:
The requested Helix (or null if not found).

iteratorHelices

public Iterator<Helix> iteratorHelices()
Returns an Iterator for the Helices held by this Model. The order of iteration is the same as the order in which Helices were added to the Model. In the rare case where a Helix was replaced (by adding a Helix with the same helixID), the replacement would not change the iteration order in any way.

Returns:
An Iterator for the Helices held by this Model.

numberOfHelices

public int numberOfHelices()
Returns the number of Helices held by this Model.

Returns:
The total number of Helices.

getBetaStrand

public BetaStrand getBetaStrand(String betaStrandID)
Returns the BetaStrand with the betaStrandID given as an argument.

Parameters:
betaStrandID - the ID for the desired BetaStrand.
Returns:
The requested BetaStrand (or null if not found).

iteratorBetaStrands

public Iterator<BetaStrand> iteratorBetaStrands()
Returns an Iterator for the BetaStrands held by this Model. The order of iteration is the same as the order in which BetaStrands were added to the Model. In the rare case where a BetaStrand was replaced (by adding a BetaStrand with the same betaStrandID), the replacement would not change the iteration order in any way.

Returns:
An Iterator for the BetaStrands held by this Model.

numberOfBetaStrands

public int numberOfBetaStrands()
Returns the number of BetaStrands held by this Model.

Returns:
The total number of BetaStrands.

sortBetaStrands

public void sortBetaStrands()
Iterates through all Chains of the Model and modifies the linked hash map of beta-strands so that when an iterator for beta-strands is handed over (based on the linked list part) the beta-strands will be ordered according to the starting amino acid.


getLoop

public Loop getLoop(String loopID)
Returns the Loop with the loopID given as an argument.

Parameters:
loopID - the ID for the desired Loop.
Returns:
The requested Loop (or null if not found).

iteratorLoops

public Iterator<Loop> iteratorLoops()
Returns an Iterator for the Loops held by this Model. The order of iteration is the same as the order in which Loops were added to the Model. In the rare case where a Loop was replaced (by adding a Loop with the same loopID), the replacement would not change the iteration order in any way.

Returns:
An Iterator for the Loops held by this Model.

numberOfLoops

public int numberOfLoops()
Returns the number of Loops held by this Model.

Returns:
The total number of Loops.

hasAminoAcids

public boolean hasAminoAcids()
Returns true if the model holds any AminoAcids. Otherwise, returns false.

Returns:
True if the Model holds any AminoAcids.

hasHeterogens

public boolean hasHeterogens()
Returns true if the model holds any Heterogens. Otherwise, returns false.

Returns:
True if the Model holds any Heterogens.

hasWaters

public boolean hasWaters()
Returns true if the model holds any Waters. Otherwise, returns false.

Returns:
True if the Model holds any Waters.

processID

public String processID(String id,
                        String typeOfID)
                 throws InvalidIDException
Returns the Model ID after trimming any leading or trailing whitespace. The Model ID should be the Model serial number (a positive integer) from a PDB file, so it will be tested to see that it can be converted to an Integer (but the value returned is still the ID as a String).

Specified by:
processID in interface IDTest
Parameters:
id - Model ID to process.
typeOfID - type of ID (for possible use in error message).
Returns:
The trimmed Model ID.
Throws:
InvalidIDException - if the Model ID cannot be converted to a positive integer.

toString

public String toString()
Returns the modelID, which is the Model's number. The String returned cannot be null or empty, because the constructor checks that this read-only attribute has at least one non-whitespace character.

Overrides:
toString in class Object
Returns:
The Model's ID number as a String.

setMinMaxXYZ

public void setMinMaxXYZ(double minX,
                         double maxX,
                         double minY,
                         double maxY,
                         double minZ,
                         double maxZ)
Sets the minimum and maximum values for the xyz-coordinates. The center xyz-coordinate for the Model will also be calculated, along with the overall dimensions and maximum dimension.

Parameters:
minX - the minimum x-coordinate.
maxX - the maximum x-coordinate.
minY - the minimum y-coordinate.
maxY - the maximum y-coordinate.
minZ - the minimum z-coordinate.
maxZ - the maximum z-coordinate.

getX

public double getX()
Returns the x-coordinate for the center of gravity of the Model.

Returns:
the x-coordinate of the center.

getY

public double getY()
Returns the y-coordinate for the center of gravity of the Model.

Returns:
the y-coordinate of the center.

getZ

public double getZ()
Returns the z-coordinate for the center of gravity of the Model.

Returns:
the z-coordinate of the center.

getMinX

public double getMinX()
Returns the minimum x-coordinate value.

Returns:
the min x-coordinate.

getMaxX

public double getMaxX()
Returns the maximum x-coordinate value.

Returns:
the max x-coordinate.

getMinY

public double getMinY()
Returns the minimum y-coordinate value.

Returns:
the min y-coordinate.

getMaxY

public double getMaxY()
Returns the maximum y-coordinate value.

Returns:
the max y-coordinate.

getMinZ

public double getMinZ()
Returns the minimum z-coordinate value.

Returns:
the min z-coordinate.

getMaxZ

public double getMaxZ()
Returns the maximum z-coordinate value.

Returns:
the max z-coordinate.

getWidth

public double getWidth()
Returns the width of the Model (maxX - minX).

Returns:
the width as a double.

getHeight

public double getHeight()
Returns the height of the Model (maxY - minY).

Returns:
the height as a double.

getDepth

public double getDepth()
Returns the depth of the Model (maxZ - minZ).

Returns:
the depth as a double.

getMaxDimension

public double getMaxDimension()
Returns the maximum dimension (the greatest of width, height, or depth).

Returns:
the max dimension as a double.

getSegment

public Segment getSegment(String segmentID,
                          String regionID,
                          RegionEnum regionType)
Returns the requested Segment if it exists.

Parameters:
segmentID - the ID of the requested Segment.
regionID - the ID of the Region the Segment belongs to.
regionType - the type of Region the Segment belongs to.
Returns:
The requested Segment (or null if it does not exist).


Copyright © 2007-2008