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