001package com.hfg.bio.proteinproperty; 002 003 004import java.util.Collection; 005import java.util.Map; 006 007import com.hfg.bio.*; 008import com.hfg.bio.seq.Protein; 009import com.hfg.util.collection.OrderedMap; 010 011//------------------------------------------------------------------------------ 012/** 013 * Mass packaged as a protein property for ease of integration with 014 * other protein properties. 015 * 016 * @author J. Alex Taylor, hairyfatguy.com 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 Mass extends SimpleProteinProperty<SimpleProteinPropertyCalcSettings, Double> 040{ 041 private KaSet mKaSet; 042 043 private static Map<String, Mass> sUniqueMap = new OrderedMap<>(); 044 045 public static final Mass MONOISOTOPIC = new Mass("Monoisotopic"); 046 public static final Mass AVERAGE = new Mass("Avg."); 047 public static final Mass ORGANIC_AVERAGE = new Mass("Organic Avg."); 048 049 //########################################################################### 050 // CONSTRUCTORS 051 //########################################################################### 052 053 //-------------------------------------------------------------------------- 054 private Mass(String inName) 055 { 056 super(inName); 057 058 sUniqueMap.put(inName, this); 059 } 060 061 //########################################################################### 062 // PUBLIC METHODS 063 //########################################################################### 064 065 //--------------------------------------------------------------------------- 066 public static Collection<Mass> values() 067 { 068 return sUniqueMap.values(); 069 } 070 071 //-------------------------------------------------------------------------- 072 public String getType() 073 { 074 return "Mass"; 075 } 076 077 //-------------------------------------------------------------------------- 078 /** 079 Determines the mass of the specified protein. 080 */ 081 public Double calculate(Protein inProtein, SimpleProteinPropertyCalcSettings inSettings) 082 { 083 Double mass = null; 084 switch (name()) 085 { 086 case "Monoisotopic": 087 mass = inProtein.getMonoisotopicMass(inSettings.getProteinAnalysisMode()); 088 break; 089 090 case "Avg.": 091 mass = inProtein.getAverageMass(inSettings.getProteinAnalysisMode()); 092 break; 093 094 case "Organic Avg.": 095 mass = inProtein.getOrganicAverageMass(inSettings.getProteinAnalysisMode()); 096 break; 097 } 098 099 return mass; 100 } 101}