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
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 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(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(String nameClass, String name)Adds the name to this taxon in the given name class.intcompareTo(Object o)NCBITaxon objects are compared only by their NCBITaxID fields.booleancontainsName(String nameClass, String name)Tests for the presence of a name in a given class.booleanequals(Object obj)NCBITaxon objects are equal if their NCBITaxID fields match.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.IntegergetGeneticCode()Returns the genetic code of this taxon, which may be null if not known.IntegergetId()Gets the Hibernate ID.IntegergetLeftValue()Gets the left value.IntegergetMitoGeneticCode()Getter for property mitoGeneticCode.SetgetNameClasses()Returns all the name classes available for a taxon.StringgetNameHierarchy()Returns the taxonomy hierarchy of this taxon entry in the form: most specific; less specific; ...; least specific.SetgetNames(String nameClass)Returns all the names available for a taxon in a given class.protected SetgetNameSet()protected MapgetNamesMap()intgetNCBITaxID()Gets the NCBI taxon ID.StringgetNodeRank()Gets the node rank of this taxon.IntegergetParentNCBITaxID()Returns the parent NCBI taxon ID, if known.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(String nameClass, String name)Removes the name from the given name class.voidsetGeneticCode(Integer geneticCode)Sets the genetic code of this taxon, which may be null, which will unset it.voidsetId(Integer id)Sets the Hibernate ID.voidsetLeftValue(Integer leftValue)Sets the left value.voidsetMitoGeneticCode(Integer mitoGeneticCode)Sets the mitochondrial genetic code of this taxon, which may be null, which will unset it.voidsetNodeRank(String nodeRank)Setter for property nodeRank.voidsetParentNCBITaxID(Integer parent)Sets the parent NCBI taxon ID.voidsetRightValue(Integer rightValue)Sets the right value.voidsetTaxonHidden(boolean isTaxonHidden)determines whether this taxonomy level is displayed in etNameHierarchy()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(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(Object o)
NCBITaxon objects are compared only by their NCBITaxID fields.- Specified by:
compareToin interfaceComparable
-
equals
public boolean equals(Object obj)
NCBITaxon objects are equal if their NCBITaxID fields match.
-
getNameClasses
public 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 Set getNames(String nameClass) throws IllegalArgumentException
Returns all the names available for a taxon in a given class. These are Strings.- Specified by:
getNamesin 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
protected Set 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:
addNamein 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:
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:
IllegalArgumentException- if the name is null.ChangeVetoException- in case of objections.
-
containsName
public boolean containsName(String nameClass, String name) throws IllegalArgumentException
Tests 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:
IllegalArgumentException- if the name is null.
-
getNamesMap
protected final Map getNamesMap()
-
getParentNCBITaxID
public Integer getParentNCBITaxID()
Returns the parent NCBI taxon ID, if known.- Specified by:
getParentNCBITaxIDin interfaceNCBITaxon- Returns:
- Value of property parent.
-
setParentNCBITaxID
public void setParentNCBITaxID(Integer parent) throws ChangeVetoException
Sets 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 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(String nodeRank) throws ChangeVetoException
Setter for property nodeRank.- Specified by:
setNodeRankin interfaceNCBITaxon- Parameters:
nodeRank- New value of property nodeRank.- Throws:
ChangeVetoException- in case of objections.
-
getGeneticCode
public 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(Integer geneticCode) throws ChangeVetoException
Sets 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 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(Integer mitoGeneticCode) throws ChangeVetoException
Sets 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 Integer getLeftValue()
Gets the left value. May be null.- Specified by:
getLeftValuein interfaceNCBITaxon- Returns:
- Value of property leftValue.
-
setLeftValue
public void setLeftValue(Integer leftValue) throws ChangeVetoException
Sets 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 Integer getRightValue()
Gets the right value. May be null.- Specified by:
getRightValuein interfaceNCBITaxon- Returns:
- Value of property rightValue.
-
setRightValue
public void setRightValue(Integer rightValue) throws ChangeVetoException
Sets 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 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 ChangeVetoException
Description 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 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.
-
getId
public Integer getId()
Gets the Hibernate ID. Should be used with caution.- Returns:
- the Hibernate ID, if using Hibernate.
-
-