com.hfg.bio.taxonomy.NCBITaxonNodeRank Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.bio.taxonomy;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
//------------------------------------------------------------------------------
/**
* NCBI taxonomy levels.
*
* Based on values in the nodes.dmp file in ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz
*
*
* @author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class NCBITaxonNodeRank implements Comparable, Serializable
{
//**************************************************************************
// PRIVATE FIELDS
//**************************************************************************
private String mName;
private int mRank;
private static Map sUniqueMap = new HashMap<>(30);
//**************************************************************************
// PUBLIC FIELDS
//**************************************************************************
public static NCBITaxonNodeRank SUPERKINGDOM = new NCBITaxonNodeRank(30, "superkingdom");
public static NCBITaxonNodeRank KINGDOM = new NCBITaxonNodeRank(29, "kingdom");
public static NCBITaxonNodeRank SUBKINGDOM = new NCBITaxonNodeRank(28, "subkingdom");
public static NCBITaxonNodeRank SUPERPHYLUM = new NCBITaxonNodeRank(27, "superphylum");
public static NCBITaxonNodeRank PHYLUM = new NCBITaxonNodeRank(26, "phylum");
public static NCBITaxonNodeRank SUBPHYLUM = new NCBITaxonNodeRank(25, "subphylum");
public static NCBITaxonNodeRank SUPERCLASS = new NCBITaxonNodeRank(24, "superclass");
public static NCBITaxonNodeRank CLASS = new NCBITaxonNodeRank(23, "class");
public static NCBITaxonNodeRank SUBCLASS = new NCBITaxonNodeRank(22, "subclass");
public static NCBITaxonNodeRank INFRACLASS = new NCBITaxonNodeRank(21, "infraclass");
public static NCBITaxonNodeRank COHORT = new NCBITaxonNodeRank(20, "cohort");
public static NCBITaxonNodeRank SUPERORDER = new NCBITaxonNodeRank(19, "superorder");
public static NCBITaxonNodeRank ORDER = new NCBITaxonNodeRank(18, "order");
public static NCBITaxonNodeRank SUBORDER = new NCBITaxonNodeRank(17, "suborder");
public static NCBITaxonNodeRank PARVORDER = new NCBITaxonNodeRank(16, "parvorder");
public static NCBITaxonNodeRank INFRAORDER = new NCBITaxonNodeRank(15, "infraorder");
public static NCBITaxonNodeRank SUPERFAMILY = new NCBITaxonNodeRank(14, "superfamily");
public static NCBITaxonNodeRank FAMILY = new NCBITaxonNodeRank(13, "family");
public static NCBITaxonNodeRank SUBFAMILY = new NCBITaxonNodeRank(12, "subfamily");
public static NCBITaxonNodeRank TRIBE = new NCBITaxonNodeRank(11, "tribe");
public static NCBITaxonNodeRank SUBTRIBE = new NCBITaxonNodeRank(10, "subtribe");
public static NCBITaxonNodeRank GENUS = new NCBITaxonNodeRank( 9, "genus");
public static NCBITaxonNodeRank SUBGENUS = new NCBITaxonNodeRank( 8, "subgenus");
public static NCBITaxonNodeRank SPECIES_GROUP = new NCBITaxonNodeRank( 7, "species group");
public static NCBITaxonNodeRank SPECIES_SUBGROUP = new NCBITaxonNodeRank(6, "species subgroup");
public static NCBITaxonNodeRank SPECIES = new NCBITaxonNodeRank( 5, "species");
public static NCBITaxonNodeRank SUBSPECIES = new NCBITaxonNodeRank( 4, "subspecies");
public static NCBITaxonNodeRank VARIETAS = new NCBITaxonNodeRank( 3, "varietas");
public static NCBITaxonNodeRank FORMA = new NCBITaxonNodeRank( 2, "forma");
public static NCBITaxonNodeRank NO_RANK = new NCBITaxonNodeRank( 0, "no rank");
//**************************************************************************
// CONSTRUCTORS
//**************************************************************************
//--------------------------------------------------------------------------
private NCBITaxonNodeRank(int inRank, String inName)
{
mRank = inRank;
mName = inName;
if (sUniqueMap.containsKey(mName))
{
throw new RuntimeException("A object already exists with the name '" + mName + "'!");
}
sUniqueMap.put(mName, this);
}
//**************************************************************************
// PUBLIC METHODS
//**************************************************************************
//--------------------------------------------------------------------------
public static Collection values()
{
return sUniqueMap.values();
}
//--------------------------------------------------------------------------
public static NCBITaxonNodeRank valueOf(String inValue)
{
return sUniqueMap.get(inValue);
}
//--------------------------------------------------------------------------
public int compareTo(NCBITaxonNodeRank inObj)
{
return inObj != null ? mRank - inObj.mRank : 1;
}
//--------------------------------------------------------------------------
public String name()
{
return mName;
}
//--------------------------------------------------------------------------
/**
The same as name().
*/
@Override
public String toString()
{
return name();
}
//**************************************************************************
// PRIVATE METHODS
//**************************************************************************
//--------------------------------------------------------------------------
/**
* This method is called after de-serialization, allowing the object
* to nominate a replacement object to be used in the output
* graph instead of this object. We don't want multiple objects of each type
* to exist in a target VM, so instances replace themselves with
* local objects.
*/
private Object readResolve()
{
return sUniqueMap.get(mName);
}
}