001package com.hfg.bio.proteinproperty; 002 003import java.math.BigDecimal; 004import java.math.MathContext; 005import java.util.Collection; 006import java.util.HashMap; 007import java.util.Map; 008 009import com.hfg.bio.seq.Protein; 010 011//------------------------------------------------------------------------------ 012/** 013 Percent extinction coefficient (ml/mg cm<sup>-1</sup>) at A<sub>280</sub> 014 packaged as a protein property for ease of integration with other protein properties. 015 <div> 016 Uses residue coefficients from Pace, C.N. et. al. (1995). "How to measure and predict the molar absorption coefficient of a protein." 017 <i>Protein Science,</i> 4, 2411-2423. 018 </div> 019 <div> 020 @author J. Alex Taylor, hairyfatguy.com 021 </div> 022 */ 023//------------------------------------------------------------------------------ 024// com.hfg Library 025// 026// This library is free software; you can redistribute it and/or 027// modify it under the terms of the GNU Lesser General Public 028// License as published by the Free Software Foundation; either 029// version 2.1 of the License, or (at your option) any later version. 030// 031// This library is distributed in the hope that it will be useful, 032// but WITHOUT ANY WARRANTY; without even the implied warranty of 033// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 034// Lesser General Public License for more details. 035// 036// You should have received a copy of the GNU Lesser General Public 037// License along with this library; if not, write to the Free Software 038// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 039// 040// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 041// jataylor@hairyfatguy.com 042//------------------------------------------------------------------------------ 043 044public class PctExtinctionCoeff extends SimpleProteinProperty<SimpleProteinPropertyCalcSettings, Float> 045{ 046 private static Map<String, PctExtinctionCoeff> sUniqueMap = new HashMap<>(); 047 048 public static final PctExtinctionCoeff PROPERTY = new PctExtinctionCoeff("Pct. Extinction Coeff.", "Pct. Extinction Coefficient (ml/mg per cm) at A280"); 049 050 //########################################################################### 051 // CONSTRUCTORS 052 //########################################################################### 053 054 //--------------------------------------------------------------------------- 055 private PctExtinctionCoeff(String inName, String inDescription) 056 { 057 super(inName); 058 setDescription(inDescription); 059 060 sUniqueMap.put(inName, this); 061 } 062 063 //########################################################################### 064 // PUBLIC METHODS 065 //########################################################################### 066 067 //--------------------------------------------------------------------------- 068 public static Collection<PctExtinctionCoeff> values() 069 { 070 return sUniqueMap.values(); 071 } 072 073 //-------------------------------------------------------------------------- 074 @Override 075 public String getType() 076 { 077 return ExtinctionCoeff.TYPE; 078 } 079 080 //--------------------------------------------------------------------------- 081 public Float calculate(Protein inProtein) 082 { 083 return calculate(inProtein, null); 084 } 085 086 //--------------------------------------------------------------------------- 087 @Override 088 public Float calculate(Protein inProtein, SimpleProteinPropertyCalcSettings inSettings) 089 { 090 Float returnValue = 0.0f; 091 092 if (inProtein.length() > 0) 093 { 094 if (null == inSettings) 095 { 096 inSettings = new SimpleProteinPropertyCalcSettings(); 097 } 098 099 double value = ExtinctionCoeff.PROPERTY.getRawValue(inProtein, inSettings) / inProtein.getAverageMass(inSettings.getProteinAnalysisMode()); 100 101 // To get to 3 sig. figs. ... 102 int length = new String(value + "").length(); 103 if (length > 3) 104 { 105 BigDecimal bd = new BigDecimal(value); 106 bd = bd.round(new MathContext(3)); 107 value = bd.doubleValue(); 108 } 109 110 returnValue = (float) value; 111 } 112 113 return returnValue; 114 } 115 116}