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

com.hfg.bio.seq.genomic.Intron Maven / Gradle / Ivy

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



import com.hfg.bio.HfgBioXML;
import com.hfg.bio.seq.GenomicLocation;
import com.hfg.bio.seq.NucleicAcid;
import com.hfg.util.StringUtil;
import com.hfg.xml.XMLNode;
import com.hfg.xml.XMLTag;

//------------------------------------------------------------------------------
/**
 * An intron in a gene.
 *
 * @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 Intron extends NucleicAcid
{

   //##########################################################################
   // PRIVATE FIELDS
   //##########################################################################

   private GenomicLocation mLocation;
   private String mDonorSpliceSite;
   private String mAcceptorSpliceSite;


   //##########################################################################
   // CONSTRUCTORS
   //##########################################################################

   //--------------------------------------------------------------------------
   public Intron()
   {

   }

   //--------------------------------------------------------------------------
   public Intron(XMLNode inXML)
   {
      inXML.verifyTagName(HfgBioXML.INTRON_TAG);

      setDonorSpliceSite(inXML.getAttributeValue(HfgBioXML.DONOR_SITE_ATT));
      setAcceptorSpliceSite(inXML.getAttributeValue(HfgBioXML.ACCEPTOR_SITE_ATT));

      XMLTag locTag = inXML.getOptionalSubtagByName(HfgBioXML.GENOMIC_LOC_TAG);
      if (locTag != null)
      {
         setGenomicLocaiton(new GenomicLocation(locTag));
      }

      XMLTag dnaTag = inXML.getOptionalSubtagByName(HfgBioXML.DNA_TAG);
      if (dnaTag != null)
      {
         setSequence(dnaTag.getContent());
      }
   }

   //##########################################################################
   // PUBLIC METHODS
   //##########################################################################


   public XMLNode toXMLNode()
   {
      XMLTag tag = new XMLTag(HfgBioXML.INTRON_TAG);
      tag.setSortAttributesBeforeWriting(false);

      if (StringUtil.isSet(getDonorSpliceSite()))
      {
         tag.setAttribute(HfgBioXML.DONOR_SITE_ATT, getDonorSpliceSite());
      }

      if (StringUtil.isSet(getAcceptorSpliceSite()))
      {
         tag.setAttribute(HfgBioXML.ACCEPTOR_SITE_ATT, getAcceptorSpliceSite());
      }

      tag.setAttribute(HfgBioXML.SEQ_LENGTH_ATT, length());

      if (getGenomicLocaiton() != null)
      {
         tag.addSubtag(getGenomicLocaiton().toXMLTag());
      }

      if (StringUtil.isSet(getSequence()))
      {
         tag.addSubtag(new XMLTag(HfgBioXML.DNA_TAG).setContent(getSequence()));
      }

      return tag;
   }

   //--------------------------------------------------------------------------
   public Intron setGenomicLocaiton(GenomicLocation inValue)
   {
      mLocation = inValue;
      return this;
   }

   //--------------------------------------------------------------------------
   public GenomicLocation getGenomicLocaiton()
   {
      return mLocation;
   }


   //--------------------------------------------------------------------------
   public Intron setDonorSpliceSite(CharSequence inValue)
   {
      mDonorSpliceSite = inValue != null ? inValue.toString() : null;
      return this;
   }

   //--------------------------------------------------------------------------
   public String getDonorSpliceSite()
   {
      return mDonorSpliceSite;
   }


   //--------------------------------------------------------------------------
   public Intron setAcceptorSpliceSite(CharSequence inValue)
   {
      mAcceptorSpliceSite = inValue != null ? inValue.toString() : null;
      return this;
   }

   //--------------------------------------------------------------------------
   public String getAcceptorSpliceSite()
   {
      return mAcceptorSpliceSite;
   }


   //--------------------------------------------------------------------------
   public Intron setSequence(String inValue)
   {
      return (Intron) super.setSequence(inValue);
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy