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

com.hfg.bio.DigestFragment Maven / Gradle / Ivy

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

import java.util.List;

import com.hfg.bio.seq.Protein;
import com.hfg.bio.seq.SeqLocation;
import com.hfg.util.collection.CollectionUtil;
import com.hfg.util.StringUtil;

//------------------------------------------------------------------------------
/**
 * Product of a proteolytic digest.
 *
 * @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 DigestFragment extends Protein
{
   private int    mBegin;
   private int    mEnd;
   private int    mNumUncleavedSites;
   private int    mBeginFragIndex;
   private int    mEndFragIndex;
   private Character mPrecedingResidue;
   private Character mTrailingResidue;
   //Cached
   private SeqLocation mSeqLocation;

   //---------------------------------------------------------------------------
   public void setBegin(int inValue)
   {
      mBegin = inValue;
      mSeqLocation =  null;
   }

   //---------------------------------------------------------------------------
   public int getBegin()
   {
      return mBegin;
   }

   //---------------------------------------------------------------------------
   public void setEnd(int inValue)
   {
      mEnd = inValue;
      mSeqLocation =  null;
   }

   //---------------------------------------------------------------------------
   public int getEnd()
   {
      return mEnd;
   }

   //---------------------------------------------------------------------------
   public SeqLocation getSeqLocation()
   {
      if (null == mSeqLocation)
      {
         mSeqLocation = new SeqLocation(getBegin(), getEnd());
      }

      return mSeqLocation;
   }


   //---------------------------------------------------------------------------
   public void setPrecedingResidue(Character inValue)
   {
      mPrecedingResidue = inValue;
   }

   //---------------------------------------------------------------------------
   public Character getPrecedingResidue()
   {
      return mPrecedingResidue;
   }


   //---------------------------------------------------------------------------
   public void setTrailingResidue(Character inValue)
   {
      mTrailingResidue = inValue;
   }

   //---------------------------------------------------------------------------
   public Character getTrailingResidue()
   {
      return mTrailingResidue;
   }


   //---------------------------------------------------------------------------
   public void setNumUncleavedSites(int inValue)
   {
      mNumUncleavedSites = inValue;
   }

   //---------------------------------------------------------------------------
   public int getNumUncleavedSites()
   {
      return mNumUncleavedSites;
   }

   //---------------------------------------------------------------------------
   public void setBeginFragIndex(int inValue)
   {
      mBeginFragIndex = inValue;
   }

   //---------------------------------------------------------------------------
   public int getBeginFragIndex()
   {
      return mBeginFragIndex;
   }

   //---------------------------------------------------------------------------
   public void setEndFragIndex(int inValue)
   {
      mEndFragIndex = inValue;
   }

   //---------------------------------------------------------------------------
   public int getEndFragIndex()
   {
      return mEndFragIndex;
   }

   //---------------------------------------------------------------------------
   public String getFragIndexString()
   {
      return mBeginFragIndex + (mEndFragIndex != mBeginFragIndex ? ".." + mEndFragIndex : "");
   }

   //---------------------------------------------------------------------------
   @Override
   public String toString()
   {
      StringBuilder buffer = new StringBuilder();

      if (CollectionUtil.hasValues(getChains()))
      {
         for (DigestFragment chain : (List) (Object) getChains())
         {
            if (StringUtil.isSet(chain.getID()))
            {
               buffer.append(chain.getID());
               buffer.append(" ");
            }
            buffer.append(chain.getFragIndexString());
            buffer.append("\t");
            buffer.append(chain.getBegin());
            buffer.append(" - ");
            buffer.append(chain.getEnd());
            buffer.append("\t");
            buffer.append(chain.getSequence());
            buffer.append("\n    ");
         }
         buffer.append(getXLinks());
      }
      else
      {
         if (StringUtil.isSet(getID()))
         {
            buffer.append(getID());
            buffer.append(" ");
         }
         buffer.append(getFragIndexString());
         buffer.append("\t");
         buffer.append(getBegin());
         buffer.append(" - ");
         buffer.append(getEnd());
         buffer.append("\t");
         buffer.append(getSequence());
      }

      return buffer.toString();
   }
}
































































© 2015 - 2024 Weber Informatics LLC | Privacy Policy