001package com.hfg.bio.proteinproperty;
002
003
004import com.hfg.bio.seq.Protein;
005
006import java.util.Collection;
007import java.util.HashMap;
008import java.util.Map;
009
010//------------------------------------------------------------------------------
011/**
012 * Sequence length packaged as a protein property for ease of integration with
013 * other protein properties.
014 *
015 * @author J. Alex Taylor, hairyfatguy.com
016 */
017//------------------------------------------------------------------------------
018// com.hfg Library
019//
020// This library is free software; you can redistribute it and/or
021// modify it under the terms of the GNU Lesser General Public
022// License as published by the Free Software Foundation; either
023// version 2.1 of the License, or (at your option) any later version.
024//
025// This library is distributed in the hope that it will be useful,
026// but WITHOUT ANY WARRANTY; without even the implied warranty of
027// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
028// Lesser General Public License for more details.
029//
030// You should have received a copy of the GNU Lesser General Public
031// License along with this library; if not, write to the Free Software
032// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
033//
034// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
035// jataylor@hairyfatguy.com
036//------------------------------------------------------------------------------
037
038public class SeqLength extends SimpleProteinProperty<SimpleProteinPropertyCalcSettings, Integer>
039{
040   private static Map<String, SeqLength> sUniqueMap = new HashMap<>();
041
042   public static final SeqLength PROPERTY = new SeqLength("Seq Length", "Length of the Sequence");
043
044   //###########################################################################
045   // CONSTRUCTORS
046   //###########################################################################
047
048   //---------------------------------------------------------------------------
049   private SeqLength(String inName, String inDescription)
050   {
051      super(inName);
052      setDescription(inDescription);
053
054      sUniqueMap.put(inName, this);
055   }
056
057   //###########################################################################
058   // PUBLIC METHODS
059   //###########################################################################
060
061   //---------------------------------------------------------------------------
062   public static Collection<SeqLength> values()
063   {
064      return sUniqueMap.values();
065   }
066
067   //--------------------------------------------------------------------------
068   public String getType()
069   {
070      return "Length";
071   }
072
073   //---------------------------------------------------------------------------
074   public Integer calculate(Protein inProtein)
075   {
076      return calculate(inProtein, null);
077   }
078
079   //---------------------------------------------------------------------------
080   public Integer calculate(Protein inProtein, SimpleProteinPropertyCalcSettings inSettings)
081   {
082      return inProtein.length();
083   }
084
085}