com.hfg.bio.seq.BioSequencePlusImpl 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.seq;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
import com.hfg.bio.DbXref;
import com.hfg.bio.seq.format.SeqCitation;
import com.hfg.bio.seq.format.feature.FeatureKey;
import com.hfg.bio.seq.format.feature.SeqFeature;
import com.hfg.bio.seq.format.feature.qualifier.MolType;
import com.hfg.bio.taxonomy.ncbi.NCBITaxon;
import com.hfg.bio.taxonomy.SeqRepositoryDivision;
import com.hfg.util.collection.OrderedSet;
import com.hfg.xml.XMLNode;
//------------------------------------------------------------------------------
/**
Exetended biological protein, DNA, or RNA sequence with support for features,
citations, db xrefs, etc.
@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 abstract class BioSequencePlusImpl extends BioSequenceImpl implements BioSequencePlus
{
private SeqRepositoryDivision mSeqRepositoryDivision;
private MolType mMolType;
private SeqTopology mSeqTopology;
private List mFeatures;
private List mCitations;
private List mDbXRefs;
private Set mKeywords;
private Date mRevisionDate;
private Clone mClone;
private NCBITaxon mNCBITaxon;
private List mParseExceptions;
//##########################################################################
// CONSTRUCTORS
//##########################################################################
//--------------------------------------------------------------------------
public BioSequencePlusImpl()
{
}
//--------------------------------------------------------------------------
public BioSequencePlusImpl(XMLNode inXML)
{
super(inXML);
// TODO: Add support for features, citations, etc.
}
//##########################################################################
// PUBLIC METHODS
//##########################################################################
//--------------------------------------------------------------------------
public XMLNode toXMLNode()
{
XMLNode node = super.toXMLNode();
// TODO: Add support for features, citations, etc.
return node;
}
//--------------------------------------------------------------------------
@Override
public BioSequencePlusImpl clone()
{
BioSequencePlusImpl theClone = (BioSequencePlusImpl) super.clone();
if (mFeatures != null)
{
// For right now this is a shallow clone of the features
theClone.mFeatures = new ArrayList<>(mFeatures);
}
if (mCitations != null)
{
// For right now this is a shallow clone of the citations
theClone.mCitations = new ArrayList<>(mCitations);
}
if (mDbXRefs != null)
{
// For right now this is a shallow clone of the dbxrefs
theClone.mDbXRefs = new ArrayList<>(mDbXRefs);
}
return theClone;
}
//--------------------------------------------------------------------------
public BioSequenceImpl addFeature(SeqFeature inValue)
{
if (null == mFeatures)
{
mFeatures = new ArrayList<>(25);
}
mFeatures.add(inValue);
return this;
}
//--------------------------------------------------------------------------
public List getFeatures()
{
return mFeatures;
}
//--------------------------------------------------------------------------
public List getFeatures(FeatureKey inFeatureKey)
{
List requestedFeatures = new ArrayList<>(20);
if (mFeatures != null)
{
for (SeqFeature feature : mFeatures)
{
if (feature.name().name().equals(inFeatureKey.name()))
{
requestedFeatures.add(feature);
}
}
}
return requestedFeatures;
}
//--------------------------------------------------------------------------
public void clearFeatures()
{
if (mFeatures != null)
{
mFeatures.clear();
}
}
//--------------------------------------------------------------------------
public BioSequenceImpl setReferences(List inValues)
{
mCitations = inValues != null ? new ArrayList<>(inValues) : null;
return this;
}
//--------------------------------------------------------------------------
public BioSequenceImpl addReference(SeqCitation inValue)
{
if (null == mCitations)
{
mCitations = new ArrayList<>(5);
}
mCitations.add(inValue);
return this;
}
//--------------------------------------------------------------------------
public List getReferences()
{
return mCitations;
}
//--------------------------------------------------------------------------
public void clearReferences()
{
if (mCitations != null)
{
mCitations.clear();
}
}
//--------------------------------------------------------------------------
public BioSequenceImpl addDbXref(DbXref inValue)
{
if (null == mDbXRefs)
{
mDbXRefs = new ArrayList<>(5);
}
mDbXRefs.add(inValue);
return this;
}
//--------------------------------------------------------------------------
public List getDbXrefs()
{
return mDbXRefs;
}
//--------------------------------------------------------------------------
public void clearDbXrefs()
{
if (mDbXRefs != null)
{
mDbXRefs.clear();
}
}
//--------------------------------------------------------------------------
public BioSequenceImpl addKeyword(String inValue)
{
if (null == mKeywords)
{
mKeywords = new OrderedSet<>(10);
}
mKeywords.add(inValue);
return this;
}
//--------------------------------------------------------------------------
public BioSequenceImpl addKeywords(Collection inValues)
{
if (inValues != null)
{
if (null == mKeywords)
{
mKeywords = new OrderedSet<>(10);
}
mKeywords.addAll(inValues);
}
return this;
}
//--------------------------------------------------------------------------
public BioSequenceImpl addKeywords(String[] inValues)
{
if (inValues != null)
{
if (null == mKeywords)
{
mKeywords = new OrderedSet<>(10);
}
mKeywords.addAll(Arrays.asList(inValues));
}
return this;
}
//--------------------------------------------------------------------------
public Set getKeywords()
{
return mKeywords;
}
//--------------------------------------------------------------------------
public void clearKeywords()
{
if (mKeywords != null)
{
mKeywords.clear();
}
}
//--------------------------------------------------------------------------
public BioSequencePlusImpl setSeqRepositoryDivision(SeqRepositoryDivision inValue)
{
mSeqRepositoryDivision = inValue;
return this;
}
//--------------------------------------------------------------------------
public SeqRepositoryDivision getSeqRepositoryDivision()
{
return mSeqRepositoryDivision;
}
//--------------------------------------------------------------------------
public BioSequencePlusImpl setMolType(MolType inValue)
{
mMolType = inValue;
return this;
}
//--------------------------------------------------------------------------
public MolType getMolType()
{
return mMolType;
}
//--------------------------------------------------------------------------
public BioSequencePlusImpl setSeqTopology(SeqTopology inValue)
{
mSeqTopology = inValue;
return this;
}
//--------------------------------------------------------------------------
public SeqTopology getSeqTopology()
{
return mSeqTopology;
}
//--------------------------------------------------------------------------
public BioSequencePlusImpl setRevisionDate(Date inValue)
{
mRevisionDate = inValue;
return this;
}
//--------------------------------------------------------------------------
public Date getRevisionDate()
{
return mRevisionDate;
}
//--------------------------------------------------------------------------
public BioSequencePlusImpl setClone(Clone inValue)
{
mClone = inValue;
return this;
}
//--------------------------------------------------------------------------
public Clone getClone()
{
return mClone;
}
//--------------------------------------------------------------------------
public BioSequencePlusImpl setNCBITaxon(NCBITaxon inValue)
{
mNCBITaxon = inValue;
return this;
}
//--------------------------------------------------------------------------
public NCBITaxon getNCBITaxon()
{
return mNCBITaxon;
}
//--------------------------------------------------------------------------
public void addParseException(Throwable inException)
{
if (null == mParseExceptions)
{
mParseExceptions = new ArrayList<>(4);
}
mParseExceptions.add(inException);
}
//--------------------------------------------------------------------------
public void clearParseExceptions()
{
mParseExceptions = null;
}
//--------------------------------------------------------------------------
public List getParseExceptions()
{
return mParseExceptions;
}
}