edu.upenn.gloDB
Class ExactFeature

java.lang.Object
  extended by edu.upenn.gloDB.AbstractFeature
      extended by edu.upenn.gloDB.ExactFeature
All Implemented Interfaces:
Feature, java.io.Serializable, java.lang.Comparable

public class ExactFeature
extends AbstractFeature

These objects store exact positions bounding a Feature. For point Features just set start and stop equal. At some point it might be advantageous to create a PointFeature class which would only have one position.

Version:
$Id: ExactFeature.java,v 1.1.2.9 2005/01/07 19:56:59 fisher Exp $
See Also:
Serialized Form

Field Summary
private  int start
          The initial position defining this Feature.
private  int stop
          The last position defining this Feature.
 
Fields inherited from class edu.upenn.gloDB.AbstractFeature
attributes, source
 
Constructor Summary
ExactFeature(int start, int stop, Sequence source)
          Create a new ExactFeature object and add it to the set of Feature objects.
ExactFeature(int start, int stop, Sequence source, boolean addToPool)
          Create a new ExactFeature object and add the newly created ExactFeature object to the set of Feature objects if addToPool is true.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean contains(Feature feature)
          Returns 'true' if the Feature 'feature' exists within this Feature.
 int contains(int pos)
          Returns '-1' if this Feature exists after the integer 'pos', returns '0' if 'pos' is contained in this Feature, and '1' if 'pos' occurs after this Feature.
 boolean equals(java.lang.Object o)
          This will return true if the features are equal and the sources are the same.
 Feature flip()
          Inverts the positions, returning a new Feature object.
 java.lang.String getData()
          Returns the Sequence data from start to stop.
 java.lang.String getDataFormatted()
          Returns the Sequence data from start to stop, with "\n" inserted every Sequence.FORMAT_WIDTH characters (usually 50 to 80 chars).
 int getMax()
          Returns the maximum position of the Feature.
 int getMin()
          Returns the initial position of the Feature.
 int getStart()
          Returns the start position.
 int getStop()
          Returns the stop position.
 int length()
          Returns the number of positions contained in the Feature ((stop - start) + 1).
 Feature overlap(Feature feature)
          Returns the overlapping region between the two Features.
 boolean overlaps(Feature feature)
          Returns 'true' if the Feature 'feature' has a position that overlaps this Feature.
 java.lang.String toString()
          Only basic Feature information.
 java.lang.String toStringFull()
          Returns all Feature information.
 java.lang.String toStringMin()
          Only returns start/stop position information.
 
Methods inherited from class edu.upenn.gloDB.AbstractFeature
addAttribute, addAttribute, containsAttribute, delAttribute, getAttribute, getAttributes, getAttributesMap, getSource, getSourceID, getType, setAttributes, setAttributes
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

start

private int start
The initial position defining this Feature.


stop

private int stop
The last position defining this Feature.

Constructor Detail

ExactFeature

public ExactFeature(int start,
                    int stop,
                    Sequence source)
Create a new ExactFeature object and add it to the set of Feature objects.


ExactFeature

public ExactFeature(int start,
                    int stop,
                    Sequence source,
                    boolean addToPool)
Create a new ExactFeature object and add the newly created ExactFeature object to the set of Feature objects if addToPool is true.

Notes:
This should probably be 'protected' instead of 'public' because all ExactFeatures should really be added to featurePool.
Method Detail

getStart

public int getStart()
Returns the start position.


getStop

public int getStop()
Returns the stop position.


getData

public java.lang.String getData()
Returns the Sequence data from start to stop.


getDataFormatted

public java.lang.String getDataFormatted()
Returns the Sequence data from start to stop, with "\n" inserted every Sequence.FORMAT_WIDTH characters (usually 50 to 80 chars).


length

public int length()
Returns the number of positions contained in the Feature ((stop - start) + 1).


getMin

public int getMin()
Returns the initial position of the Feature.

Notes:
This will return the same value as getStart().

getMax

public int getMax()
Returns the maximum position of the Feature.

Notes:
This will return the same value as getStop().

flip

public Feature flip()
Inverts the positions, returning a new Feature object. For example, if the Feature had a start position of 10 and a stop position of 20 on a contig that was 100 positions long, then flipping the Feature would result in a new Feature object with a start position of 80 and a stop position of 90.

Notes:
Not yet implemented.

contains

public int contains(int pos)
Returns '-1' if this Feature exists after the integer 'pos', returns '0' if 'pos' is contained in this Feature, and '1' if 'pos' occurs after this Feature.

Notes:
This assumes 'pos' is positive and within this Feature's Sequence boundaries.

contains

public boolean contains(Feature feature)
Returns 'true' if the Feature 'feature' exists within this Feature.


overlaps

public boolean overlaps(Feature feature)
Returns 'true' if the Feature 'feature' has a position that overlaps this Feature.


overlap

public Feature overlap(Feature feature)
Returns the overlapping region between the two Features. If no overlap, then null is returned.


compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. If can't cast argument as an Feature, then throws a java.lang.ClassCastException. If different sources, then sorts on the source ID.

Throws:
java.lang.ClassCastException

equals

public boolean equals(java.lang.Object o)
               throws java.lang.ClassCastException
This will return true if the features are equal and the sources are the same. If can't cast argument as an ExactFeature, then throws a java.lang.ClassCastException.

Specified by:
equals in interface Feature
Overrides:
equals in class java.lang.Object
Throws:
java.lang.ClassCastException

toString

public java.lang.String toString()
Only basic Feature information.

Specified by:
toString in interface Feature
Overrides:
toString in class AbstractFeature

toStringMin

public java.lang.String toStringMin()
Only returns start/stop position information.


toStringFull

public java.lang.String toStringFull()
Returns all Feature information.




Copyright 2012 Stephen Fisher and Junhyong Kim, University of Pennsylvania. All Rights Reserved.