All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.bio.taxonomy.ncbi.NCBIGenBankDivision Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.bio.taxonomy.ncbi;

import com.hfg.bio.taxonomy.SeqRepositoryDivision;
import com.hfg.util.StringUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.Collection;
import java.io.Serializable;


//------------------------------------------------------------------------------
/**
 * Enumerated list of NCBI GenBank divisions.
 * 
* Based on division.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 NCBIGenBankDivision implements SeqRepositoryDivision, Serializable { //************************************************************************** // PRIVATE FIELDS //************************************************************************** private String mName; private String mCode; private Integer mId; private static Map sUniqueIdMap = new HashMap<>(20); private static Map sUniqueCodeMap = new HashMap<>(20); //************************************************************************** // PUBLIC FIELDS //************************************************************************** /** Bacteria BCT 0 */ public static NCBIGenBankDivision BACTERIA = new NCBIGenBankDivision("Bacteria", "BCT", 0); /** Invertebrates INV 1 */ public static NCBIGenBankDivision INVERTEBRATES = new NCBIGenBankDivision("Invertebrates", "INV", 1); /** Mammals MAM 2 */ public static NCBIGenBankDivision MAMMALS = new NCBIGenBankDivision("Mammals", "MAM", 2); /** Phages PHG 3 */ public static NCBIGenBankDivision PHAGES = new NCBIGenBankDivision("Phages", "PHG", 3); /** Plants PLN 4 */ public static NCBIGenBankDivision PLANTS = new NCBIGenBankDivision("Plants", "PLN", 4); /** Primates PRI 5 */ public static NCBIGenBankDivision PRIMATES = new NCBIGenBankDivision("Primates", "PRI", 5); /** Rodents ROD 6 */ public static NCBIGenBankDivision RODENTS = new NCBIGenBankDivision("Rodents", "ROD", 6); /** Synthetic SYN 7 */ public static NCBIGenBankDivision SYNTHETIC = new NCBIGenBankDivision("Synthetic", "SYN", 7); /** Unassigned UNA 8 (No species nodes should inherit this division assignment) */ public static NCBIGenBankDivision UNASSIGNED = new NCBIGenBankDivision("Unassigned", "UNA", 8); /** Viruses VRL 9 */ public static NCBIGenBankDivision VIRUSES = new NCBIGenBankDivision("Viruses", "VRL", 9); /** Vertebrates VRT 10 */ public static NCBIGenBankDivision VERTEBRATES = new NCBIGenBankDivision("Vertebrates", "VRT", 10); /** Environmental samples ENV 11 (Anonymous sequences cloned directly from the environment) */ public static NCBIGenBankDivision ENVIRONMENTAL_SAMPLES = new NCBIGenBankDivision("Environmental samples", "ENV", 11); // Functional divisions /** Constructed sequences */ public static NCBIGenBankDivision CONSTRUCTED = new NCBIGenBankDivision("Constructed", "CON"); /** EST sequences (Expressed Sequence Tags) */ public static NCBIGenBankDivision EST = new NCBIGenBankDivision("EST", "EST"); /** Patent sequences */ public static NCBIGenBankDivision PATENT = new NCBIGenBankDivision("Patent", "PAT"); /** STS sequences (Sequence Tagged Sites) */ public static NCBIGenBankDivision STS = new NCBIGenBankDivision("STS", "STS"); /** GSS sequences (Genome Survey Sequences) */ public static NCBIGenBankDivision GSS = new NCBIGenBankDivision("GSS", "GSS"); /** HTGS sequences (High Throughput Genomic sequences) */ public static NCBIGenBankDivision HTG = new NCBIGenBankDivision("HTG", "HTG"); /** HTC sequences (High Throughput cDNA sequences) */ public static NCBIGenBankDivision HTC = new NCBIGenBankDivision("HTC", "HTC"); /** Transcriptome Shotgun Assembly sequences */ public static NCBIGenBankDivision TSA = new NCBIGenBankDivision("TSA", "TSA"); //************************************************************************** // CONSTRUCTORS //************************************************************************** //-------------------------------------------------------------------------- private NCBIGenBankDivision(String inName, String inCode, int inId) { this(inName, inCode); mId = inId; if (sUniqueIdMap.containsKey(mId + "")) { throw new RuntimeException("A object already exists with the id '" + mId + "'!"); } sUniqueIdMap.put(mId + "", this); } //-------------------------------------------------------------------------- private NCBIGenBankDivision(String inName, String inCode) { mName = inName; mCode = inCode; if (sUniqueCodeMap.containsKey(mCode)) { throw new RuntimeException("A object already exists with the code '" + mCode + "'!"); } sUniqueCodeMap.put(mCode, this); } //************************************************************************** // PUBLIC METHODS //************************************************************************** //-------------------------------------------------------------------------- public static Collection values() { return sUniqueCodeMap.values(); } //-------------------------------------------------------------------------- /** Returns the corresponding NCBIGenBankDivision by comparing the id to the id values of the enumerated set. @param inId the id of the GenBank division to retrieve @return NCBIGenBankDivsion object corresponding to the specified id */ public static NCBIGenBankDivision valueOf(int inId) { return sUniqueIdMap.get(inId + ""); } //-------------------------------------------------------------------------- /** Returns the corresponding NCBIGenBankDivision by comparing the value to the name, code, and id values of the enumerated set. @param inValue the name, code, or id of the GenBank division to retrieve @return NCBIGenBankDivsion object corresponding to the specified value */ public static NCBIGenBankDivision valueOf(String inValue) { NCBIGenBankDivision value = null; if (StringUtil.isSet(inValue)) { for (NCBIGenBankDivision division : sUniqueCodeMap.values()) { if (division.name().equalsIgnoreCase(inValue) || division.getCode().equalsIgnoreCase(inValue) || (division.getId() != null && (division.getId() + "").equals(inValue))) { value = division; break; } } } return value; } //-------------------------------------------------------------------------- public String name() { return mName; } //-------------------------------------------------------------------------- /** The same as name(). */ @Override public String toString() { return name(); } //-------------------------------------------------------------------------- /** Returns the 3-letter GenBank division code. @return the 3-letter GenBank division code */ public String getCode() { return mCode; } //-------------------------------------------------------------------------- public Integer getId() { return mId; } //************************************************************************** // 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 sUniqueIdMap.get(mId + ""); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy