public class SimpleRichFeature extends AbstractChangeable implements RichFeature
RichFeature.Template, RichFeature.Tools
StrandedFeature.Strand
Feature.ByLocationComparator
FeatureHolder.EmptyFeatureHolder
Annotatable.AnnotationForwarder
CROSSREF, LOCATION, NAME, PARENT, RANK, RELATION, SOURCETERM, TYPETERM
NEGATIVE, POSITIVE, STRAND, UNKNOWN
byLocationOrder, PROPERTY_DATA_KEY, SOURCE, TYPE
EMPTY_FEATURE_HOLDER, FEATURES, SCHEMA
ANNOTATION
Modifier | Constructor and Description |
---|---|
protected |
SimpleRichFeature() |
|
SimpleRichFeature(FeatureHolder parent,
Feature.Template templ)
Creates a new instance of SimpleRichFeature based on a template.
|
Modifier and Type | Method and Description |
---|---|
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 first by rank, then parent, type, and source.
|
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 rank, parent, type, and source.
|
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<RichFeatureRelationship> |
getFeatureRelationshipSet()
Returns the set of relationships held in this feature holder.
|
Integer |
getId()
Gets the Hibernate ID.
|
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.
|
FeatureHolder |
getParent()
Return the
FeatureHolder to which this feature has been
attached. |
int |
getRank()
Returns the rank of this feature.
|
Set<RankedCrossRef> |
getRankedCrossRefs()
Returns the set of all ranked cross references associated with an object.
|
RichAnnotation |
getRichAnnotation()
Return the associated annotation object.
|
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<RichFeatureRelationship> relationships)
Clears the relations from this feature holder and replaces them with a new set.
|
void |
setId(Integer id)
Sets the Hibernate ID.
|
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.
|
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 |
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.
|
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)"
|
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
public SimpleRichFeature(FeatureHolder parent, Feature.Template templ) throws ChangeVetoException, InvalidTermException
parent
- The parent feature holder.templ
- The template to construct the feature from.ChangeVetoException
- if we don't want to be like the template.InvalidTermException
- if any of the template terms are bad.protected SimpleRichFeature()
public Feature.Template makeTemplate()
makeTemplate
in interface Feature
public Annotation getAnnotation()
getAnnotation
in interface Annotatable
public RichAnnotation getRichAnnotation()
getRichAnnotation
in interface RichAnnotatable
public Set getNoteSet()
getNoteSet
in interface RichAnnotatable
Note
public void setNoteSet(Set notes) throws ChangeVetoException
setNoteSet
in interface RichAnnotatable
notes
- the set of Note objects to replace the existing ones with.ChangeVetoException
- if the set is null or contains any objects
that are not Note objects.Note
public void setName(String name) throws ChangeVetoException
setName
in interface RichFeature
name
- the name the feature should identify itself with.ChangeVetoException
- if the new value is unacceptable.public String getName()
getName
in interface RichFeature
public void setRank(int rank) throws ChangeVetoException
setRank
in interface RichFeature
rank
- the rank the feature should identify itself with.ChangeVetoException
- if the new value is unacceptable.public int getRank()
getRank
in interface RichFeature
public Sequence getSequence()
Sequence
object to which this feature
is (ultimately) attached. For top level features, this will be
equal to the FeatureHolder
returned by
getParent
.getSequence
in interface Feature
public void setSource(String source) throws ChangeVetoException
setSource
in interface Feature
source
- the new source StringChangeVetoException
- if the source can't be alteredpublic Term getSourceTerm()
OntoTools.ANY
in implementations which aren't ontology aware.getSourceTerm
in interface Feature
public void setSourceTerm(Term t) throws ChangeVetoException, InvalidTermException
setSourceTerm
in interface Feature
ChangeVetoException
- if changes are not allowedInvalidTermException
- if the specified term is not an acceptable type
for this feature.public void setType(String type) throws ChangeVetoException
setType
in interface Feature
type
- new type StringChangeVetoException
- if the type can't be alteredpublic Term getTypeTerm()
OntoTools.ANY
in implementations which aren't ontology aware.getTypeTerm
in interface Feature
public void setTypeTerm(Term t) throws ChangeVetoException, InvalidTermException
setTypeTerm
in interface Feature
ChangeVetoException
- if changes are not allowedInvalidTermException
- if the specified term is not an acceptable type
for this feature.public SymbolList getSymbols()
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.
getSymbols
in interface Feature
getSymbols
in interface StrandedFeature
public Location getLocation()
The location may be complicated, or simply a range. The annotation is assumed to apply to all the region contained within the location.
getLocation
in interface Feature
public void setLocation(Location loc) throws ChangeVetoException
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.
setLocation
in interface Feature
loc
- the new Location for this featureChangeVetoException
- if the location can't be alteredpublic FeatureHolder getParent()
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.public void setParent(FeatureHolder parent) throws ChangeVetoException
setParent
in interface RichFeature
parent
- the parent the feature should identify itself with.ChangeVetoException
- if the new value is unacceptable.public Set<RankedCrossRef> getRankedCrossRefs()
getRankedCrossRefs
in interface RankedCrossRefable
public void setRankedCrossRefs(Set crossrefs) throws ChangeVetoException
setRankedCrossRefs
in interface RankedCrossRefable
crossrefs
- a set of RankedCrossRef objects.ChangeVetoException
- if the set was null or any of its contents
were not RankedCrossRef objects.public void addRankedCrossRef(RankedCrossRef crossref) throws ChangeVetoException
addRankedCrossRef
in interface RankedCrossRefable
crossref
- the ranked cross reference to add.ChangeVetoException
- if the parameter is null.public void removeRankedCrossRef(RankedCrossRef crossref) throws ChangeVetoException
removeRankedCrossRef
in interface RankedCrossRefable
crossref
- the ranked cross reference to remove.ChangeVetoException
- if the parameter is null.public Set<RichFeatureRelationship> getFeatureRelationshipSet()
getFeatureRelationshipSet
in interface RichFeatureRelationshipHolder
public void setFeatureRelationshipSet(Set<RichFeatureRelationship> relationships) throws ChangeVetoException
setFeatureRelationshipSet
in interface RichFeatureRelationshipHolder
relationships
- the new set of features this holder should have. The set must
contain only RichFeatureRelationship objects.ChangeVetoException
- if the new set could not be installed.public void addFeatureRelationship(RichFeatureRelationship relationship) throws ChangeVetoException
addFeatureRelationship
in interface RichFeatureRelationshipHolder
relationship
- the relationship to add.ChangeVetoException
- if the relationship is unacceptable.public void removeFeatureRelationship(RichFeatureRelationship relationship) throws ChangeVetoException
removeFeatureRelationship
in interface RichFeatureRelationshipHolder
relationship
- the relationship to remove.ChangeVetoException
- if it cannot be removed.public boolean containsFeature(Feature f)
containsFeature
in interface FeatureHolder
f
- the Feature to checkpublic int countFeatures()
countFeatures
in interface FeatureHolder
public Feature createFeature(Feature.Template ft) throws BioException, ChangeVetoException
createFeature
in interface FeatureHolder
BioException
- if something went wrong during creating the featureChangeVetoException
- if this FeatureHolder does not support
creation of new features, or if the change was vetoedpublic Iterator features()
features
in interface Feature
features
in interface FeatureHolder
public FeatureHolder filter(FeatureFilter filter)
FeatureFilter
.filter
in interface FeatureHolder
filter
- the FeatureFilter
to apply.filter
.public FeatureHolder filter(FeatureFilter fc, boolean recurse)
filter
in interface FeatureHolder
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.public FeatureFilter getSchema()
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))
.
getSchema
in interface FeatureHolder
public void removeFeature(Feature f) throws ChangeVetoException, BioException
removeFeature
in interface FeatureHolder
ChangeVetoException
- if this FeatureHolder does not support
feature removal or if the change was vetoedBioException
- if there was an error removing the featurepublic void setStrand(StrandedFeature.Strand strand) throws ChangeVetoException
This will be one of StrandedFeature.POSITIVE or NEGATIVE. NOT IMPLEMENTED.
setStrand
in interface StrandedFeature
strand
- a Strand
.ChangeVetoException
- if the strand may not be
changed.public StrandedFeature.Strand getStrand()
This will be one of StrandedFeature.POSITIVE or NEGATIVE.
getStrand
in interface StrandedFeature
public boolean equals(Object o)
public int compareTo(Object o)
compareTo
in interface Comparable
public Integer getId()
Copyright © 2014 BioJava. All rights reserved.