Class FeatureTypes


  • public class FeatureTypes
    extends java.lang.Object
    Registry of known types of features.

    Historically, the type of a feature within a sequence has been represented by the class or interface of the feature, or by the type property. Different databases use different names for types, and the same name can mean different things depending on where it came from.

    This class attempts to provide a framework for registering and managing feature types. It includes the concept of a type having a FeatureFilter schema that would match all examples of that type, and a URI for that type. Groups of related types, such as all those defined in embl, can be packaged up into a single namespace. One type can refer to any number of others, indicating that they are direct parents. This lets us say things like an Ensembl exon is a specific type of the general exon type, and also an instance of the Ensembl feature type.

    All feature types are presumed to have URIs that are of the form: uri:biojava.org:types:${repository}/${type} where ${repository} is something like embl or ensembl. Feature types defined within biojava will be in the repository called "core". ${type} is the local type of the feature. This will be something like exon, or repeat. The total URI must be unique. Different repositories can (and are encouraged to) define types with the same names.

    Since:
    1.3
    Author:
    Matthew Pocock
    • Field Detail

      • URI_PREFIX

        public static final java.lang.String URI_PREFIX
        The standard prefix for all type URIs
        See Also:
        Constant Field Values
    • Constructor Detail

      • FeatureTypes

        public FeatureTypes()
    • Method Detail

      • getRepository

        public static FeatureTypes.Repository getRepository​(java.lang.String name)
                                                     throws java.util.NoSuchElementException

        Fetch a repository by name.

        Use this to find out what types a repository can provide.

        Parameters:
        name - the name of the Repository to fetch
        Returns:
        the Repository with that name
        Throws:
        java.util.NoSuchElementException - if there is no repository by that name
      • getRepositoryNames

        public static java.util.Set getRepositoryNames()
        Find the names of all known repositories.
        Returns:
        a Set of all repository names
      • addRepository

        public static void addRepository​(FeatureTypes.Repository repos)
        Add a repository to FeatureTypes.
        Parameters:
        repos - the Repository to add
      • removeRepository

        public static void removeRepository​(FeatureTypes.Repository repos)
        Remove a repository from FeaturTypes.
        Parameters:
        repos - the Repository to remove
      • getType

        public static FeatureTypes.Type getType​(java.lang.String uri)

        Get a Type by URI.

        This will attemt to resolve the URI to a type by first matching the standard prefix, then finding a repository of the right name and finally searching that with the type-name portion of the URI.

        Parameters:
        uri - the URI to resolve
        Returns:
        a Type with that URI
        Throws:
        java.util.NoSuchElementException - if the type could not be resolved
      • isSubTypeOf

        public static boolean isSubTypeOf​(FeatureTypes.Type subType,
                                          FeatureTypes.Type superType)

        Work out if one type is a sub-type of another.

        This is the transiative closure of Type.getParent(). It will return true if superType is reachable by following getParent() calls, and false otherwise.

        Parameters:
        subType - the Type of the potential sub type
        superType - the Type of the potential super type
        Returns:
        true if they are sub-super types, false otherwise