Package org.biojavax.bio.taxa
Class SimpleNCBITaxon
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojavax.bio.taxa.SimpleNCBITaxon
-
- All Implemented Interfaces:
java.lang.Comparable,Changeable,NCBITaxon
public class SimpleNCBITaxon extends AbstractChangeable implements NCBITaxon
Reference implementation of NCBITaxon.- Since:
- 1.5
- Author:
- Richard Holland, Mark Schreiber, David Scott
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Setnames-
Fields inherited from interface org.biojavax.bio.taxa.NCBITaxon
ACRONYM, COMMON, EQUIVALENT, GENETICCODE, HIDDEN, LEFTVALUE, MITOGENETICCODE, NAMES, NODERANK, PARENT, RIGHTVALUE, SCIENTIFIC, SYNONYM
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleNCBITaxon()SimpleNCBITaxon(int NCBITaxID)Creates a new instance of SimpleNCBITaxon based on the given taxon ID.SimpleNCBITaxon(java.lang.Integer NCBITaxID)Creates a new instance of SimpleNCBITaxon based on the given taxon ID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddName(java.lang.String nameClass, java.lang.String name)Adds the name to this taxon in the given name class.intcompareTo(java.lang.Object o)NCBITaxon objects are compared only by their NCBITaxID fields.booleancontainsName(java.lang.String nameClass, java.lang.String name)Tests for the presence of a name in a given class.booleanequals(java.lang.Object obj)NCBITaxon objects are equal if their NCBITaxID fields match.java.lang.StringgetDisplayName()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.java.lang.IntegergetGeneticCode()Returns the genetic code of this taxon, which may be null if not known.java.lang.IntegergetId()Gets the Hibernate ID.java.lang.IntegergetLeftValue()Gets the left value.java.lang.IntegergetMitoGeneticCode()Getter for property mitoGeneticCode.java.util.SetgetNameClasses()Returns all the name classes available for a taxon.java.lang.StringgetNameHierarchy()Returns the taxonomy hierarchy of this taxon entry in the form: most specific; less specific; ...; least specific.java.util.SetgetNames(java.lang.String nameClass)Returns all the names available for a taxon in a given class.protected java.util.SetgetNameSet()protected java.util.MapgetNamesMap()intgetNCBITaxID()Gets the NCBI taxon ID.java.lang.StringgetNodeRank()Gets the node rank of this taxon.java.lang.IntegergetParentNCBITaxID()Returns the parent NCBI taxon ID, if known.java.lang.IntegergetRightValue()Gets the right value.inthashCode()booleanisTaxonHidden()Returns the taxonomy hierarchy of this taxon entry in the form: most specific; less specific; ...; least specific.booleanremoveName(java.lang.String nameClass, java.lang.String name)Removes the name from the given name class.voidsetGeneticCode(java.lang.Integer geneticCode)Sets the genetic code of this taxon, which may be null, which will unset it.voidsetId(java.lang.Integer id)Sets the Hibernate ID.voidsetLeftValue(java.lang.Integer leftValue)Sets the left value.voidsetMitoGeneticCode(java.lang.Integer mitoGeneticCode)Sets the mitochondrial genetic code of this taxon, which may be null, which will unset it.voidsetNodeRank(java.lang.String nodeRank)Setter for property nodeRank.voidsetParentNCBITaxID(java.lang.Integer parent)Sets the parent NCBI taxon ID.voidsetRightValue(java.lang.Integer rightValue)Sets the right value.voidsetTaxonHidden(boolean isTaxonHidden)determines whether this taxonomy level is displayed in etNameHierarchy()java.lang.StringtoString()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
-
-
-
-
Constructor Detail
-
SimpleNCBITaxon
public SimpleNCBITaxon(int NCBITaxID)
Creates a new instance of SimpleNCBITaxon based on the given taxon ID.- Parameters:
NCBITaxID- the underlying taxon ID from NCBI.
-
SimpleNCBITaxon
public SimpleNCBITaxon(java.lang.Integer NCBITaxID)
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 Detail
-
compareTo
public int compareTo(java.lang.Object o)
NCBITaxon objects are compared only by their NCBITaxID fields.- Specified by:
compareToin interfacejava.lang.Comparable
-
equals
public boolean equals(java.lang.Object obj)
NCBITaxon objects are equal if their NCBITaxID fields match.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getNameClasses
public java.util.Set getNameClasses()
Returns all the name classes available for a taxon. These are Strings.- Specified by:
getNameClassesin interfaceNCBITaxon- Returns:
- a set of name classes, or the empty set if there are none.
-
getNames
public java.util.Set getNames(java.lang.String nameClass) throws java.lang.IllegalArgumentExceptionReturns all the names available for a taxon in a given class. These are Strings.
-
getNameSet
protected java.util.Set getNameSet()
-
addName
public void addName(java.lang.String nameClass, java.lang.String name) throws java.lang.IllegalArgumentException, ChangeVetoExceptionAdds the name to this taxon in the given name class. Neither can be null.- Specified by:
addNamein interfaceNCBITaxon- Parameters:
nameClass- the class to add the name in.name- the name to add.- Throws:
java.lang.IllegalArgumentException- if the name is null.ChangeVetoException- in case of objections.
-
removeName
public boolean removeName(java.lang.String nameClass, java.lang.String name) throws java.lang.IllegalArgumentException, ChangeVetoExceptionRemoves the name from the given name class. Neither can be null.- Specified by:
removeNamein 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:
java.lang.IllegalArgumentException- if the name is null.ChangeVetoException- in case of objections.
-
containsName
public boolean containsName(java.lang.String nameClass, java.lang.String name) throws java.lang.IllegalArgumentExceptionTests for the presence of a name in a given class. Neither can be null.- Specified by:
containsNamein 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:
java.lang.IllegalArgumentException- if the name is null.
-
getNamesMap
protected final java.util.Map getNamesMap()
-
getParentNCBITaxID
public java.lang.Integer getParentNCBITaxID()
Returns the parent NCBI taxon ID, if known.- Specified by:
getParentNCBITaxIDin interfaceNCBITaxon- Returns:
- Value of property parent.
-
setParentNCBITaxID
public void setParentNCBITaxID(java.lang.Integer parent) throws ChangeVetoExceptionSets the parent NCBI taxon ID. May be null if not known.- Specified by:
setParentNCBITaxIDin interfaceNCBITaxon- Parameters:
parent- New value of property parent.- Throws:
ChangeVetoException- in case of objections.
-
getNCBITaxID
public int 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:
getNCBITaxIDin interfaceNCBITaxon- Returns:
- Value of property NCBITaxID.
-
getNodeRank
public java.lang.String getNodeRank()
Gets the node rank of this taxon. May be null.- Specified by:
getNodeRankin interfaceNCBITaxon- Returns:
- Value of property nodeRank.
-
setNodeRank
public void setNodeRank(java.lang.String nodeRank) throws ChangeVetoExceptionSetter for property nodeRank.- Specified by:
setNodeRankin interfaceNCBITaxon- Parameters:
nodeRank- New value of property nodeRank.- Throws:
ChangeVetoException- in case of objections.
-
getGeneticCode
public java.lang.Integer getGeneticCode()
Returns the genetic code of this taxon, which may be null if not known.- Specified by:
getGeneticCodein interfaceNCBITaxon- Returns:
- Value of property geneticCode.
-
setGeneticCode
public void setGeneticCode(java.lang.Integer geneticCode) throws ChangeVetoExceptionSets the genetic code of this taxon, which may be null, which will unset it.- Specified by:
setGeneticCodein interfaceNCBITaxon- Parameters:
geneticCode- New value of property geneticCode.- Throws:
ChangeVetoException- in case of objections.
-
getMitoGeneticCode
public java.lang.Integer getMitoGeneticCode()
Getter for property mitoGeneticCode. Returns Persistent.NULL_INTEGER if null.- Specified by:
getMitoGeneticCodein interfaceNCBITaxon- Returns:
- Value of property mitoGeneticCode.
-
setMitoGeneticCode
public void setMitoGeneticCode(java.lang.Integer mitoGeneticCode) throws ChangeVetoExceptionSets the mitochondrial genetic code of this taxon, which may be null, which will unset it.- Specified by:
setMitoGeneticCodein interfaceNCBITaxon- Parameters:
mitoGeneticCode- New value of property mitoGeneticCode.- Throws:
ChangeVetoException- in case of objections.
-
getLeftValue
public java.lang.Integer getLeftValue()
Gets the left value. May be null.- Specified by:
getLeftValuein interfaceNCBITaxon- Returns:
- Value of property leftValue.
-
setLeftValue
public void setLeftValue(java.lang.Integer leftValue) throws ChangeVetoExceptionSets the left value. May be null.- Specified by:
setLeftValuein interfaceNCBITaxon- Parameters:
leftValue- New value of property leftValue.- Throws:
ChangeVetoException- in case of objections.
-
getRightValue
public java.lang.Integer getRightValue()
Gets the right value. May be null.- Specified by:
getRightValuein interfaceNCBITaxon- Returns:
- Value of property rightValue.
-
setRightValue
public void setRightValue(java.lang.Integer rightValue) throws ChangeVetoExceptionSets the right value. May be null.- Specified by:
setRightValuein interfaceNCBITaxon- Parameters:
rightValue- New value of property rightValue.- Throws:
ChangeVetoException- in case of objections.
-
getDisplayName
public java.lang.String 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:
getDisplayNamein interfaceNCBITaxon- Returns:
- the display name as described above.
-
isTaxonHidden
public final boolean 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:
isTaxonHiddenin interfaceNCBITaxon- Returns:
- the display name as described above.
-
setTaxonHidden
public final void setTaxonHidden(boolean isTaxonHidden) throws ChangeVetoExceptionDescription copied from interface:NCBITaxondetermines whether this taxonomy level is displayed in etNameHierarchy()- Specified by:
setTaxonHiddenin interfaceNCBITaxon- Parameters:
isTaxonHidden- - if true it is displayed- Throws:
ChangeVetoException
-
getNameHierarchy
public java.lang.String 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:
getNameHierarchyin interfaceNCBITaxon- Returns:
- the display name as described above.
-
toString
public java.lang.String toString()
Form: "taxid:[name,name...]"- Overrides:
toStringin classjava.lang.Object
-
getId
public java.lang.Integer getId()
Gets the Hibernate ID. Should be used with caution.- Returns:
- the Hibernate ID, if using Hibernate.
-
setId
public void setId(java.lang.Integer id)
Sets the Hibernate ID. Should be used with caution.- Parameters:
id- the Hibernate ID, if using Hibernate.
-
-