org.proteinshader.structure
Class Region

java.lang.Object
  extended by org.proteinshader.structure.Region
All Implemented Interfaces:
IDTest, Visitable
Direct Known Subclasses:
BetaStrand, Helix, Loop

public abstract class Region
extends Object
implements IDTest, Visitable

Abstract class that contains references to a region of a Chain of AminoAcids.

The known subclasses are Loop, Helix and BetaStrand.


Constructor Summary
Region(String startResidueID, String endResidueID, Chain chain)
          Constructor for use by subclasses.
 
Method Summary
abstract  void accept(Visitor visitor)
          Accepts a Visitor and does a callback.
protected  void createSegments(SegmentFactory factory)
          This protected method should be called by the constructor of concrete subclasses of Region so that the Segment objects for the Region can be created with the appropriate type of SegmentFactory.
 AminoAcid getAminoAcidAfterRegion()
          Returns the AminoAcid after this Region (or null if it does not exist).
 AminoAcid getAminoAcidBeforeRegion()
          Returns the AminoAcid before this Region (or null if it does not exist).
 String getChainID()
          Returns the ID of the Chain that this Region belongs to.
 String getEndResidueID()
          Returns the ID of the last Residue in the sequence.
 String getModelID()
          Returns the ID of the Model that this Region belongs to.
 Segment getSegment(String segmentID)
          Returns the Segment with the requested segmentID (if it exists).
 String getStartResidueID()
          Returns the ID of the first Residue in the sequence.
 String getStructureID()
          Returns the ID of the Structure that this Region belongs to.
 Iterator<AminoAcid> iteratorAminoAcids()
          Returns an Iterator for the AminoAcids referred to by this Region.
 Iterator<Segment> iteratorSegments()
          Returns an Iterator for the Segments owned by this Region.
protected  void markAminoAcids(String regionID, RegionEnum regionType)
          Used to mark each AminoAcid with the ID and type of Region it belongs to.
 int numberOfAminoAcids()
          Returns the number of AminoAcids referred to by this Region.
 int numberOfSegments()
          Returns the number of Segments owned by this Region.
 String processID(String id, String typeOfID)
          Returns the ID after trimming any leading or trailing whitespace.
 void setSegmentAlpha(float alpha)
          Sets the alpha component of the RGBA color for all Segments held by this Region.
 void setSegmentAlphaToDefault()
          The defalult alpha value is 1.0.
 void setSegmentRGB(float red, float green, float blue)
          Sets the RGB color on all Segments held by this Region.
 void setSegmentRGBToDefault()
          The default RGB color is determined by the Region type.
 void setSegmentsToAminoAcidColors()
          Sets the color of each Segment in the Region to the AAColorEnum for the AminoAcid the Segment corresponds to.
 void setSegmentsToRegionColor()
          Sets the color of each Segment in the Region to the default color for the type of Region the Segment belongs to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Region

public Region(String startResidueID,
              String endResidueID,
              Chain chain)
       throws InvalidRegionException,
              InvalidIDException
Constructor for use by subclasses.

A Region refers to a continuous sequence of AminoAcids in a Chain, so a start Residue ID and an end Residue ID must always be specified. The Constructor will cache references to the sequence of AminoAcids from the start Residue to the end Residue (or throw an exception if they cannot be found). If there is an AminoAcid before or after the Region, a memory of it will be kept.

Any leading or trailing whitespace will be trimmed from the startResidueID and the endResidueID. The ancestor IDs (Chain, Model, and Structure) will be stored after they are obtained from the Chain given as an argument.

Parameters:
startResidueID - ID of the first AminoAcid in the sequence.
endResidueID - ID of the last AminoAcid in the sequence.
chain - address of the Chain the Region is being added to.
Throws:
InvalidRegionException - if the sequence of AminoAcids (with at least two Residues) cannot be found on the Chain.
InvalidIDException - if startResidueID or endResidueID is null or does not have at least one non-whitespace character.
Method Detail

createSegments

protected void createSegments(SegmentFactory factory)
This protected method should be called by the constructor of concrete subclasses of Region so that the Segment objects for the Region can be created with the appropriate type of SegmentFactory.

This method should be called after the AminoAcids have already been marked as belonging to a particular Region object (which happens in the constructor of a subclass).

Segment objects can be viewed as a collection of local coordinate frames. How these local coordinate frames should be calculated will vary depending on the concrete subclass of Region, which is why different Segment factories are needed.

Parameters:
factory - a SegmentFactory created by a subclass of Region.

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.

getStartResidueID

public String getStartResidueID()
Returns the ID of the first Residue in the sequence.

Returns:
The start Residue ID as a String.

getEndResidueID

public String getEndResidueID()
Returns the ID of the last Residue in the sequence.

Returns:
The start Residue ID as a String.

getSegment

public Segment getSegment(String segmentID)
Returns the Segment with the requested segmentID (if it exists).

Parameters:
segmentID - the same as the residueID of the AminoAcid that the Segment corresponds to.
Returns:
The requested Segment (or null if not found).

getAminoAcidBeforeRegion

public AminoAcid getAminoAcidBeforeRegion()
Returns the AminoAcid before this Region (or null if it does not exist).

Returns:
The AminoAcid right before the start AminoAcid.

getAminoAcidAfterRegion

public AminoAcid getAminoAcidAfterRegion()
Returns the AminoAcid after this Region (or null if it does not exist).

Returns:
The AminoAcid right after the end AminoAcid.

getChainID

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

Returns:
The Chain ID as a String.

getModelID

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

Returns:
The Model ID as a String.

getStructureID

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

Returns:
The Structure ID as a String.

iteratorAminoAcids

public Iterator<AminoAcid> iteratorAminoAcids()
Returns an Iterator for the AminoAcids referred to by this Region.

Returns:
An Iterator for the AminoAcids held by this Chain.

numberOfAminoAcids

public int numberOfAminoAcids()
Returns the number of AminoAcids referred to by this Region.

Returns:
The total number of AminoAcids.

iteratorSegments

public Iterator<Segment> iteratorSegments()
Returns an Iterator for the Segments owned by this Region.

Returns:
An Iterator for the Segments held by this Chain.

setSegmentRGB

public void setSegmentRGB(float red,
                          float green,
                          float blue)
                   throws ColorOutOfRangeException
Sets the RGB color on all Segments held by this Region. Each value must be between 0.0 and 1.0, inclusive.

Parameters:
red - component of the RGBA color.
green - component of the RGBA color.
blue - component of the RGBA color.
Throws:
ColorOutOfRangeException - if a color value is less than 0.0 or greater than 1.0.

setSegmentAlpha

public void setSegmentAlpha(float alpha)
                     throws ColorOutOfRangeException
Sets the alpha component of the RGBA color for all Segments held by this Region. The value must be between 0.0 and 1.0, inclusive.

Parameters:
alpha - component of the RGBA color.
Throws:
ColorOutOfRangeException - if alpha is less than 0.0 or greater than 1.0.

setSegmentsToAminoAcidColors

public void setSegmentsToAminoAcidColors()
Sets the color of each Segment in the Region to the AAColorEnum for the AminoAcid the Segment corresponds to.


setSegmentsToRegionColor

public void setSegmentsToRegionColor()
Sets the color of each Segment in the Region to the default color for the type of Region the Segment belongs to.


setSegmentRGBToDefault

public void setSegmentRGBToDefault()
The default RGB color is determined by the Region type.


setSegmentAlphaToDefault

public void setSegmentAlphaToDefault()
The defalult alpha value is 1.0.


numberOfSegments

public int numberOfSegments()
Returns the number of Segments owned by this Region.

Returns:
The total number of Segments.

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.
typeOfID - the type of ID (for possible inclusion in a error message).
Returns:
The trimmed ID.
Throws:
InvalidIDException - if the trimmed ID does not have at least one character.

markAminoAcids

protected void markAminoAcids(String regionID,
                              RegionEnum regionType)
Used to mark each AminoAcid with the ID and type of Region it belongs to.

Parameters:
regionID - will be a loopID, helixID, or a betaStrandID.
regionType - will be LOOP, HELIX, or BETA_STRAND.


Copyright © 2007-2008