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

com.hfg.bio.seq.genomic.assembly.NCBIGenomicAssemblyInfo Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.bio.seq.genomic.assembly;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hfg.bio.taxonomy.ncbi.NCBITaxon;
import com.hfg.util.BooleanUtil;
import com.hfg.util.CompareUtil;
import com.hfg.util.StringBuilderPlus;
import com.hfg.util.io.TSV;
import com.hfg.xml.HfgXML;
import com.hfg.xml.XMLName;
import com.hfg.xml.XMLTag;

//------------------------------------------------------------------------------
/**
 * Information about an NCBI genomic assembly.
 * See ftp://ftp.ncbi.nlm.nih.gov/genomes/README_assembly_summary.txt for a description of the fields.
 * 
* @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 NCBIGenomicAssemblyInfo implements Comparable { // Tag names private static final XMLName NCBI_GENOMIC_ASSEMBLY_INFO = new XMLName("NCBIGenomicAssemblyInfo", HfgXML.HFG_NAMESPACE); private static final XMLName ASSEMBLY_ACCESSION = new XMLName("AssemblyAccession", HfgXML.HFG_NAMESPACE); private static final XMLName BIOPROJECT_ACCESSION = new XMLName("BioprojectAccession", HfgXML.HFG_NAMESPACE); private static final XMLName BIOSAMPLE_ACCESSION = new XMLName("BiosampleAccession", HfgXML.HFG_NAMESPACE); private static final XMLName WGS_ACCESSION = new XMLName("WGS_Accession", HfgXML.HFG_NAMESPACE); private static final XMLName REFSEQ_CATEGORY = new XMLName("RefseqCategory", HfgXML.HFG_NAMESPACE); private static final XMLName ORGANISM_TAXON = new XMLName("OrganismTaxon", HfgXML.HFG_NAMESPACE); private static final XMLName SPECIES_TAXON = new XMLName("SpeciesTaxon", HfgXML.HFG_NAMESPACE); private static final XMLName INFRASPECIFIC_NAME = new XMLName("InfraspecificName", HfgXML.HFG_NAMESPACE); private static final XMLName ISOLATE = new XMLName("Isolate", HfgXML.HFG_NAMESPACE); private static final XMLName ASSEMBLY_VERSION_STATUS = new XMLName("AssemblyVersionStatus", HfgXML.HFG_NAMESPACE); private static final XMLName ASSEMBLY_LEVEL = new XMLName("AssemblyLevel", HfgXML.HFG_NAMESPACE); private static final XMLName ASSEMBLY_RELEASE_TYPE = new XMLName("AssemblyReleaseType", HfgXML.HFG_NAMESPACE); private static final XMLName GENOMIC_REPRESENTATION = new XMLName("GenomicRepresentation", HfgXML.HFG_NAMESPACE); private static final XMLName RELEASE_DATE = new XMLName("ReleaseDate", HfgXML.HFG_NAMESPACE); private static final XMLName ASSEMBLY_NAME = new XMLName("AssemblyName", HfgXML.HFG_NAMESPACE); private static final XMLName SUBMITTER = new XMLName("Submitter", HfgXML.HFG_NAMESPACE); private static final XMLName GENBANK_REFSEQ_PAIRED_ASSEMBLY = new XMLName("GenBankRefseqPairedAssembly", HfgXML.HFG_NAMESPACE); private static final XMLName GENOMIC_PAIRED_ASSEMBLY_COMPARISON = new XMLName("GenomicPairedAssemblyComparison", HfgXML.HFG_NAMESPACE); private static final XMLName FTP_PATH = new XMLName("FTP_Path", HfgXML.HFG_NAMESPACE); private static final XMLName EXCLUDED_FROM_REFSEQ = new XMLName("ExcludedFromRefseq", HfgXML.HFG_NAMESPACE); private static final XMLName GENOMIC_RELATION_TO_TYPE_MATERIAL = new XMLName("GenomicRelationToTypeMaterial", HfgXML.HFG_NAMESPACE); private String mAssemblyAccession; private String mBioprojectAccession; private String mBiosampleAccession; private String mWGSAccession; private GenomicRefSeqCategory mRefseqCategory; private NCBITaxon mOrganismNCBITaxon; private NCBITaxon mSpeciesNCBITaxon; // The species taxid will differ from the // organism taxid (column 6) only when the // organism was reported at a sub-species or strain level. private String mInfraspecificName; private String mIsolate; private GenomicAssemblyVersionStatus mAssemblyVersionStatus; private GenomicAssemblyLevel mAssemblyLevel; private GenomicAssemblyReleaseType mAssemblyReleaseType; private GenomicRepresentation mGenomicRepresentation; private Date mReleaseDate; private String mAssemblyName; private String mSubmitter; private String mGenBankRefSeqPairedAssembly; private GenomicPairedAssemblyComparison mGenomicPairedAssemblyComparison; private String mFTP_Path; private Boolean mExcludedFromRefSeq; private GenomicRelationToTypeMaterial mGenomicRelationToTypeMaterial; private SimpleDateFormat mDateFormat = new SimpleDateFormat("YYYY-MM-dd"); //########################################################################## // CONSTRUCTORS //########################################################################## //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo() { } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo(XMLTag inXMLTag) { inXMLTag.verifyTagName(NCBI_GENOMIC_ASSEMBLY_INFO); XMLTag assemblyAccessionTag = inXMLTag.getRequiredSubtagByName(ASSEMBLY_ACCESSION); setAssemblyAccession(assemblyAccessionTag.getContent().trim()); XMLTag bioprojectAccessionTag = inXMLTag.getRequiredSubtagByName(BIOPROJECT_ACCESSION); setBioprojectAccession(bioprojectAccessionTag.getContent().trim()); XMLTag biosampleAccessionTag = inXMLTag.getRequiredSubtagByName(BIOSAMPLE_ACCESSION); setBioprojectAccession(biosampleAccessionTag.getContent().trim()); XMLTag wgsAccessionTag = inXMLTag.getRequiredSubtagByName(WGS_ACCESSION); setWGSAccession(wgsAccessionTag.getContent().trim()); XMLTag refseqCategoryTag = inXMLTag.getRequiredSubtagByName(REFSEQ_CATEGORY); setRefSeqCategory(GenomicRefSeqCategory.valueOf(refseqCategoryTag.getContent().trim())); XMLTag organismTaxonTag = inXMLTag.getRequiredSubtagByName(ORGANISM_TAXON); setOrganismTaxon(NCBITaxon.getByTaxonId(Integer.parseInt(organismTaxonTag.getContent().trim()))); XMLTag speciesTaxonTag = inXMLTag.getRequiredSubtagByName(SPECIES_TAXON); setSpeciesTaxon(NCBITaxon.getByTaxonId(Integer.parseInt(speciesTaxonTag.getContent().trim()))); XMLTag infraspecificNameTag = inXMLTag.getOptionalSubtagByName(INFRASPECIFIC_NAME); if (infraspecificNameTag != null) { setInfraspecificName(infraspecificNameTag.getContent().trim()); } XMLTag isolateTag = inXMLTag.getOptionalSubtagByName(ISOLATE); if (isolateTag != null) { setIsolate(isolateTag.getContent().trim()); } XMLTag assemblyVersionStatusTag = inXMLTag.getRequiredSubtagByName(ASSEMBLY_VERSION_STATUS); setAssemblyVersionStatus(GenomicAssemblyVersionStatus.valueOf(assemblyVersionStatusTag.getContent().trim())); XMLTag assemblyLevelTag = inXMLTag.getRequiredSubtagByName(ASSEMBLY_LEVEL); setAssemblyLevel(GenomicAssemblyLevel.valueOf(assemblyLevelTag.getContent().trim())); XMLTag assemblyReleaseTypeTag = inXMLTag.getRequiredSubtagByName(ASSEMBLY_RELEASE_TYPE); setAssemblyReleaseType(GenomicAssemblyReleaseType.valueOf(assemblyReleaseTypeTag.getContent().trim())); XMLTag genomicRepresentationTag = inXMLTag.getRequiredSubtagByName(GENOMIC_REPRESENTATION); setGenomicRepresentation(GenomicRepresentation.valueOf(genomicRepresentationTag.getContent().trim())); XMLTag releaseDateTag = inXMLTag.getRequiredSubtagByName(RELEASE_DATE); try { setReleaseDate(mDateFormat.parse(releaseDateTag.getContent().trim())); } catch (ParseException e) { throw new RuntimeException(e); } XMLTag assemblyNameTag = inXMLTag.getRequiredSubtagByName(ASSEMBLY_NAME); setAssemblyName(assemblyNameTag.getContent().trim()); XMLTag submitterTag = inXMLTag.getRequiredSubtagByName(SUBMITTER); setSubmitter(submitterTag.getContent().trim()); XMLTag genbankRefseqPairedAssemblyTag = inXMLTag.getOptionalSubtagByName(GENBANK_REFSEQ_PAIRED_ASSEMBLY); if (genbankRefseqPairedAssemblyTag != null) { setGenBankRefSeqPairedAssembly(genbankRefseqPairedAssemblyTag.getContent().trim()); } XMLTag genomicPairedAssemblyComparisonTag = inXMLTag.getOptionalSubtagByName(GENOMIC_PAIRED_ASSEMBLY_COMPARISON); if (genomicPairedAssemblyComparisonTag != null) { setPairedAssemblyComparison(GenomicPairedAssemblyComparison.valueOf(genomicPairedAssemblyComparisonTag.getContent().trim())); } XMLTag ftpPathTag = inXMLTag.getRequiredSubtagByName(FTP_PATH); setFTP_Path(ftpPathTag.getContent().trim()); XMLTag excludedFromRefseqTag = inXMLTag.getRequiredSubtagByName(EXCLUDED_FROM_REFSEQ); setExcludedFromRefSeq(BooleanUtil.valueOf(excludedFromRefseqTag.getContent().trim())); XMLTag genomicRelationToTypeMaterialTag = inXMLTag.getOptionalSubtagByName(GENOMIC_RELATION_TO_TYPE_MATERIAL); if (genomicRelationToTypeMaterialTag != null) { setRelationToTypeMaterial(GenomicRelationToTypeMaterial.valueOf(genomicRelationToTypeMaterialTag.getContent().trim())); } } //########################################################################## // PUBLIC METHODS //########################################################################## //--------------------------------------------------------------------------- /** * Use for processing an assembly_summary.txt file from the NCBI ftp site. * @param inFile the assembly_summary.txt file * @return a Map with species taxons as the keys * @throws IOException * @throws ParseException */ public static Map> extractInfoFromAssemblySummaryFile(File inFile) throws IOException, ParseException { List tsvData = TSV.parse(new BufferedReader(new FileReader(inFile))); Map> assemblyMap = new HashMap<>(tsvData.size()); String[] headerCols = tsvData.get(1); if (headerCols.length != 22) { throw new IOException("The assembly_summary.txt file does not have the expected number of columns!"); } SimpleDateFormat YYYYMMDD_format = new SimpleDateFormat("yyyy/MM/dd"); // Build the map of assembly data for (int i = 2; i < tsvData.size(); i++) { String[] fields = tsvData.get(i); NCBIGenomicAssemblyInfo assemblyInfo = new NCBIGenomicAssemblyInfo() .setAssemblyAccession(fields[0]) .setBioprojectAccession(fields[1]) .setBiosampleAccession(fields[2]) .setWGSAccession(fields[3]) .setRefSeqCategory(GenomicRefSeqCategory.valueOf(fields[4])) .setOrganismTaxon(NCBITaxon.getByTaxonId(Integer.parseInt(fields[5]))) .setSpeciesTaxon(NCBITaxon.getByTaxonId(Integer.parseInt(fields[6]))) // Skipping field 7 (the species name) since is part of the taxon info .setInfraspecificName(fields[8]) .setIsolate(fields[9]) .setAssemblyVersionStatus(GenomicAssemblyVersionStatus.valueOf(fields[10])) .setAssemblyLevel(GenomicAssemblyLevel.valueOf(fields[11])) .setAssemblyReleaseType(GenomicAssemblyReleaseType.valueOf(fields[12])) .setGenomicRepresentation(GenomicRepresentation.valueOf(fields[13])) .setReleaseDate(YYYYMMDD_format.parse(fields[14])) // Ex: 2019/07/30 .setAssemblyName(fields[15]) .setSubmitter(fields[16]) .setGenBankRefSeqPairedAssembly(fields[17]) .setPairedAssemblyComparison(GenomicPairedAssemblyComparison.valueOf(fields[18])) .setFTP_Path(fields[19]) .setExcludedFromRefSeq(BooleanUtil.valueOf(fields[20])) .setRelationToTypeMaterial(GenomicRelationToTypeMaterial.valueOf(fields[21])); List infoList = assemblyMap.get(assemblyInfo.getSpeciesTaxon()); if (null == infoList) { infoList = new ArrayList<>(2); assemblyMap.put(assemblyInfo.getSpeciesTaxon(), infoList); } infoList.add(assemblyInfo); } return assemblyMap; } //--------------------------------------------------------------------------- @Override public String toString() { StringBuilderPlus buffer = new StringBuilderPlus().setDelimiter("\n") .delimitedAppend("assembly_accession: " + getAssemblyAccession()) .delimitedAppend("bioproject: " + getBioprojectAccession()) .delimitedAppend("biosample: " + getBiosampleAccession()) .delimitedAppend("wgs_master: " + getWGSAccession()) .delimitedAppend("refseq_category: " + getRefSeqCategory()) .delimitedAppend("taxid: " + getOrganismTaxon().getTaxonId()) .delimitedAppend("species_taxid: " + getSpeciesTaxon().getTaxonId()) .delimitedAppend("organism_name: " + getSpeciesTaxon().getScientificName()) .delimitedAppend("infraspecific_name: " + getInfraspecificName()) .delimitedAppend("isolate: " + getIsolate()) .delimitedAppend("version_status: " + getAssemblyVersionStatus()) .delimitedAppend("assembly_level: " + getAssemblyLevel()) .delimitedAppend("release_type: " + getAssemblyReleaseType()) .delimitedAppend("genome_rep: " + getGenomicRepresentation()) .delimitedAppend("seq_rel_date: " + getReleaseDate()) .delimitedAppend("asm_name: " + getAssemblyName()) .delimitedAppend("submitter: " + getSubmitter()) .delimitedAppend("gbrs_paired_asm: " + getGenBankRefSeqPairedAssembly()) .delimitedAppend("paired_asm_comp: " + getPairedAssemblyComparison()) .delimitedAppend("ftp_path: " + getFTP_Path()) .delimitedAppend("excluded_from_refseq: " + getExcludedFromRefSeq()) .delimitedAppend("relation_to_type_material: " + (getRelationToTypeMaterial() != null ? getRelationToTypeMaterial() : "")); return buffer.toString(); } //--------------------------------------------------------------------------- public XMLTag toXMLTag() { XMLTag rootTag = new XMLTag(NCBI_GENOMIC_ASSEMBLY_INFO); rootTag.addSubtag(ASSEMBLY_ACCESSION).setContent(getAssemblyAccession()); rootTag.addSubtag(BIOPROJECT_ACCESSION).setContent(getBioprojectAccession()); rootTag.addSubtag(BIOSAMPLE_ACCESSION).setContent(getBiosampleAccession()); rootTag.addSubtag(WGS_ACCESSION).setContent(getWGSAccession()); rootTag.addSubtag(REFSEQ_CATEGORY).setContent(getRefSeqCategory().name()); rootTag.addSubtag(ORGANISM_TAXON).setContent(getOrganismTaxon().getTaxonId()); rootTag.addSubtag(SPECIES_TAXON).setContent(getSpeciesTaxon().getTaxonId()); if (getInfraspecificName() != null) { rootTag.addSubtag(INFRASPECIFIC_NAME).setContent(getInfraspecificName()); } if (getIsolate() != null) { rootTag.addSubtag(ISOLATE).setContent(getIsolate()); } rootTag.addSubtag(ASSEMBLY_VERSION_STATUS).setContent(getAssemblyVersionStatus().name()); rootTag.addSubtag(ASSEMBLY_LEVEL).setContent(getAssemblyLevel().name()); rootTag.addSubtag(ASSEMBLY_RELEASE_TYPE).setContent(getAssemblyReleaseType().name()); rootTag.addSubtag(GENOMIC_REPRESENTATION).setContent(getGenomicRepresentation().name()); rootTag.addSubtag(RELEASE_DATE).setContent(mDateFormat.format(getReleaseDate())); rootTag.addSubtag(ASSEMBLY_NAME).setContent(getAssemblyName()); rootTag.addSubtag(SUBMITTER).setContent(getSubmitter()); if (getGenBankRefSeqPairedAssembly() != null) { rootTag.addSubtag(GENBANK_REFSEQ_PAIRED_ASSEMBLY).setContent(getGenBankRefSeqPairedAssembly()); } if (getPairedAssemblyComparison() != null) { rootTag.addSubtag(GENOMIC_PAIRED_ASSEMBLY_COMPARISON).setContent(getPairedAssemblyComparison().name()); } rootTag.addSubtag(FTP_PATH).setContent(getFTP_Path()); rootTag.addSubtag(EXCLUDED_FROM_REFSEQ).setContent(getExcludedFromRefSeq() ? "true" : "false"); if (getRelationToTypeMaterial() != null) { rootTag.addSubtag(GENOMIC_RELATION_TO_TYPE_MATERIAL).setContent(getRelationToTypeMaterial().name()); } return rootTag; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setAssemblyAccession(String inValue) { mAssemblyAccession = inValue; return this; } //--------------------------------------------------------------------------- public String getAssemblyAccession() { return mAssemblyAccession; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setBioprojectAccession(String inValue) { mBioprojectAccession = inValue; return this; } //--------------------------------------------------------------------------- public String getBioprojectAccession() { return mBioprojectAccession; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setBiosampleAccession(String inValue) { mBiosampleAccession = inValue; return this; } //--------------------------------------------------------------------------- public String getBiosampleAccession() { return mBiosampleAccession; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setWGSAccession(String inValue) { mWGSAccession = inValue; return this; } //--------------------------------------------------------------------------- public String getWGSAccession() { return mWGSAccession; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setRefSeqCategory(GenomicRefSeqCategory inValue) { mRefseqCategory = inValue; return this; } //--------------------------------------------------------------------------- public GenomicRefSeqCategory getRefSeqCategory() { return mRefseqCategory; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setOrganismTaxon(NCBITaxon inValue) { mOrganismNCBITaxon = inValue; return this; } //--------------------------------------------------------------------------- public NCBITaxon getOrganismTaxon() { return mOrganismNCBITaxon; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setSpeciesTaxon(NCBITaxon inValue) { mSpeciesNCBITaxon = inValue; return this; } //--------------------------------------------------------------------------- public NCBITaxon getSpeciesTaxon() { return mSpeciesNCBITaxon; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setInfraspecificName(String inValue) { mInfraspecificName = inValue; return this; } //--------------------------------------------------------------------------- public String getInfraspecificName() { return mInfraspecificName; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setIsolate(String inValue) { mIsolate = inValue; return this; } //--------------------------------------------------------------------------- public String getIsolate() { return mIsolate; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setAssemblyVersionStatus(GenomicAssemblyVersionStatus inValue) { mAssemblyVersionStatus = inValue; return this; } //--------------------------------------------------------------------------- public GenomicAssemblyVersionStatus getAssemblyVersionStatus() { return mAssemblyVersionStatus; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setAssemblyLevel(GenomicAssemblyLevel inValue) { mAssemblyLevel = inValue; return this; } //--------------------------------------------------------------------------- public GenomicAssemblyLevel getAssemblyLevel() { return mAssemblyLevel; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setAssemblyReleaseType(GenomicAssemblyReleaseType inValue) { mAssemblyReleaseType = inValue; return this; } //--------------------------------------------------------------------------- public GenomicAssemblyReleaseType getAssemblyReleaseType() { return mAssemblyReleaseType; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setGenomicRepresentation(GenomicRepresentation inValue) { mGenomicRepresentation = inValue; return this; } //--------------------------------------------------------------------------- public GenomicRepresentation getGenomicRepresentation() { return mGenomicRepresentation; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setReleaseDate(Date inValue) { mReleaseDate = inValue; return this; } //--------------------------------------------------------------------------- public Date getReleaseDate() { return mReleaseDate; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setAssemblyName(String inValue) { mAssemblyName = inValue; return this; } //--------------------------------------------------------------------------- public String getAssemblyName() { return mAssemblyName; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setSubmitter(String inValue) { mSubmitter = inValue; return this; } //--------------------------------------------------------------------------- public String getSubmitter() { return mSubmitter; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setGenBankRefSeqPairedAssembly(String inValue) { mGenBankRefSeqPairedAssembly = inValue; return this; } //--------------------------------------------------------------------------- public String getGenBankRefSeqPairedAssembly() { return mGenBankRefSeqPairedAssembly; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setPairedAssemblyComparison(GenomicPairedAssemblyComparison inValue) { mGenomicPairedAssemblyComparison = inValue; return this; } //--------------------------------------------------------------------------- public GenomicPairedAssemblyComparison getPairedAssemblyComparison() { return mGenomicPairedAssemblyComparison; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setFTP_Path(String inValue) { mFTP_Path = inValue; return this; } //--------------------------------------------------------------------------- public String getFTP_Path() { return mFTP_Path; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setExcludedFromRefSeq(boolean inValue) { mExcludedFromRefSeq = inValue; return this; } //--------------------------------------------------------------------------- public boolean getExcludedFromRefSeq() { return mExcludedFromRefSeq; } //--------------------------------------------------------------------------- public NCBIGenomicAssemblyInfo setRelationToTypeMaterial(GenomicRelationToTypeMaterial inValue) { mGenomicRelationToTypeMaterial = inValue; return this; } //--------------------------------------------------------------------------- public GenomicRelationToTypeMaterial getRelationToTypeMaterial() { return mGenomicRelationToTypeMaterial; } //--------------------------------------------------------------------------- /** * Compares this object with the specified object for order. Returns a * negative integer, zero, or a positive integer as this object is less * than, equal to, or greater than the specified object. * *

The implementor must ensure * {@code sgn(x.compareTo(y)) == -sgn(y.compareTo(x))} * for all {@code x} and {@code y}. (This * implies that {@code x.compareTo(y)} must throw an exception iff * {@code y.compareTo(x)} throws an exception.) * *

The implementor must also ensure that the relation is transitive: * {@code (x.compareTo(y) > 0 && y.compareTo(z) > 0)} implies * {@code x.compareTo(z) > 0}. * *

Finally, the implementor must ensure that {@code x.compareTo(y)==0} * implies that {@code sgn(x.compareTo(z)) == sgn(y.compareTo(z))}, for * all {@code z}. * *

It is strongly recommended, but not strictly required that * {@code (x.compareTo(y)==0) == (x.equals(y))}. Generally speaking, any * class that implements the {@code Comparable} interface and violates * this condition should clearly indicate this fact. The recommended * language is "Note: this class has a natural ordering that is * inconsistent with equals." * *

In the foregoing description, the notation * {@code sgn(}expression{@code )} designates the mathematical * signum function, which is defined to return one of {@code -1}, * {@code 0}, or {@code 1} according to whether the value of * expression is negative, zero, or positive, respectively. * * @param inObj2 the object to be compared. * @return a negative integer, zero, or a positive integer as this object * is less than, equal to, or greater than the specified object. * @throws ClassCastException if the specified object's type prevents it * from being compared to this object. */ @Override public int compareTo(NCBIGenomicAssemblyInfo inObj2) { int result = -1; if (inObj2 != null) { result = CompareUtil.compare(getSpeciesTaxon(), inObj2.getSpeciesTaxon()); if (0 == result) { result = CompareUtil.compare(getOrganismTaxon(), inObj2.getOrganismTaxon()); if (0 == result) { result = CompareUtil.compare(getRefSeqCategory(), inObj2.getRefSeqCategory()); if (0 == result) { result = CompareUtil.compare(getGenomicRepresentation(), inObj2.getGenomicRepresentation()); if (0 == result) { result = CompareUtil.compare(getAssemblyReleaseType(), inObj2.getAssemblyReleaseType()); if (0 == result) { result = CompareUtil.compare(getAssemblyVersionStatus(), inObj2.getAssemblyVersionStatus()); } } } } } } return result; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy