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

    public interface Feature
    extends FeatureHolder, Annotatable
    A feature within a sequence, or nested within another feature.

    Common operations

     // loop over all features in a sequence
     for(Iterator fi = mySeq.features(); fi.hasNext(); ) {
       Feature f = (Feature);
       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),
     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"),


    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.

    Matthew Pocock, Thomas Down, Keith James
    See Also:
    • Field Detail


        static final String PROPERTY_DATA_KEY
        This is used as a key in the Annotation where it identifies internal data. This is not printed when the Feature is written to a flatfile. E.g. the original feature's EMBL location string (if it has one) is stored here.
        See Also:
        Constant Field Values
      • LOCATION

        static final ChangeType LOCATION
        The location of this feature is being altered.
      • TYPE

        static final ChangeType TYPE
        The type of this feature has altered.
      • TYPETERM

        static final ChangeType TYPETERM
        The ontological type of this feature has altered.
    • Method Detail

      • getLocation

        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.

        a Location anchoring this feature
      • setLocation

        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.

        loc - the new Location for this feature
        ChangeVetoException - if the location can't be altered
      • getType

        String getType()
        The type of the feature.
        the type of this sequence
      • getTypeTerm

        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.
      • getSourceTerm

        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.
      • getSource

        String getSource()
        The source of the feature. This may be a program or process.
        the source, or generator
      • getSymbols

        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.

        a SymbolList containing each symbol of the parent sequence contained within this feature in the order they appear in the parent
      • getParent

        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.
      • getSequence

        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.
        the ultimate parent Sequence
      • features

        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 FeatureHolder
        an Iterator
      • makeTemplate

        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.
        a new Template that would make a feature like this one