Class SimpleRichFeature
- All Implemented Interfaces:
Comparable
,Annotatable
,Feature
,FeatureHolder
,StrandedFeature
,Changeable
,RichFeature
,RichFeatureRelationshipHolder
,RankedCrossRefable
,RichAnnotatable
- Since:
- 1.5
- Author:
- Richard Holland, Mark Schreiber, Bubba Puryear, George Waldon
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarder
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.biojavax.bio.seq.RichFeature
RichFeature.Template, RichFeature.Tools
Nested classes/interfaces inherited from interface org.biojava.bio.seq.StrandedFeature
StrandedFeature.Strand
-
Field Summary
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATION
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.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
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SimpleRichFeature
(FeatureHolder parent, Feature.Template templ) Creates a new instance of SimpleRichFeature based on a template. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFeatureRelationship
(RichFeatureRelationship relationship) Adds a relationship to this feature holder.void
addRankedCrossRef
(RankedCrossRef crossref) Adds a ranked cross reference to the existing set.int
Features are sorted first by rank, then parent, type, and source.boolean
Check if the feature is present in this holder.int
Count how many features are contained.Create a new Feature, and add it to this FeatureHolder.boolean
Features are equal when they have the same rank, parent, type, and source.features()
Iterate over any child features which are held by this feature.filter
(FeatureFilter filter) Query this set of features using a suppliedFeatureFilter
.filter
(FeatureFilter fc, boolean recurse) Return a new FeatureHolder that contains all of the children of this one that passed the filter fc.Should return the associated annotation object.Returns the set of relationships held in this feature holder.getId()
Gets the Hibernate ID.The location of this feature.getName()
Returns the name of this feature.Returns the set of notes associated with this object.Return theFeatureHolder
to which this feature has been attached.int
getRank()
Returns the rank of this feature.Returns the set of all ranked cross references associated with an object.Return the associated annotation object.Return a schema-filter for thisFeatureHolder
.Return theSequence
object to which this feature is (ultimately) attached.The source of the feature.An ontology term defining the source of this feature.Retrieve the strand that this feature lies upon.Return a list of symbols that are contained in this feature.getType()
The type of the feature.An ontology term defining the type of feature.int
hashCode()
Create a new Template that could be used to generate a feature identical to this one.void
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<RichFeatureRelationship> relationships) Clears the relations from this feature holder and replaces them with a new set.void
Sets the Hibernate ID.void
setLocation
(Location loc) The new location for this feature.void
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.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.void
Change the source of the Feature.void
Set the source ontology-term for this feature.void
setStrand
(StrandedFeature.Strand strand) Set the strand that this feature lies upon.void
Change the type of this feature.void
setTypeTerm
(Term t) Set the type ontology-term for this feature.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
-
Constructor Details
-
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 Details
-
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 interfaceFeature
- Returns:
- a new Template that would make a feature like this one
-
getAnnotation
Should return the associated annotation object.- Specified by:
getAnnotation
in interfaceAnnotatable
- Returns:
- an Annotation object, never null
-
getRichAnnotation
Return the associated annotation object.- Specified by:
getRichAnnotation
in interfaceRichAnnotatable
- Returns:
- a RichAnnotation object, never null
-
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 interfaceRichAnnotatable
- Returns:
- set a set of Note objects.
- See Also:
-
setNoteSet
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 interfaceRichAnnotatable
- 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:
-
setName
Sets the name of this feature.- Specified by:
setName
in interfaceRichFeature
- Parameters:
name
- the name the feature should identify itself with.- Throws:
ChangeVetoException
- if the new value is unacceptable.
-
getName
Returns the name of this feature.- Specified by:
getName
in interfaceRichFeature
- Returns:
- the name.
-
setRank
Sets the rank of this feature.- Specified by:
setRank
in interfaceRichFeature
- Parameters:
rank
- the rank the feature should identify itself with.- Throws:
ChangeVetoException
- if the new value is unacceptable.
-
getRank
Returns the rank of this feature.- Specified by:
getRank
in interfaceRichFeature
- Returns:
- the rank.
-
getSequence
Return theSequence
object to which this feature is (ultimately) attached. For top level features, this will be equal to theFeatureHolder
returned bygetParent
.- Specified by:
getSequence
in interfaceFeature
- Returns:
- the ultimate parent Sequence
-
getSource
The source of the feature. This may be a program or process. -
setSource
Change the source of the Feature.- Specified by:
setSource
in interfaceFeature
- Parameters:
source
- the new source String- Throws:
ChangeVetoException
- if the source can't be altered
-
getSourceTerm
An ontology term defining the source of this feature. This is optional, and will default toOntoTools.ANY
in implementations which aren't ontology aware.- Specified by:
getSourceTerm
in interfaceFeature
-
setSourceTerm
Set the source ontology-term for this feature. If this succeeds, it will generally also change the source name.- Specified by:
setSourceTerm
in interfaceFeature
- Throws:
ChangeVetoException
- if changes are not allowedInvalidTermException
- if the specified term is not an acceptable type for this feature.
-
getType
The type of the feature. -
setType
Change the type of this feature.- Specified by:
setType
in interfaceFeature
- Parameters:
type
- new type String- Throws:
ChangeVetoException
- if the type can't be altered
-
getTypeTerm
An ontology term defining the type of feature. This is optional, and will default toOntoTools.ANY
in implementations which aren't ontology aware.- Specified by:
getTypeTerm
in interfaceFeature
-
setTypeTerm
Set the type ontology-term for this feature. If this succeeds, it will generally also change the source name.- Specified by:
setTypeTerm
in interfaceFeature
- Throws:
ChangeVetoException
- if changes are not allowedInvalidTermException
- if the specified term is not an acceptable type for this feature.
-
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 is on the negative strand then the SymbolList will be reverse-complemented as appropriate.
- Specified by:
getSymbols
in interfaceFeature
- Specified by:
getSymbols
in interfaceStrandedFeature
- Returns:
- a SymbolList containing each symbol of the parent sequence contained within this feature in the order they appear in the parent
-
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 interfaceFeature
- Returns:
- a Location anchoring this feature
-
setLocation
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 interfaceFeature
- Parameters:
loc
- the new Location for this feature- Throws:
ChangeVetoException
- if the location can't be altered
-
getParent
Return theFeatureHolder
to which this feature has been attached. This will be aSequence
object for top level features, and aFeature
object for features further down the tree. -
setParent
Sets the parent of this feature.- Specified by:
setParent
in interfaceRichFeature
- Parameters:
parent
- the parent the feature should identify itself with.- Throws:
ChangeVetoException
- if the new value is unacceptable.
-
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 interfaceRankedCrossRefable
- Returns:
- a set of RankedCrossRef objects.
-
setRankedCrossRefs
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 interfaceRankedCrossRefable
- Parameters:
crossrefs
- a set of RankedCrossRef objects.- Throws:
ChangeVetoException
- if the set was null or any of its contents were not RankedCrossRef objects.
-
addRankedCrossRef
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 interfaceRankedCrossRefable
- Parameters:
crossref
- the ranked cross reference to add.- Throws:
ChangeVetoException
- if the parameter is null.
-
removeRankedCrossRef
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 interfaceRankedCrossRefable
- Parameters:
crossref
- the ranked cross reference to remove.- Throws:
ChangeVetoException
- if the parameter is null.
-
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 interfaceRichFeatureRelationshipHolder
- Returns:
- a set of RichFeatureRelationship objects.
-
setFeatureRelationshipSet
public void setFeatureRelationshipSet(Set<RichFeatureRelationship> relationships) throws ChangeVetoException Clears the relations from this feature 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 interfaceRichFeatureRelationshipHolder
- 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
Adds a relationship to this feature holder.- Specified by:
addFeatureRelationship
in interfaceRichFeatureRelationshipHolder
- 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 interfaceRichFeatureRelationshipHolder
- Parameters:
relationship
- the relationship to remove.- Throws:
ChangeVetoException
- if it cannot be removed.
-
containsFeature
Check if the feature is present in this holder.- Specified by:
containsFeature
in interfaceFeatureHolder
- Parameters:
f
- the Feature to check- Returns:
- true if f is in this set
-
countFeatures
Count how many features are contained.- Specified by:
countFeatures
in interfaceFeatureHolder
- Returns:
- a positive integer or zero, equal to the number of features contained
-
createFeature
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 interfaceFeatureHolder
- Throws:
BioException
- if something went wrong during creating the featureChangeVetoException
- if this FeatureHolder does not support creation of new features, or if the change was vetoed
-
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 interfaceFeature
- Specified by:
features
in interfaceFeatureHolder
- Returns:
- an Iterator
-
filter
Query this set of features using a suppliedFeatureFilter
.- Specified by:
filter
in interfaceFeatureHolder
- Parameters:
filter
- theFeatureFilter
to apply.- Returns:
- all features in this container which match
filter
.
-
filter
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 interfaceFeatureHolder
- Parameters:
fc
- the FeatureFilter to applyrecurse
- 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
Return a schema-filter for thisFeatureHolder
. This is a filter which allFeature
s immediately contained by thisFeatureHolder
will match. It need not directly match their child features, but it can (and should!) provide information about them usingFeatureFilter.OnlyChildren
filters. In cases where there is no feature hierarchy, this can be indicated by includingFeatureFilter.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, returnFeatureFilter.top_level
.Feature
objects should, as a minimum, returnFeatureFilter.ByParent(new FeatureFilter.ByFeature(this))
.- Specified by:
getSchema
in interfaceFeatureHolder
- Returns:
- the schema filter
-
removeFeature
Remove a feature from this FeatureHolder.- Specified by:
removeFeature
in interfaceFeatureHolder
- Throws:
ChangeVetoException
- if this FeatureHolder does not support feature removal or if the change was vetoedBioException
- if there was an error removing the feature
-
setStrand
Set the strand that this feature lies upon.This will be one of StrandedFeature.POSITIVE or NEGATIVE. NOT IMPLEMENTED.
- Specified by:
setStrand
in interfaceStrandedFeature
- Parameters:
strand
- aStrand
.- Throws:
ChangeVetoException
- if the strand may not be changed.
-
getStrand
Retrieve the strand that this feature lies upon.This will be one of StrandedFeature.POSITIVE or NEGATIVE.
- Specified by:
getStrand
in interfaceStrandedFeature
- Returns:
- one of the Strand constants
-
hashCode
-
equals
Features are equal when they have the same rank, parent, type, and source. Features which are not instance of RichFeature are given a rank of zero. -
compareTo
Features are sorted first by rank, then parent, type, and source. If both parents are not comparable then this part of the sorting is skipped. Features which are not instance of RichFeature are given a rank of zero.- Specified by:
compareTo
in interfaceComparable
-
toString
Form: "(#rank) parent:type,source(location)" -
getId
Gets the Hibernate ID. Should be used with caution.- Returns:
- the Hibernate ID, if using Hibernate.
-
setId
Sets the Hibernate ID. Should be used with caution.- Parameters:
id
- the Hibernate ID, if using Hibernate.
-