apollo.gui.detailviewers.sequencealigner
Class Tier

java.lang.Object
  extended by apollo.gui.detailviewers.sequencealigner.Tier
All Implemented Interfaces:
AnnotationChangeListener, TierI, java.util.EventListener, org.bdgp.util.Range

public class Tier
extends java.lang.Object
implements TierI

A Tier is a container class that holds a set of non overlapping SeqFeatureI's. When referencing a position the 0th position corresponds to the first base in the reference sequence. The level of a tier is related to the different perspectives at which you can look at a tier. The Level.TOP is a view of the tier at a transcript level while the Level.BOTTOM corresponds to the exon level view. At each level a position is associated with a range, if that range corresponds to a feature then a position is also associated to that feature. The strand of a tier identifies how to translate from a tier position to a chromosome relative position. When adding features to a tier they should all be of the same strand type, and reading frame. Additionally all added features should be within the bounds of the reference sequence. Are type and phase needed?


Nested Class Summary
 
Nested classes/interfaces inherited from interface apollo.gui.detailviewers.sequencealigner.TierI
TierI.Level
 
Field Summary
protected  java.util.Map<TierI.Level,org.bdgp.util.RangeHash> views
          The different levels this tier can be viewed from.
 
Constructor Summary
Tier(SequenceI reference, Strand strand, ReadingFrame readingFrame)
          Creates a new Tier
 
Method Summary
 boolean addFeature(SeqFeatureI feature)
          Adds the feature to this Tier
 java.util.Collection<SeqFeatureI> addFeatures(java.util.Collection<SeqFeatureI> features)
          Adds a collection of features to this tier
 char charAt(int position)
          Returns the base on the reference sequence for a given position
 void clear()
           
 SeqFeatureI featureAt(int position, TierI.Level level)
          Gets the feature that contains a given position
 boolean featureExsitsAt(int position, TierI.Level level)
          Determines if there exsists a feature at a given position
 SeqFeatureI featureIn(org.bdgp.util.Range range, boolean exact, TierI.Level level)
          Gets the first(?) feature within a given range inclusive(?)
 java.util.Collection<SeqFeatureI> featuresIn(org.bdgp.util.Range range, TierI.Level level)
          Gets all of the features within a given range
 int getBasePair(int position)
          Translates a position on the tier into base pair coordinates.
 int getBoundaryType(int position, TierI.Level level)
          Returns the type of boundary of a base at a given position and level.
 java.util.Collection<SeqFeatureI> getFeatures(TierI.Level level)
          Gets a collection of all the top level features in the tier
 int getHigh()
          Gets the highest position on this tier
 int getLow()
          Gets the lowest position on this tier
 SeqFeatureI getNextFeature(int position, TierI.Level level)
          gets the next feature in the 3' direction
 int getPosition(int basePair)
          Translates a base pair coordinate into a position on the tier
 SeqFeatureI getPrevFeature(int position, TierI.Level level)
          gets the next feature in the 5' direction
 ReadingFrame getReadingFrame()
           
 SequenceI getReference()
          Returns the sequence which is used as a reference for this tier.
 Strand getStrand()
          Gets the strand of this tier.
 SequenceType getType()
           
 boolean handleAnnotationChangeEvent(AnnotationChangeEvent evt)
           
 int numFeatures(TierI.Level level)
          Gets the number of features at a given level.
 org.bdgp.util.Range rangeAt(int position, TierI.Level level)
          Returns the range that corresponds to a given position at a level.
 void removeFeature(SeqFeatureI feature)
          Removes a given feature from this tier.
 void setReadingFrame(ReadingFrame rf)
           
 void setReference(SequenceI s)
           
 void setStrand(Strand s)
           
 boolean willOverlap(SeqFeatureI feature)
          Determine weather or not a feature will overlap with another feature already in the tier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

views

protected java.util.Map<TierI.Level,org.bdgp.util.RangeHash> views
The different levels this tier can be viewed from.

Constructor Detail

Tier

public Tier(SequenceI reference,
            Strand strand,
            ReadingFrame readingFrame)
Creates a new Tier

Parameters:
reference - the sequence on which the tier is based
strand - the strand of the tier
phase - the reading frame of the tier
Method Detail

addFeature

public boolean addFeature(SeqFeatureI feature)
Adds the feature to this Tier

Specified by:
addFeature in interface TierI
Parameters:
feature - the feature to be added
Returns:
true if the feature was successfully added false otherwise
See Also:
Calls willOverlap

addFeatures

public java.util.Collection<SeqFeatureI> addFeatures(java.util.Collection<SeqFeatureI> features)
Adds a collection of features to this tier

Specified by:
addFeatures in interface TierI
Parameters:
features - a collection of features to be added
Returns:
the collection of features which were not added
See Also:
Calls addFeature

getBoundaryType

public int getBoundaryType(int position,
                           TierI.Level level)
Returns the type of boundary of a base at a given position and level.

Specified by:
getBoundaryType in interface TierI
Parameters:
position - the position to look at
level - the level to look at
Returns:
a type of boundary
See Also:
apollo.gui.detailviewers.exonviewer.TierI#boundaryTypeAt(int, int)

charAt

public char charAt(int position)
Returns the base on the reference sequence for a given position

Specified by:
charAt in interface TierI
Parameters:
position - the position of the base that is returned
Returns:
a base character
See Also:
apollo.gui.detailviewers.exonviewer.TierI#charAt(int)

featureAt

public SeqFeatureI featureAt(int position,
                             TierI.Level level)
Gets the feature that contains a given position

Specified by:
featureAt in interface TierI
Parameters:
position - the position that should be within the returned feature
level - the level to view the tier at
Returns:
the feature that contains the position or null
See Also:
apollo.gui.detailviewers.exonviewer.TierI#featureAt(int, int)

featureExsitsAt

public boolean featureExsitsAt(int position,
                               TierI.Level level)
Determines if there exsists a feature at a given position

Specified by:
featureExsitsAt in interface TierI
Parameters:
position - the position to look for a feature at
level - the level to view the tier at
Returns:
true if featureAt(position,level) returns a feature false if it returns null
See Also:
apollo.gui.detailviewers.exonviewer.TierI#featureExsitsAt(int, int)

featureIn

public SeqFeatureI featureIn(org.bdgp.util.Range range,
                             boolean exact,
                             TierI.Level level)
Gets the first(?) feature within a given range inclusive(?)

Specified by:
featureIn in interface TierI
Parameters:
range - a position range to look for features within
exact - not sure...
level - the level to view the tier at
See Also:
apollo.gui.detailviewers.exonviewer.TierI#featureIn(org.bdgp.util.Range, boolean, int)

featuresIn

public java.util.Collection<SeqFeatureI> featuresIn(org.bdgp.util.Range range,
                                                    TierI.Level level)
Gets all of the features within a given range

Specified by:
featuresIn in interface TierI
Parameters:
range - a position range to look for the features within
level - the level to view the tier at
See Also:
apollo.gui.detailviewers.exonviewer.TierI#featuresIn(org.bdgp.util.Range, int)

getReference

public SequenceI getReference()
Returns the sequence which is used as a reference for this tier.

Specified by:
getReference in interface TierI
Returns:
the reference sequence for this tier
See Also:
apollo.gui.detailviewers.exonviewer.TierI#getReference()

setReference

public void setReference(SequenceI s)
Specified by:
setReference in interface TierI

numFeatures

public int numFeatures(TierI.Level level)
Gets the number of features at a given level.

Specified by:
numFeatures in interface TierI
Parameters:
level - the level to view the tier at
Returns:
the number of features
See Also:
apollo.gui.detailviewers.exonviewer.TierI#numFeatures(int)

rangeAt

public org.bdgp.util.Range rangeAt(int position,
                                   TierI.Level level)
Returns the range that corresponds to a given position at a level. All of the positions within the returned range will be of the same type at that level.

Specified by:
rangeAt in interface TierI
Parameters:
position - a position within the tier
level - a level to view the tier at
Returns:
a range of positions which all have the same type
See Also:
apollo.gui.detailviewers.exonviewer.TierI#rangeAt(int, int)

removeFeature

public void removeFeature(SeqFeatureI feature)
Removes a given feature from this tier.

Specified by:
removeFeature in interface TierI
Parameters:
feature - the feature to be removed
See Also:
apollo.gui.detailviewers.exonviewer.TierI#removeFeature(apollo.datamodel.SeqFeatureI)

getFeatures

public java.util.Collection<SeqFeatureI> getFeatures(TierI.Level level)
Gets a collection of all the top level features in the tier

Specified by:
getFeatures in interface TierI
Returns:
a collection of features

getHigh

public int getHigh()
Gets the highest position on this tier

Specified by:
getHigh in interface org.bdgp.util.Range
Returns:
the highest position
See Also:
Range.getHigh()

getLow

public int getLow()
Gets the lowest position on this tier

Specified by:
getLow in interface org.bdgp.util.Range
Returns:
the lowest position
See Also:
Range.getLow()

getBasePair

public int getBasePair(int position)
Translates a position on the tier into base pair coordinates.

Specified by:
getBasePair in interface TierI
Parameters:
position - a position within the tier
Returns:
the base pair coordinate for that position

getPosition

public int getPosition(int basePair)
Translates a base pair coordinate into a position on the tier

Specified by:
getPosition in interface TierI
Parameters:
basePair - a base pair coordinate within the tier
Returns:
a position within the tier

willOverlap

public boolean willOverlap(SeqFeatureI feature)
Determine weather or not a feature will overlap with another feature already in the tier. Two features overlap if they both contain a common set of base pair locations.

Specified by:
willOverlap in interface TierI
Parameters:
feature - the feature to be tested
Returns:
true if the feature will overlap false otherwise

getStrand

public Strand getStrand()
Gets the strand of this tier.

Specified by:
getStrand in interface TierI
Returns:
the strand of this tier

setStrand

public void setStrand(Strand s)
Specified by:
setStrand in interface TierI

getReadingFrame

public ReadingFrame getReadingFrame()
Specified by:
getReadingFrame in interface TierI

setReadingFrame

public void setReadingFrame(ReadingFrame rf)
Specified by:
setReadingFrame in interface TierI

getNextFeature

public SeqFeatureI getNextFeature(int position,
                                  TierI.Level level)
gets the next feature in the 3' direction

Specified by:
getNextFeature in interface TierI

getPrevFeature

public SeqFeatureI getPrevFeature(int position,
                                  TierI.Level level)
gets the next feature in the 5' direction

Specified by:
getPrevFeature in interface TierI

clear

public void clear()
Specified by:
clear in interface TierI

handleAnnotationChangeEvent

public boolean handleAnnotationChangeEvent(AnnotationChangeEvent evt)
Specified by:
handleAnnotationChangeEvent in interface AnnotationChangeListener

getType

public SequenceType getType()
Specified by:
getType in interface TierI