com.hfg.bio.seq.BioSequence 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.io.*;
import java.lang.reflect.Constructor;
import java.util.Collection;
import java.util.List;
import com.hfg.bio.DbXref;
import com.hfg.bio.HfgBioXML;
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.util.StringUtil;
import com.hfg.xml.XMLNode;
//------------------------------------------------------------------------------
/**
Interface for a biological Protein, DNA, or RNA sequence.
@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 interface BioSequence extends Cloneable
{
//##########################################################################
// PUBLIC METHODS
//##########################################################################
//--------------------------------------------------------------------------
public BioSequence clone();
//--------------------------------------------------------------------------
/**
Sets the id or name for the sequence.
Returns 'this' which can be useful for method chaining.
@param inValue the id to use for this sequence
@return this BioSequence to enable method chaining
*/
public BioSequence setID(String inValue);
//--------------------------------------------------------------------------
public String getID();
//--------------------------------------------------------------------------
public BioSequenceType getType();
//--------------------------------------------------------------------------
public BioSequence setDescription(CharSequence inValue);
//--------------------------------------------------------------------------
public String getDescription();
//--------------------------------------------------------------------------
public BioSequence setSequence(CharSequence inValue);
//--------------------------------------------------------------------------
public BioSequence setSequence(Reader inReader);
//--------------------------------------------------------------------------
public String getSequence();
//--------------------------------------------------------------------------
public String getSubSequence(SeqLocation inSeqLocation);
//--------------------------------------------------------------------------
public int length();
//--------------------------------------------------------------------------
/**
Returns the residue character at the specified (1-based) sequence location.
@param inIndex the 1-based sequence location at which to retrieve the residue
@return the residue at the specified index
*/
public char residueAt(int inIndex);
//--------------------------------------------------------------------------
public Reader getSequenceReader();
//--------------------------------------------------------------------------
public Reader getSubSequenceReader(SeqLocation inSeqLocation);
//--------------------------------------------------------------------------
public InputStream getSequenceStream();
//--------------------------------------------------------------------------
public byte[] getMD5Checksum();
//--------------------------------------------------------------------------
public byte[] getSHA1Checksum();
//--------------------------------------------------------------------------
public void setAttribute(String inName, Object inValue);
//--------------------------------------------------------------------------
public Object getAttribute(String inName);
//--------------------------------------------------------------------------
public boolean hasAttribute(String inName);
//--------------------------------------------------------------------------
public Collection getAttributeNames();
//--------------------------------------------------------------------------
public Object removeAttribute(String inName);
//--------------------------------------------------------------------------
public XMLNode toXMLNode();
//--------------------------------------------------------------------------
public static BioSequence instantiate(XMLNode inXMLNode)
{
String classname = inXMLNode.getAttributeValue(HfgBioXML.CLASS_ATT);
if (! StringUtil.isSet(classname))
{
throw new RuntimeException("No " + HfgBioXML.CLASS_ATT + " specified on sequence's XML tag!");
}
BioSequence seq = null;
try
{
Class clazz = Class.forName(classname);
Constructor constructor = clazz.getConstructor(XMLNode.class);
seq = (BioSequence) constructor.newInstance(inXMLNode);
}
catch (Exception e)
{
throw new RuntimeException("Error during sequence instantiation from its XML tag!", e);
}
return seq;
}
}