public class FeatureTypes extends Object
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.
Modifier and Type | Class and Description |
---|---|
static interface |
FeatureTypes.Repository
A named collection of Types.
|
static class |
FeatureTypes.RepositoryImpl
A simple implementation of a Repository.
|
static interface |
FeatureTypes.Type
A type of feature.
|
Modifier and Type | Field and Description |
---|---|
static String |
URI_PREFIX
The standard prefix for all type URIs
|
Constructor and Description |
---|
FeatureTypes() |
Modifier and Type | Method and Description |
---|---|
static void |
addRepository(FeatureTypes.Repository repos)
Add a repository to FeatureTypes.
|
static FeatureTypes.Repository |
getRepository(String name)
Fetch a repository by name.
|
static Set |
getRepositoryNames()
Find the names of all known repositories.
|
static FeatureTypes.Type |
getType(String uri)
Get a Type by URI.
|
static boolean |
isSubTypeOf(FeatureTypes.Type subType,
FeatureTypes.Type superType)
Work out if one type is a sub-type of another.
|
static void |
removeRepository(FeatureTypes.Repository repos)
Remove a repository from FeaturTypes.
|
public static final String URI_PREFIX
public FeatureTypes()
public static FeatureTypes.Repository getRepository(String name) throws NoSuchElementException
Fetch a repository by name.
Use this to find out what types a repository can provide.
name
- the name of the Repository to fetchNoSuchElementException
- if there is no repository by that namepublic static Set getRepositoryNames()
public static void addRepository(FeatureTypes.Repository repos)
repos
- the Repository to addpublic static void removeRepository(FeatureTypes.Repository repos)
repos
- the Repository to removepublic static FeatureTypes.Type getType(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.
uri
- the URI to resolveNoSuchElementException
- if the type could not be resolvedpublic 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.
subType
- the Type of the potential sub typesuperType
- the Type of the potential super typeCopyright © 2014 BioJava. All rights reserved.