Package org.biojavax.bio.taxa
Class SimpleNCBITaxon
java.lang.Object
org.biojava.utils.AbstractChangeable
org.biojavax.bio.taxa.SimpleNCBITaxon
- All Implemented Interfaces:
Comparable
,Changeable
,NCBITaxon
Reference implementation of NCBITaxon.
- Since:
- 1.5
- Author:
- Richard Holland, Mark Schreiber, David Scott
-
Field Summary
FieldsFields inherited from interface org.biojavax.bio.taxa.NCBITaxon
ACRONYM, COMMON, EQUIVALENT, GENETICCODE, HIDDEN, LEFTVALUE, MITOGENETICCODE, NAMES, NODERANK, PARENT, RIGHTVALUE, SCIENTIFIC, SYNONYM
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SimpleNCBITaxon
(int NCBITaxID) Creates a new instance of SimpleNCBITaxon based on the given taxon ID.SimpleNCBITaxon
(Integer NCBITaxID) Creates a new instance of SimpleNCBITaxon based on the given taxon ID. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the name to this taxon in the given name class.int
NCBITaxon objects are compared only by their NCBITaxID fields.boolean
containsName
(String nameClass, String name) Tests for the presence of a name in a given class.boolean
NCBITaxon objects are equal if their NCBITaxID fields match.Returns the name of this taxon entry in the form: scientific (common) or if there is no common name: scientific or if there are no scientific names at all, the empty string.Returns the genetic code of this taxon, which may be null if not known.getId()
Gets the Hibernate ID.Gets the left value.Getter for property mitoGeneticCode.Returns all the name classes available for a taxon.Returns the taxonomy hierarchy of this taxon entry in the form: most specific; less specific; ...; least specific.Returns all the names available for a taxon in a given class.protected Set
protected final Map
int
Gets the NCBI taxon ID.Gets the node rank of this taxon.Returns the parent NCBI taxon ID, if known.Gets the right value.int
hashCode()
final boolean
Returns the taxonomy hierarchy of this taxon entry in the form: most specific; less specific; ...; least specific.boolean
removeName
(String nameClass, String name) Removes the name from the given name class.void
setGeneticCode
(Integer geneticCode) Sets the genetic code of this taxon, which may be null, which will unset it.void
Sets the Hibernate ID.void
setLeftValue
(Integer leftValue) Sets the left value.void
setMitoGeneticCode
(Integer mitoGeneticCode) Sets the mitochondrial genetic code of this taxon, which may be null, which will unset it.void
setNodeRank
(String nodeRank) Setter for property nodeRank.void
setParentNCBITaxID
(Integer parent) Sets the parent NCBI taxon ID.void
setRightValue
(Integer rightValue) Sets the right value.final void
setTaxonHidden
(boolean isTaxonHidden) determines whether this taxonomy level is displayed in etNameHierarchy()toString()
Form: "taxid:[name,name...]"Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
Field Details
-
names
-
-
Constructor Details
-
SimpleNCBITaxon
Creates a new instance of SimpleNCBITaxon based on the given taxon ID.- Parameters:
NCBITaxID
- the underlying taxon ID from NCBI.
-
SimpleNCBITaxon
Creates a new instance of SimpleNCBITaxon based on the given taxon ID. It may not be null, else you'll get exceptions.- Parameters:
NCBITaxID
- the underlying taxon ID from NCBI.
-
SimpleNCBITaxon
protected SimpleNCBITaxon()
-
-
Method Details
-
compareTo
NCBITaxon objects are compared only by their NCBITaxID fields.- Specified by:
compareTo
in interfaceComparable
-
equals
NCBITaxon objects are equal if their NCBITaxID fields match. -
hashCode
-
getNameClasses
Returns all the name classes available for a taxon. These are Strings.- Specified by:
getNameClasses
in interfaceNCBITaxon
- Returns:
- a set of name classes, or the empty set if there are none.
-
getNames
Returns all the names available for a taxon in a given class. These are Strings.- Specified by:
getNames
in interfaceNCBITaxon
- Parameters:
nameClass
- the name class to retrieve names from.- Returns:
- a set of names, or the empty set if there are none.
- Throws:
IllegalArgumentException
- if the name is null.
-
getNameSet
-
addName
public void addName(String nameClass, String name) throws IllegalArgumentException, ChangeVetoException Adds the name to this taxon in the given name class. Neither can be null.- Specified by:
addName
in interfaceNCBITaxon
- Parameters:
nameClass
- the class to add the name in.name
- the name to add.- Throws:
IllegalArgumentException
- if the name is null.ChangeVetoException
- in case of objections.
-
removeName
public boolean removeName(String nameClass, String name) throws IllegalArgumentException, ChangeVetoException Removes the name from the given name class. Neither can be null.- Specified by:
removeName
in interfaceNCBITaxon
- Parameters:
nameClass
- the class to remove the name from.name
- the name to remove.- Returns:
- True if the name was found and removed, false otherwise.
- Throws:
IllegalArgumentException
- if the name is null.ChangeVetoException
- in case of objections.
-
containsName
Tests for the presence of a name in a given class. Neither can be null.- Specified by:
containsName
in interfaceNCBITaxon
- Parameters:
nameClass
- the class to look the name up in.name
- the name to text for existence of.- Returns:
- True if the name exists in that class, false otherwise.
- Throws:
IllegalArgumentException
- if the name is null.
-
getNamesMap
-
getParentNCBITaxID
Returns the parent NCBI taxon ID, if known.- Specified by:
getParentNCBITaxID
in interfaceNCBITaxon
- Returns:
- Value of property parent.
-
setParentNCBITaxID
Sets the parent NCBI taxon ID. May be null if not known.- Specified by:
setParentNCBITaxID
in interfaceNCBITaxon
- Parameters:
parent
- New value of property parent.- Throws:
ChangeVetoException
- in case of objections.
-
getNCBITaxID
Gets the NCBI taxon ID. This is never null and is immutable, as otherwise we would have no way of distinguishing between various taxa. It should be set by the constructor of an implementation.- Specified by:
getNCBITaxID
in interfaceNCBITaxon
- Returns:
- Value of property NCBITaxID.
-
getNodeRank
Gets the node rank of this taxon. May be null.- Specified by:
getNodeRank
in interfaceNCBITaxon
- Returns:
- Value of property nodeRank.
-
setNodeRank
Setter for property nodeRank.- Specified by:
setNodeRank
in interfaceNCBITaxon
- Parameters:
nodeRank
- New value of property nodeRank.- Throws:
ChangeVetoException
- in case of objections.
-
getGeneticCode
Returns the genetic code of this taxon, which may be null if not known.- Specified by:
getGeneticCode
in interfaceNCBITaxon
- Returns:
- Value of property geneticCode.
-
setGeneticCode
Sets the genetic code of this taxon, which may be null, which will unset it.- Specified by:
setGeneticCode
in interfaceNCBITaxon
- Parameters:
geneticCode
- New value of property geneticCode.- Throws:
ChangeVetoException
- in case of objections.
-
getMitoGeneticCode
Getter for property mitoGeneticCode. Returns Persistent.NULL_INTEGER if null.- Specified by:
getMitoGeneticCode
in interfaceNCBITaxon
- Returns:
- Value of property mitoGeneticCode.
-
setMitoGeneticCode
Sets the mitochondrial genetic code of this taxon, which may be null, which will unset it.- Specified by:
setMitoGeneticCode
in interfaceNCBITaxon
- Parameters:
mitoGeneticCode
- New value of property mitoGeneticCode.- Throws:
ChangeVetoException
- in case of objections.
-
getLeftValue
Gets the left value. May be null.- Specified by:
getLeftValue
in interfaceNCBITaxon
- Returns:
- Value of property leftValue.
-
setLeftValue
Sets the left value. May be null.- Specified by:
setLeftValue
in interfaceNCBITaxon
- Parameters:
leftValue
- New value of property leftValue.- Throws:
ChangeVetoException
- in case of objections.
-
getRightValue
Gets the right value. May be null.- Specified by:
getRightValue
in interfaceNCBITaxon
- Returns:
- Value of property rightValue.
-
setRightValue
Sets the right value. May be null.- Specified by:
setRightValue
in interfaceNCBITaxon
- Parameters:
rightValue
- New value of property rightValue.- Throws:
ChangeVetoException
- in case of objections.
-
getDisplayName
Returns the name of this taxon entry in the form: scientific (common) or if there is no common name: scientific or if there are no scientific names at all, the empty string.- Specified by:
getDisplayName
in interfaceNCBITaxon
- Returns:
- the display name as described above.
-
isTaxonHidden
Returns the taxonomy hierarchy of this taxon entry in the form: most specific; less specific; ...; least specific. It follows the chain up the tree as far as it can, and will stop at the first one it comes to that returns null for getParentNCBITaxID(). If this taxon entry has no scientific name, you will get the string ".".- Specified by:
isTaxonHidden
in interfaceNCBITaxon
- Returns:
- the display name as described above.
-
setTaxonHidden
Description copied from interface:NCBITaxon
determines whether this taxonomy level is displayed in etNameHierarchy()- Specified by:
setTaxonHidden
in interfaceNCBITaxon
- Parameters:
isTaxonHidden
- - if true it is displayed- Throws:
ChangeVetoException
-
getNameHierarchy
Returns the taxonomy hierarchy of this taxon entry in the form: most specific; less specific; ...; least specific. It follows the chain up the tree as far as it can, and will stop at the first one it comes to that returns null for getParentNCBITaxID(). If this taxon entry has no scientific name, you will get the string ".".- Specified by:
getNameHierarchy
in interfaceNCBITaxon
- Returns:
- the display name as described above.
-
toString
Form: "taxid:[name,name...]" -
getId
Gets the Hibernate ID. Should be used with caution.- Returns:
- the Hibernate ID, if using Hibernate.
-
setId
Sets the Hibernate ID. Should be used with caution.- Parameters:
id
- the Hibernate ID, if using Hibernate.
-