SimpleRichFeature (BioJava-1.5-beta API)
Keywords: org.biojavax.bio.seq.SimpleRichFeature class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.biojavax.bio.seq
Class SimpleRichFeature

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojavax.bio.seq.SimpleRichFeature

All Implemented Interfaces:
  Comparable, Annotatable, Feature, FeatureHolder, StrandedFeature, Changeable, RichFeature, RichFeatureHolder, RankedCrossRefable, RichAnnotatable

    public class SimpleRichFeature

extends AbstractChangeable
implements RichFeature

A simple implementation of RichFeature.

Since:
  1.5
Author:
  Richard Holland, Mark Schreiber

Nested Class Summary

Nested classes/interfaces inherited from interface org.biojavax.bio.seq.RichFeature
`RichFeature.Template, RichFeature.Tools`

Nested classes/interfaces inherited from interface org.biojava.bio.seq.StrandedFeature
`StrandedFeature.Strand`

Nested classes/interfaces inherited from interface org.biojava.bio.seq.Feature
`Feature.ByLocationComparator`

Nested classes/interfaces inherited from interface org.biojava.bio.seq.FeatureHolder
`FeatureHolder.EmptyFeatureHolder`

Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
`Annotatable.AnnotationForwarder`

Field Summary

Fields inherited from interface org.biojavax.bio.seq.RichFeature
`CROSSREF, LOCATION, NAME, PARENT, RANK, RELATION, SOURCETERM, TYPETERM`

Fields inherited from interface org.biojava.bio.seq.StrandedFeature
`NEGATIVE, POSITIVE, STRAND, UNKNOWN`

Fields inherited from interface org.biojava.bio.seq.Feature
`byLocationOrder, PROPERTY_DATA_KEY, SOURCE, TYPE`

Fields inherited from interface org.biojava.bio.seq.FeatureHolder
`EMPTY_FEATURE_HOLDER, FEATURES, SCHEMA`

Fields inherited from interface org.biojava.bio.Annotatable
`ANNOTATION`

Constructor Summary
`protected` | `SimpleRichFeature()`
`` | `SimpleRichFeature(FeatureHolder parent, Feature.Template templ)` Creates a new instance of SimpleRichFeature based on a template.

Method Summary
`void` | `addFeatureRelationship(RichFeatureRelationship relationship)` Adds a relationship to this feature holder.
`void` | `addRankedCrossRef(RankedCrossRef crossref)` Adds a ranked cross reference to the existing set.
`int` | `compareTo(Object o)` Features are sorted by rank only.
`boolean` | `containsFeature(Feature f)` Check if the feature is present in this holder.
`int` | `countFeatures()` Count how many features are contained.
`Feature` | `createFeature(Feature.Template ft)` Create a new Feature, and add it to this FeatureHolder.
`boolean` | `equals(Object o)` Features are equal when they have the same parent, type, source and rank.
`Iterator` | `features()` Iterate over any child features which are held by this feature.
`FeatureHolder` | `filter(FeatureFilter filter)` Query this set of features using a supplied `FeatureFilter`.
`FeatureHolder` | `filter(FeatureFilter fc, boolean recurse)` Return a new FeatureHolder that contains all of the children of this one that passed the filter fc.
`Annotation` | `getAnnotation()` Should return the associated annotation object.
`Set` | `getFeatureRelationshipSet()` Returns the set of relationships held in this feature holder. Warning this method gives access to the original Collection not a copy.
`Location` | `getLocation()` The location of this feature.
`String` | `getName()` Returns the name of this feature.
`Set` | `getNoteSet()` Returns the set of notes associated with this object. Warning this method gives access to the original Collection not a copy.
`FeatureHolder` | `getParent()` Return the `FeatureHolder` to which this feature has been attached.
`int` | `getRank()` Returns the rank of this feature.
`Set` | `getRankedCrossRefs()` Returns the set of all ranked cross references associated with an object. Warning this method gives access to the original Collection not a copy.
`FeatureFilter` | `getSchema()` Return a schema-filter for this `FeatureHolder`.
`Sequence` | `getSequence()` Return the `Sequence` object to which this feature is (ultimately) attached.
`String` | `getSource()` The source of the feature.
`Term` | `getSourceTerm()` An ontology term defining the source of this feature.
`StrandedFeature.Strand` | `getStrand()` Retrieve the strand that this feature lies upon.
`SymbolList` | `getSymbols()` Return a list of symbols that are contained in this feature.
`String` | `getType()` The type of the feature.
`Term` | `getTypeTerm()` An ontology term defining the type of feature.
`int` | `hashCode()`
`Feature.Template` | `makeTemplate()` Create a new Template that could be used to generate a feature identical to this one.
`void` | `removeFeature(Feature f)` Remove a feature from this FeatureHolder.
`void` | `removeFeatureRelationship(RichFeatureRelationship relationship)` Removes a relationship from this feature holder.
`void` | `removeRankedCrossRef(RankedCrossRef crossref)` Removes a ranked cross reference from the existing set.
`void` | `setFeatureRelationshipSet(Set relationships)` Clears the relations from this feautre holder and replaces them with a new set. Warning this method gives access to the original Collection not a copy.
`void` | `setLocation(Location loc)` The new location for this feature.
`void` | `setName(String name)` Sets the name of this feature.
`void` | `setNoteSet(Set notes)` Clears the notes associated with this object and replaces them with the contents of this set. Warning this method gives access to the original Collection not a copy.
`void` | `setParent(FeatureHolder parent)` Sets the parent of this feature.
`void` | `setRank(int rank)` Sets the rank of this feature.
`void` | `setRankedCrossRefs(Set crossrefs)` Sets the ranked cross references associated with an object. Warning this method gives access to the original Collection not a copy.
`void` | `setSource(String source)` Change the source of the Feature.
`void` | `setSourceTerm(Term t)` Set the source ontology-term for this feature.
`void` | `setStrand(StrandedFeature.Strand strand)` Set the strand that this feature lies upon. NOT IMPLEMENTED.
`void` | `setType(String type)` Change the type of this feature.
`void` | `setTypeTerm(Term t)` Set the type ontology-term for this feature.
`String` | `toString()` Form: "(#rank) parent:type,source(location)"

Methods inherited from class org.biojava.utils.AbstractChangeable
`addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Constructor Detail

### SimpleRichFeature

    public SimpleRichFeature(FeatureHolder parent,
                             Feature.Template templ)
                      throws ChangeVetoException,
                             InvalidTermException

  Creates a new instance of SimpleRichFeature based on a template.

  Parameters:
    `parent` - The parent feature holder.
    `templ` - The template to construct the feature from.
  Throws:
    `ChangeVetoException` - if we don't want to be like the template.
    `InvalidTermException` - if any of the template terms are bad.

### SimpleRichFeature

    protected SimpleRichFeature()

Method Detail

### makeTemplate

    public Feature.Template makeTemplate()

  Create a new Template that could be used to generate a feature identical to this one. The fields of the template can be edited without changing the feature.

  Specified by:
    `makeTemplate` in interface `Feature`
  Returns:
    a new Template that would make a feature like this one

### getAnnotation

    public Annotation getAnnotation()

  Should return the associated annotation object.

  Specified by:
    `getAnnotation` in interface `Annotatable`
  Returns:
    an Annotation object, never null

### getNoteSet

    public Set getNoteSet()

  Returns the set of notes associated with this object. Would normally delegate call to internal RichAnnotation instance. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `getNoteSet` in interface `RichAnnotatable`
  Returns:
    set a set of Note objects.
  See Also:
    `Note`

### setNoteSet

    public void setNoteSet(Set notes)
                    throws ChangeVetoException

  Clears the notes associated with this object and replaces them with the contents of this set. Would normally delegate call to internal RichAnnotation instance. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `setNoteSet` in interface `RichAnnotatable`
  Parameters:
    `notes` - the set of Note objects to replace the existing ones with.
  Throws:
    `ChangeVetoException` - if the set is null or contains any objects that are not Note objects.
  See Also:
    `Note`

### setName

    public void setName(String name)
                 throws ChangeVetoException

  Sets the name of this feature.

  Specified by:
    `setName` in interface `RichFeature`
  Parameters:
    `name` - the name the feature should identify itself with.
  Throws:
    `ChangeVetoException` - if the new value is unacceptable.

### getName

    public String getName()

  Returns the name of this feature.

  Specified by:
    `getName` in interface `RichFeature`
  Returns:
    the name.

### setRank

    public void setRank(int rank)
                 throws ChangeVetoException

  Sets the rank of this feature.

  Specified by:
    `setRank` in interface `RichFeature`
  Parameters:
    `rank` - the rank the feature should identify itself with.
  Throws:
    `ChangeVetoException` - if the new value is unacceptable.

### getRank

    public int getRank()

  Returns the rank of this feature.

  Specified by:
    `getRank` in interface `RichFeature`
  Returns:
    the rank.

### getSequence

    public Sequence getSequence()

  Return the `Sequence` object to which this feature is (ultimately) attached. For top level features, this will be equal to the `FeatureHolder` returned by `getParent`.

  Specified by:
    `getSequence` in interface `Feature`
  Returns:
    the ultimate parent Sequence

### getSource

    public String getSource()

  The source of the feature. This may be a program or process.

  Specified by:
    `getSource` in interface `Feature`
  Returns:
    the source, or generator

### setSource

    public void setSource(String source)
                   throws ChangeVetoException

  Change the source of the Feature.

  Specified by:
    `setSource` in interface `Feature`
  Parameters:
    `source` - the new source String
  Throws:
    `ChangeVetoException` - if the source can't be altered

### getSourceTerm

    public Term getSourceTerm()

  An ontology term defining the source of this feature. This is optional, and will default to `OntoTools.ANY` in implementations which aren't ontology aware.

  Specified by:
    `getSourceTerm` in interface `Feature`

### setSourceTerm

    public void setSourceTerm(Term t)
                       throws ChangeVetoException,
                              InvalidTermException

  Set the source ontology-term for this feature. If this succeeds, it will generally also change the source name.

  Specified by:
    `setSourceTerm` in interface `Feature`
  Throws:
    `ChangeVetoException` - if changes are not allowed
    `InvalidTermException` - if the specified term is not an acceptable type for this feature.

### getType

    public String getType()

  The type of the feature.

  Specified by:
    `getType` in interface `Feature`
  Returns:
    the type of this sequence

### setType

    public void setType(String type)
                 throws ChangeVetoException

  Change the type of this feature.

  Specified by:
    `setType` in interface `Feature`
  Parameters:
    `type` - new type String
  Throws:
    `ChangeVetoException` - if the type can't be altered

### getTypeTerm

    public Term getTypeTerm()

  An ontology term defining the type of feature. This is optional, and will default to `OntoTools.ANY` in implementations which aren't ontology aware.

  Specified by:
    `getTypeTerm` in interface `Feature`

### setTypeTerm

    public void setTypeTerm(Term t)
                     throws ChangeVetoException,
                            InvalidTermException

  Set the type ontology-term for this feature. If this succeeds, it will generally also change the source name.

  Specified by:
    `setTypeTerm` in interface `Feature`
  Throws:
    `ChangeVetoException` - if changes are not allowed
    `InvalidTermException` - if the specified term is not an acceptable type for this feature.

### getSymbols

    public SymbolList getSymbols()

  Return a list of symbols that are contained in this feature.

  The symbols may not be contiguous in the original sequence, but they will be concatenated together in the resulting SymbolList.

  The order of the Symbols within the resulting symbol list will be according to the concept of ordering within the location object.

  If the feature location is modified then this does not modify any SymbolList produced by earlier invocations of this method.

  Specified by:
    `getSymbols` in interface `Feature`
  Specified by:
    `getSymbols` in interface `StrandedFeature`
  Returns:
    a SymbolList containing each symbol of the parent sequence contained within this feature in the order they appear in the parent

### getLocation

    public Location getLocation()

  The location of this feature.

  The location may be complicated, or simply a range. The annotation is assumed to apply to all the region contained within the location.

  Specified by:
    `getLocation` in interface `Feature`
  Returns:
    a Location anchoring this feature

### setLocation

    public void setLocation(Location loc)
                     throws ChangeVetoException

  The new location for this feature.

  The location may be complicated or simply a range. The annotation is assumed to apply to the entire region contained within the location. Any values returned from methods that rely on the old location must not be affected.

  Specified by:
    `setLocation` in interface `Feature`
  Parameters:
    `loc` - the new Location for this feature
  Throws:
    `ChangeVetoException` - if the location can't be altered

### getParent

    public FeatureHolder getParent()

  Return the `FeatureHolder` to which this feature has been attached. This will be a `Sequence` object for top level features, and a `Feature` object for features further down the tree.

  Specified by:
    `getParent` in interface `Feature`

### setParent

    public void setParent(FeatureHolder parent)
                   throws ChangeVetoException

  Sets the parent of this feature.

  Specified by:
    `setParent` in interface `RichFeature`
  Parameters:
    `parent` - the parent the feature should identify itself with.
  Throws:
    `ChangeVetoException` - if the new value is unacceptable.

### getRankedCrossRefs

    public Set getRankedCrossRefs()

  Returns the set of all ranked cross references associated with an object. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `getRankedCrossRefs` in interface `RankedCrossRefable`
  Returns:
    a set of RankedCrossRef objects.

### setRankedCrossRefs

    public void setRankedCrossRefs(Set crossrefs)
                            throws ChangeVetoException

  Sets the ranked cross references associated with an object. Null will throw an exception but the empty set is fine. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `setRankedCrossRefs` in interface `RankedCrossRefable`
  Parameters:
    `crossrefs` - a set of RankedCrossRef objects.
  Throws:
    `ChangeVetoException` - if the set was null or any of its contents were not RankedCrossRef objects.

### addRankedCrossRef

    public void addRankedCrossRef(RankedCrossRef crossref)
                           throws ChangeVetoException

  Adds a ranked cross reference to the existing set. If already present, this call is ignored. Null values are not acceptable.

  Specified by:
    `addRankedCrossRef` in interface `RankedCrossRefable`
  Parameters:
    `crossref` - the ranked cross reference to add.
  Throws:
    `ChangeVetoException` - if the parameter is null.

### removeRankedCrossRef

    public void removeRankedCrossRef(RankedCrossRef crossref)
                              throws ChangeVetoException

  Removes a ranked cross reference from the existing set. If not present, this call is ignored. Null values are not acceptable.

  Specified by:
    `removeRankedCrossRef` in interface `RankedCrossRefable`
  Parameters:
    `crossref` - the ranked cross reference to remove.
  Throws:
    `ChangeVetoException` - if the parameter is null.

### getFeatureRelationshipSet

    public Set getFeatureRelationshipSet()

  Returns the set of relationships held in this feature holder. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `getFeatureRelationshipSet` in interface `RichFeatureHolder`
  Returns:
    a set of RichFeatureRelationship objects.

### setFeatureRelationshipSet

    public void setFeatureRelationshipSet(Set relationships)
                                   throws ChangeVetoException

  Clears the relations from this feautre holder and replaces them with a new set. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.

  Specified by:
    `setFeatureRelationshipSet` in interface `RichFeatureHolder`
  Parameters:
    `relationships` - the new set of features this holder should have. The set must contain only RichFeatureRelationship objects.
  Throws:
    `ChangeVetoException` - if the new set could not be installed.

### addFeatureRelationship

    public void addFeatureRelationship(RichFeatureRelationship relationship)
                                throws ChangeVetoException

  Adds a relationship to this feature holder.

  Specified by:
    `addFeatureRelationship` in interface `RichFeatureHolder`
  Parameters:
    `relationship` - the relationship to add.
  Throws:
    `ChangeVetoException` - if the relationship is unacceptable.

### removeFeatureRelationship

    public void removeFeatureRelationship(RichFeatureRelationship relationship)
                                   throws ChangeVetoException

  Removes a relationship from this feature holder.

  Specified by:
    `removeFeatureRelationship` in interface `RichFeatureHolder`
  Parameters:
    `relationship` - the relationship to remove.
  Throws:
    `ChangeVetoException` - if it cannot be removed.

### containsFeature

    public boolean containsFeature(Feature f)

  Check if the feature is present in this holder.

  Specified by:
    `containsFeature` in interface `FeatureHolder`
  Parameters:
    `f` - the Feature to check
  Returns:
    true if f is in this set

### countFeatures

    public int countFeatures()

  Count how many features are contained.

  Specified by:
    `countFeatures` in interface `FeatureHolder`
  Returns:
    a positive integer or zero, equal to the number of features contained

### createFeature

    public Feature createFeature(Feature.Template ft)
                          throws BioException,
                                 ChangeVetoException

  Create a new Feature, and add it to this FeatureHolder. This method will generally only work on Sequences, and on some Features which have been attached to Sequences.

  Specified by:
    `createFeature` in interface `FeatureHolder`
  Throws:
    `BioException` - if something went wrong during creating the feature
    `ChangeVetoException` - if this FeatureHolder does not support creation of new features, or if the change was vetoed

### features

    public Iterator features()

  Iterate over any child features which are held by this feature. The order of iteration MAY be significant for some types of Feature.

  Specified by:
    `features` in interface `Feature`
  Specified by:
    `features` in interface `FeatureHolder`
  Returns:
    an Iterator

### filter

    public FeatureHolder filter(FeatureFilter filter)

  Query this set of features using a supplied `FeatureFilter`.

  Specified by:
    `filter` in interface `FeatureHolder`
  Parameters:
    `filter` - the `FeatureFilter` to apply.
  Returns:
    all features in this container which match `filter`.

### filter

    public FeatureHolder filter(FeatureFilter fc,
                                boolean recurse)

  Return a new FeatureHolder that contains all of the children of this one that passed the filter fc. This method is scheduled for deprecation. Use the 1-arg filter instead.

  Specified by:
    `filter` in interface `FeatureHolder`
  Parameters:
    `fc` - the FeatureFilter to apply
    `recurse` - true if all features-of-features should be scanned, and a single flat collection of features returned, or false if just immediate children should be filtered.

### getSchema

    public FeatureFilter getSchema()

  Return a schema-filter for this `FeatureHolder`. This is a filter which all `Feature`s immediately contained by this `FeatureHolder` will match. It need not directly match their child features, but it can (and should!) provide information about them using `FeatureFilter.OnlyChildren` filters. In cases where there is no feature hierarchy, this can be indicated by including `FeatureFilter.leaf` in the schema filter.

  For the truly non-informative case, it is possible to return `FeatureFilter.all`. However, it is almost always possible to provide slightly more information that this. For example, `Sequence` objects should, at a minimum, return `FeatureFilter.top_level`. `Feature` objects should, as a minimum, return `FeatureFilter.ByParent(new FeatureFilter.ByFeature(this))`.

  Specified by:
    `getSchema` in interface `FeatureHolder`
  Returns:
    the schema filter

### removeFeature

    public void removeFeature(Feature f)
                       throws ChangeVetoException,
                              BioException

  Remove a feature from this FeatureHolder.

  Specified by:
    `removeFeature` in interface `FeatureHolder`
  Throws:
    `ChangeVetoException` - if this FeatureHolder does not support feature removal or if the change was vetoed
    `BioException` - if there was an error removing the feature

### setStrand

    public void setStrand(StrandedFeature.Strand strand)
                   throws ChangeVetoException

  Set the strand that this feature lies upon.

  This will be one of StrandedFeature.POSITIVE or NEGATIVE. NOT IMPLEMENTED.

  Specified by:
    `setStrand` in interface `StrandedFeature`
  Parameters:
    `strand` - a `Strand`.
  Throws:
    `ChangeVetoException` - if the strand may not be changed.

### getStrand

    public StrandedFeature.Strand getStrand()

  Retrieve the strand that this feature lies upon.

  This will be one of StrandedFeature.POSITIVE or NEGATIVE.

  Specified by:
    `getStrand` in interface `StrandedFeature`
  Returns:
    one of the Strand constants

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object o)

  Features are equal when they have the same parent, type, source and rank.

  Overrides:
    `equals` in class `Object`

### compareTo

    public int compareTo(Object o)

  Features are sorted by rank only. However, equal ranks are acceptable, so -1 is returned if the ranks are equal.

  Specified by:
    `compareTo` in interface `Comparable`

### toString

    public String toString()

  Form: "(#rank) parent:type,source(location)"

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD