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 Chemical formula packaged as a protein property for ease of integration with
013 other protein properties.
014 <div>
015 @author J. Alex Taylor, hairyfatguy.com
016 </div>
017 */
018//------------------------------------------------------------------------------
019// com.hfg 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 ChemicalFormula extends SimpleProteinProperty<SimpleProteinPropertyCalcSettings, String>
040{
041   private static Map<String, ChemicalFormula> sUniqueMap = new HashMap<>();
042
043   public static final ChemicalFormula PROPERTY = new ChemicalFormula("Chemical Formula", "Elemental composition of the sequence");
044
045   //###########################################################################
046   // CONSTRUCTORS
047   //###########################################################################
048
049   //---------------------------------------------------------------------------
050   private ChemicalFormula(String inName, String inDescription)
051   {
052      super(inName);
053      setDescription(inDescription);
054
055      sUniqueMap.put(inName, this);
056   }
057
058   //###########################################################################
059   // PUBLIC METHODS
060   //###########################################################################
061
062   //---------------------------------------------------------------------------
063   public static Collection<ChemicalFormula> values()
064   {
065      return sUniqueMap.values();
066   }
067
068   //--------------------------------------------------------------------------
069   public String getType()
070   {
071      return "Composition";
072   }
073
074   //---------------------------------------------------------------------------
075   public String calculate(Protein inProtein)
076   {
077      return calculate(inProtein, null);
078   }
079
080   //---------------------------------------------------------------------------
081   public String calculate(Protein inProtein, SimpleProteinPropertyCalcSettings inSettings)
082   {
083      return inProtein.getChemicalFormula();
084   }
085
086}