Package org.biojava.bio.proteomics
Class MassCalc
- java.lang.Object
-
- org.biojava.bio.proteomics.MassCalc
-
public class MassCalc extends Object
MassCalc
calculates the mass of peptides which for our purposes areSymbolList
s which containSymbol
sfrom the proteinAlphabet
. It uses the mono-isotopic and average-isotopic masses identical to those specified at www.micromass.co.uk Note: This class does not handle selenocysteine and pyrrolysine.- Author:
- M. Jones sdfsd, Keith James (minor changes), Mark Schreiber, George Waldon - getMolecularWeight
-
-
Field Summary
Fields Modifier and Type Field Description static double
Cavg
Constant value of Carbon average massstatic double
Cmono
Constant value of Carbon monoisotopic massstatic double
Havg
Constant value of Hydrogen average massstatic double
Hmono
Constant value of Hydrogen monoisotopic massstatic double
Navg
Constant value of Nitrogen average massstatic double
Nmono
Constant value of Nitrogen monoisotopic massstatic double
Oavg
Constant value of Oxygen average massstatic double
Omono
Constant value of Oxygen monoisotopic mass
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addVariableModification(char residue, double[] masses)
Add Variable modifications.void
addVariableModification(Symbol residue, double[] masses)
Add Variable modifications.double
getMass(SymbolList proteinSeq)
Get the Mass of this peptide.static double
getMass(SymbolList proteinSeq, String isotopicType, boolean MH_PLUS)
getMass
calculates the mass of this peptide.static double
getMolecularWeight(SymbolList proteinSeq)
Calculate the molecular weight of a protein, making estimates whenever it is possible like averaging mass values for ambiguity symbols or counting zero when gaps are encountered.double
getTermMass()
getTermMass
returns the terminal mass being used by the instance methods.double[]
getVariableMasses(SymbolList peptide)
Get all masses including the variable mass.boolean
removeVariableModifications(char residue)
Remove all variable modifications assocaited with this residue.boolean
removeVariableModifications(Symbol residue)
Remove all variable modifications assocaited with this residue.void
setSymbolModification(char symbolToken, double mass)
Use this to set a post translational modification for theSymbol
represented by this character.
-
-
-
Field Detail
-
Cmono
public static final double Cmono
Constant value of Carbon monoisotopic mass- See Also:
- Constant Field Values
-
Hmono
public static final double Hmono
Constant value of Hydrogen monoisotopic mass- See Also:
- Constant Field Values
-
Nmono
public static final double Nmono
Constant value of Nitrogen monoisotopic mass- See Also:
- Constant Field Values
-
Omono
public static final double Omono
Constant value of Oxygen monoisotopic mass- See Also:
- Constant Field Values
-
Cavg
public static final double Cavg
Constant value of Carbon average mass- See Also:
- Constant Field Values
-
Havg
public static final double Havg
Constant value of Hydrogen average mass- See Also:
- Constant Field Values
-
Navg
public static final double Navg
Constant value of Nitrogen average mass- See Also:
- Constant Field Values
-
Oavg
public static final double Oavg
Constant value of Oxygen average mass- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MassCalc
public MassCalc(String isotopicType, boolean MH_PLUS)
Creates a newMassCalc
.- Parameters:
isotopicType
- aString
. The type of isotopes to calculate. Either mono isotopic or average isotopic. Acceptable values areSymbolPropertyTable.AVG_MASS
orSymbolPropertyTable.MONO_MASS
.MH_PLUS
- aboolean
.
-
-
Method Detail
-
setSymbolModification
public void setSymbolModification(char symbolToken, double mass) throws IllegalSymbolException
Use this to set a post translational modification for theSymbol
represented by this character. It will only affect the currentMassCalc
instance and will not affect the static method.- Parameters:
symbolToken
- achar
representing aSymbol
.mass
- adouble
to be the new mass of the residue.- Throws:
IllegalSymbolException
- if theSymbol
is not recognised.
-
addVariableModification
public void addVariableModification(char residue, double[] masses) throws IllegalSymbolException
Add Variable modifications. If multiple masses are set by this method more then one mass will be returned for a mass calculation. For example if a peptide contains two Mets and the user sets the native and oxidized mass for the Met then the masses returned will be of the peptide with 0, 1 and 2 modified Mets.- Parameters:
residue
- The one char id for this residuemasses
-- Throws:
IllegalSymbolException
- See Also:
getVariableMasses(SymbolList peptide)
,addVariableModification(Symbol residue,double[] masses)
-
addVariableModification
public void addVariableModification(Symbol residue, double[] masses) throws IllegalSymbolException
Add Variable modifications. If multiple masses are set by this method more then one mass will be returned for a mass calculation. For example if a peptide contains two Mets and the user sets the native and oxidized mass for the Met then the masses returned will be of the peptide with 0, 1 and 2 modified Mets.- Throws:
IllegalSymbolException
-
removeVariableModifications
public boolean removeVariableModifications(char residue) throws IllegalSymbolException
Remove all variable modifications assocaited with this residue.- Throws:
IllegalSymbolException
-
removeVariableModifications
public boolean removeVariableModifications(Symbol residue)
Remove all variable modifications assocaited with this residue.
-
getMolecularWeight
public static final double getMolecularWeight(SymbolList proteinSeq) throws IllegalSymbolException
Calculate the molecular weight of a protein, making estimates whenever it is possible like averaging mass values for ambiguity symbols or counting zero when gaps are encountered. The method is tolerant for ambiguity symbols as long as they can be resolved to a series of atomic symbols whose mass is available in the ResidueProperties.xml configuration file or they are gaps. The method returns the same value as getMass(SymbolList proteinSeq, SymbolPropertyTable.AVG_MASS, false) when only atomic symbols are found in the polypeptide.- Throws:
IllegalSymbolException
- Since:
- 1.5
-
getMass
public static final double getMass(SymbolList proteinSeq, String isotopicType, boolean MH_PLUS) throws IllegalSymbolException
getMass
calculates the mass of this peptide. This only works for the values in the ResidueProperties.xml configuration file. It is probably slightly faster than the instance method, but it does not handle post-translational modifications.- Parameters:
proteinSeq
- aSymbolList
whose mass is to be calculated. This should use the protein alphabet.isotopicType
- aString
The type of isotopes to calculate. Either mono isotopic or average isotopic. Acceptable values areSymbolPropertyTable.AVG_MASS
orSymbolPropertyTable.MONO_MASS
.MH_PLUS
- aboolean
true if the value needed is the MH+ mass.- Returns:
- a
double
mass of the peptide. - Throws:
IllegalSymbolException
- if theSymbolList
contains illegalSymbol
s.
-
getMass
public double getMass(SymbolList proteinSeq) throws IllegalSymbolException
Get the Mass of this peptide. Use this if you want to set fixed modifications and have created an instance of MassCalc. The value is calculated using the value of MH_PLUS defined in the constructor. The static method may be faster.- Parameters:
proteinSeq
- The sequence for mass calculation- Returns:
- The mass of the sequence
- Throws:
IllegalSymbolException
-
getVariableMasses
public double[] getVariableMasses(SymbolList peptide) throws IllegalSymbolException
Get all masses including the variable mass. Allgorythm 1 Get the first residue of the sequence create a list of all the standard and non-standard massses for this reidue for each residue mass goto 1 with the sequence of all residues after the current residue add the residue mass to each mass from 1 to the list- Throws:
IllegalSymbolException
- See Also:
addVariableModification(char, double[])
-
getTermMass
public double getTermMass()
getTermMass
returns the terminal mass being used by the instance methods.- Returns:
- a
double
mass.
-
-