001package com.hfg.bio.seq.genomic; 002 003 004 005import com.hfg.bio.HfgBioXML; 006import com.hfg.bio.seq.GenomicLocation; 007import com.hfg.bio.seq.NucleicAcid; 008import com.hfg.util.StringUtil; 009import com.hfg.xml.XMLNode; 010import com.hfg.xml.XMLTag; 011 012//------------------------------------------------------------------------------ 013/** 014 * An intron in a gene. 015 * 016 * @author J. Alex Taylor, hairyfatguy.com 017 */ 018//------------------------------------------------------------------------------ 019// com.hfg XML/HTML Coding Library 020// 021// This library is free software; you can redistribute it and/or 022// modify it under the terms of the GNU Lesser General Public 023// License as published by the Free Software Foundation; either 024// version 2.1 of the License, or (at your option) any later version. 025// 026// This library is distributed in the hope that it will be useful, 027// but WITHOUT ANY WARRANTY; without even the implied warranty of 028// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 029// Lesser General Public License for more details. 030// 031// You should have received a copy of the GNU Lesser General Public 032// License along with this library; if not, write to the Free Software 033// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 034// 035// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 036// jataylor@hairyfatguy.com 037//------------------------------------------------------------------------------ 038 039public class Intron extends NucleicAcid 040{ 041 042 //########################################################################## 043 // PRIVATE FIELDS 044 //########################################################################## 045 046 private GenomicLocation mLocation; 047 private String mDonorSpliceSite; 048 private String mAcceptorSpliceSite; 049 050 051 //########################################################################## 052 // CONSTRUCTORS 053 //########################################################################## 054 055 //-------------------------------------------------------------------------- 056 public Intron() 057 { 058 059 } 060 061 //-------------------------------------------------------------------------- 062 public Intron(XMLNode inXML) 063 { 064 inXML.verifyTagName(HfgBioXML.INTRON_TAG); 065 066 setDonorSpliceSite(inXML.getAttributeValue(HfgBioXML.DONOR_SITE_ATT)); 067 setAcceptorSpliceSite(inXML.getAttributeValue(HfgBioXML.ACCEPTOR_SITE_ATT)); 068 069 XMLTag locTag = inXML.getOptionalSubtagByName(HfgBioXML.GENOMIC_LOC_TAG); 070 if (locTag != null) 071 { 072 setGenomicLocaiton(new GenomicLocation(locTag)); 073 } 074 075 XMLTag dnaTag = inXML.getOptionalSubtagByName(HfgBioXML.DNA_TAG); 076 if (dnaTag != null) 077 { 078 setSequence(dnaTag.getContent()); 079 } 080 } 081 082 //########################################################################## 083 // PUBLIC METHODS 084 //########################################################################## 085 086 087 public XMLNode toXMLNode() 088 { 089 XMLTag tag = new XMLTag(HfgBioXML.INTRON_TAG); 090 tag.setSortAttributesBeforeWriting(false); 091 092 if (StringUtil.isSet(getDonorSpliceSite())) 093 { 094 tag.setAttribute(HfgBioXML.DONOR_SITE_ATT, getDonorSpliceSite()); 095 } 096 097 if (StringUtil.isSet(getAcceptorSpliceSite())) 098 { 099 tag.setAttribute(HfgBioXML.ACCEPTOR_SITE_ATT, getAcceptorSpliceSite()); 100 } 101 102 tag.setAttribute(HfgBioXML.SEQ_LENGTH_ATT, length()); 103 104 if (getGenomicLocaiton() != null) 105 { 106 tag.addSubtag(getGenomicLocaiton().toXMLTag()); 107 } 108 109 if (StringUtil.isSet(getSequence())) 110 { 111 tag.addSubtag(new XMLTag(HfgBioXML.DNA_TAG).setContent(getSequence())); 112 } 113 114 return tag; 115 } 116 117 //-------------------------------------------------------------------------- 118 public Intron setGenomicLocaiton(GenomicLocation inValue) 119 { 120 mLocation = inValue; 121 return this; 122 } 123 124 //-------------------------------------------------------------------------- 125 public GenomicLocation getGenomicLocaiton() 126 { 127 return mLocation; 128 } 129 130 131 //-------------------------------------------------------------------------- 132 public Intron setDonorSpliceSite(CharSequence inValue) 133 { 134 mDonorSpliceSite = inValue != null ? inValue.toString() : null; 135 return this; 136 } 137 138 //-------------------------------------------------------------------------- 139 public String getDonorSpliceSite() 140 { 141 return mDonorSpliceSite; 142 } 143 144 145 //-------------------------------------------------------------------------- 146 public Intron setAcceptorSpliceSite(CharSequence inValue) 147 { 148 mAcceptorSpliceSite = inValue != null ? inValue.toString() : null; 149 return this; 150 } 151 152 //-------------------------------------------------------------------------- 153 public String getAcceptorSpliceSite() 154 { 155 return mAcceptorSpliceSite; 156 } 157 158 159 //-------------------------------------------------------------------------- 160 public Intron setSequence(String inValue) 161 { 162 return (Intron) super.setSequence(inValue); 163 } 164 165}