001package com.hfg.bio; 002 003import java.util.List; 004 005import com.hfg.bio.seq.Protein; 006import com.hfg.bio.seq.SeqLocation; 007import com.hfg.util.collection.CollectionUtil; 008import com.hfg.util.StringUtil; 009 010//------------------------------------------------------------------------------ 011/** 012 * Product of a proteolytic digest. 013 * 014 * @author J. Alex Taylor, hairyfatguy.com 015 */ 016//------------------------------------------------------------------------------ 017// com.hfg XML/HTML Coding Library 018// 019// This library is free software; you can redistribute it and/or 020// modify it under the terms of the GNU Lesser General Public 021// License as published by the Free Software Foundation; either 022// version 2.1 of the License, or (at your option) any later version. 023// 024// This library is distributed in the hope that it will be useful, 025// but WITHOUT ANY WARRANTY; without even the implied warranty of 026// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 027// Lesser General Public License for more details. 028// 029// You should have received a copy of the GNU Lesser General Public 030// License along with this library; if not, write to the Free Software 031// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 032// 033// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 034// jataylor@hairyfatguy.com 035//------------------------------------------------------------------------------ 036 037public class DigestFragment extends Protein 038{ 039 private String mSrcChainId; 040 private int mBegin; 041 private int mEnd; 042 private int mNumUncleavedSites; 043 private int mBeginFragIndex; 044 private int mEndFragIndex; 045 private Character mPrecedingResidue; 046 private Character mTrailingResidue; 047 //Cached 048 private SeqLocation mSeqLocation; 049 050 //--------------------------------------------------------------------------- 051 public DigestFragment setSrcChainId(String inValue) 052 { 053 mSrcChainId = inValue; 054 return this; 055 } 056 057 //--------------------------------------------------------------------------- 058 public String getSrcChainId() 059 { 060 return mSrcChainId; 061 } 062 063 064 //--------------------------------------------------------------------------- 065 public void setBegin(int inValue) 066 { 067 mBegin = inValue; 068 mSeqLocation = null; 069 } 070 071 //--------------------------------------------------------------------------- 072 public int getBegin() 073 { 074 return mBegin; 075 } 076 077 //--------------------------------------------------------------------------- 078 public void setEnd(int inValue) 079 { 080 mEnd = inValue; 081 mSeqLocation = null; 082 } 083 084 //--------------------------------------------------------------------------- 085 public int getEnd() 086 { 087 return mEnd; 088 } 089 090 //--------------------------------------------------------------------------- 091 public SeqLocation getSeqLocation() 092 { 093 if (null == mSeqLocation) 094 { 095 mSeqLocation = new SeqLocation(getBegin(), getEnd()); 096 } 097 098 return mSeqLocation; 099 } 100 101 102 //--------------------------------------------------------------------------- 103 public void setPrecedingResidue(Character inValue) 104 { 105 mPrecedingResidue = inValue; 106 } 107 108 //--------------------------------------------------------------------------- 109 public Character getPrecedingResidue() 110 { 111 return mPrecedingResidue; 112 } 113 114 115 //--------------------------------------------------------------------------- 116 public void setTrailingResidue(Character inValue) 117 { 118 mTrailingResidue = inValue; 119 } 120 121 //--------------------------------------------------------------------------- 122 public Character getTrailingResidue() 123 { 124 return mTrailingResidue; 125 } 126 127 128 //--------------------------------------------------------------------------- 129 public void setNumUncleavedSites(int inValue) 130 { 131 mNumUncleavedSites = inValue; 132 } 133 134 //--------------------------------------------------------------------------- 135 public int getNumUncleavedSites() 136 { 137 return mNumUncleavedSites; 138 } 139 140 //--------------------------------------------------------------------------- 141 public void setBeginFragIndex(int inValue) 142 { 143 mBeginFragIndex = inValue; 144 } 145 146 //--------------------------------------------------------------------------- 147 public int getBeginFragIndex() 148 { 149 return mBeginFragIndex; 150 } 151 152 //--------------------------------------------------------------------------- 153 public void setEndFragIndex(int inValue) 154 { 155 mEndFragIndex = inValue; 156 } 157 158 //--------------------------------------------------------------------------- 159 public int getEndFragIndex() 160 { 161 return mEndFragIndex; 162 } 163 164 //--------------------------------------------------------------------------- 165 public String getFragIndexString() 166 { 167 return mBeginFragIndex + (mEndFragIndex != mBeginFragIndex ? ".." + mEndFragIndex : ""); 168 } 169 170 //--------------------------------------------------------------------------- 171 @Override 172 public String toString() 173 { 174 StringBuilder buffer = new StringBuilder(); 175 176 if (CollectionUtil.hasValues(getChains())) 177 { 178 for (DigestFragment chain : (List<DigestFragment>) (Object) getChains()) 179 { 180 if (StringUtil.isSet(chain.getSrcChainId())) 181 { 182 buffer.append(chain.getSrcChainId()); 183 buffer.append(" "); 184 } 185 else if (StringUtil.isSet(chain.getID())) 186 { 187 buffer.append(chain.getID()); 188 buffer.append(" "); 189 } 190 buffer.append("#" + chain.getFragIndexString()); 191 buffer.append("\t"); 192 buffer.append(chain.getBegin()); 193 buffer.append(" - "); 194 buffer.append(chain.getEnd()); 195 buffer.append("\t"); 196 buffer.append(chain.getSequence()); 197 buffer.append("\n "); 198 } 199 buffer.append(getXLinks()); 200 } 201 else 202 { 203 if (StringUtil.isSet(getID())) 204 { 205 buffer.append(getID()); 206 buffer.append(" "); 207 } 208 buffer.append(getFragIndexString()); 209 buffer.append("\t"); 210 buffer.append(getBegin()); 211 buffer.append(" - "); 212 buffer.append(getEnd()); 213 buffer.append("\t"); 214 buffer.append(getSequence()); 215 } 216 217 return buffer.toString(); 218 } 219} 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279