Interface Feature
- All Superinterfaces:
Annotatable,Changeable,FeatureHolder
- All Known Subinterfaces:
ComponentFeature,FramedFeature,HomologyFeature,RemoteFeature,RestrictionSite,RichFeature,SimilarityPairFeature,StrandedFeature
- All Known Implementing Classes:
ProjectedFeature,SimpleFeature,SimpleFramedFeature,SimpleHomologyFeature,SimpleRemoteFeature,SimpleRestrictionSite,SimpleRichFeature,SimpleSimilarityPairFeature,SimpleStrandedFeature
Common operations
// loop over all features in a sequence
for(Iterator fi = mySeq.features(); fi.hasNext(); ) {
Feature f = (Feature) fi.next();
System.out.println(f.getType() + "\t" + f.getLocation());
}
// loop over all features that are children of this one, such as exons in a
// gene
for(Iterator cfi = feature.features(); cfi.hasNext(); ) {
...
// extract all stranded features that are directly on a sequence
FeatureHolder strandedFeatures = mySeq.filter(
new FeatureFilter.ByClass(StrandedFeature.class),
false
);
for(fi = strandedFeatures.features(); ...
// find all features with the type property set to "EXON" no matter how
// far down the feature hierachy they are
FeatureHolder repeats = mySeq.filter(
new FeatureFilter.ByType("EXON"),
true;
);
Description
Features contain annotation and a location. The type of the feature is something like 'Repeat' or 'BetaStrand'. Where the feature has been read from an EMBL or Genbank source the type will be the same as the feature key in the feature table e.g. 'gene', 'CDS', 'repeat_unit', 'misc_feature'. The source of the feature is something like 'genscan', 'repeatmasker' or 'made-up'.
Features are always contained by a parent FeatureHolder,
which may either be a Sequence or another Feature.
Feature instances should never be constructed directly by client
code, and the BioJava core does not contain any publicly accessible
implementations of the Feature interface. Instead, you
should create a suitable Feature.Template, then pass this
to the createFeature method of a Sequence
or Feature.
We may need some standardisation for what the fields mean. In particular, we should be compliant where sensible with GFF.
- Author:
- Matthew Pocock, Thomas Down, Keith James
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classByLocationComparatorcomparesFeatures by the minimum base position of theirLocation.static classTemplate class for a plain feature.Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarderNested classes/interfaces inherited from interface org.biojava.bio.seq.FeatureHolder
FeatureHolder.EmptyFeatureHolder -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Feature.ByLocationComparatorbyLocationOrdercontains aFeaturecomparator which compares by the minimum base position of theirLocation.static final ChangeTypeThe location of this feature is being altered.static final StringThis is used as a key in theAnnotationwhere it identifies internal data.static final ChangeTypeThe source of this feature has alteredstatic final ChangeTypeThe ontological source of this feature has alteredstatic final ChangeTypeThe type of this feature has altered.static final ChangeTypeThe ontological type of this feature has altered.Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATIONFields inherited from interface org.biojava.bio.seq.FeatureHolder
EMPTY_FEATURE_HOLDER, FEATURES, SCHEMA -
Method Summary
Modifier and TypeMethodDescriptionfeatures()Iterate over any child features which are held by this feature.The location of this feature.Return theFeatureHolderto which this feature has been attached.Return theSequenceobject to which this feature is (ultimately) attached.The source of the feature.An ontology term defining the source of this feature.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.Create a new Template that could be used to generate a feature identical to this one.voidsetLocation(Location loc) The new location for this feature.voidChange the source of the Feature.voidSet the source ontology-term for this feature.voidChange the type of this feature.voidsetTypeTerm(Term t) Set the type ontology-term for this feature.Methods inherited from interface org.biojava.bio.Annotatable
getAnnotationMethods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListenerMethods inherited from interface org.biojava.bio.seq.FeatureHolder
containsFeature, countFeatures, createFeature, filter, filter, getSchema, removeFeature
-
Field Details
-
PROPERTY_DATA_KEY
This is used as a key in theAnnotationwhere it identifies internal data. This is not printed when theFeatureis written to a flatfile. E.g. the original feature's EMBL location string (if it has one) is stored here.- See Also:
-
LOCATION
The location of this feature is being altered. -
TYPE
The type of this feature has altered. -
SOURCE
The source of this feature has altered -
TYPETERM
The ontological type of this feature has altered. -
SOURCETERM
The ontological source of this feature has altered -
byLocationOrder
byLocationOrdercontains aFeaturecomparator which compares by the minimum base position of theirLocation.
-
-
Method Details
-
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.
- 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.
- Parameters:
loc- the new Location for this feature- Throws:
ChangeVetoException- if the location can't be altered
-
getType
The type of the feature.- Returns:
- the type of this sequence
-
setType
Change the type of this feature.- 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.ANYin implementations which aren't ontology aware.- Since:
- 1.4
-
setTypeTerm
Set the type ontology-term for this feature. If this succeeds, it will generally also change the source name.- Throws:
ChangeVetoException- if changes are not allowedInvalidTermException- if the specified term is not an acceptable type for this feature.- Since:
- 1.4
-
getSourceTerm
An ontology term defining the source of this feature. This is optional, and will default toOntoTools.ANYin implementations which aren't ontology aware.- Since:
- 1.4
-
setSourceTerm
Set the source ontology-term for this feature. If this succeeds, it will generally also change the source name.- Throws:
ChangeVetoException- if changes are not allowedInvalidTermException- if the specified term is not an acceptable type for this feature.- Since:
- 1.4
-
getSource
The source of the feature. This may be a program or process.- Returns:
- the source, or generator
-
setSource
Change the source of the Feature.- Parameters:
source- the new source String- Throws:
ChangeVetoException- if the source can't be altered
-
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.
- Returns:
- a SymbolList containing each symbol of the parent sequence contained within this feature in the order they appear in the parent
-
getParent
Return theFeatureHolderto which this feature has been attached. This will be aSequenceobject for top level features, and aFeatureobject for features further down the tree. -
getSequence
Return theSequenceobject to which this feature is (ultimately) attached. For top level features, this will be equal to theFeatureHolderreturned bygetParent.- Returns:
- the ultimate parent Sequence
-
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:
featuresin interfaceFeatureHolder- Returns:
- an Iterator
-
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.- Returns:
- a new Template that would make a feature like this one
-