com.compomics.util.general
Class MassCalc

java.lang.Object
  extended by com.compomics.util.general.MassCalc

public class MassCalc
extends java.lang.Object

This class takes care of mass calculation, based on a sequence in IUPAC format.
By default it can handle monoisotopic biochemical element masses and monoisotopic single-letter amino acid masses.
The object can be customized with your own mass lists through the use of a properties file, or by directly passing a HashMap.

Please note: if you decide on your own lists, be sure to follow the following guidelines:

Author:
Lennart Martens

Field Summary
static int MONOAA
          Index for the monoisotopic aminoacid masses.
static int MONOELEMENTS
          Index for the monoisotopic masses of the biochemically relevant elements.
static int MONONUCLEOTIDES
          Index for the monoisotopic nucleotide masses.
static int SELFDEFINED
          Value for the self-defined masses.
 
Constructor Summary
MassCalc()
          Default constructor.
MassCalc(java.util.HashMap aElementList)
          This constructor allows the caller to initialize the elementlist with a HashMap of its own design.
MassCalc(int aMassListIdentifier)
          This constructor allows you to specify an identifier to select a element list to use for calculating a mass.
MassCalc(int aMassListIdentifier, java.util.HashMap aSupplElementList)
          This constructor allows the caller to supplement (or to replace elements in) a built-in elementlist with a HashMap of its own design.
MassCalc(java.lang.String aFilename)
          This constructor allows the caller to use an elementlist of its own making.
 
Method Summary
 double calculateMass(java.lang.String aFormula)
          This method attempts to calculate the mass of a chemical formula.
static void main(java.lang.String[] args)
          The main method can be used for command-line usage of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MONOELEMENTS

public static final int MONOELEMENTS
Index for the monoisotopic masses of the biochemically relevant elements.

See Also:
Constant Field Values

MONOAA

public static final int MONOAA
Index for the monoisotopic aminoacid masses.

See Also:
Constant Field Values

MONONUCLEOTIDES

public static final int MONONUCLEOTIDES
Index for the monoisotopic nucleotide masses.

See Also:
Constant Field Values

SELFDEFINED

public static final int SELFDEFINED
Value for the self-defined masses.

See Also:
Constant Field Values
Constructor Detail

MassCalc

public MassCalc()
Default constructor. The mass list to be used defaults to the monoisotopic masses for biochemically relevant elements.


MassCalc

public MassCalc(int aMassListIdentifier)
This constructor allows you to specify an identifier to select a element list to use for calculating a mass.
Please use the finalo vriables on this class as identifiers!

Parameters:
aMassListIdentifier - int with the identifier for the elementlist to use.

MassCalc

public MassCalc(java.lang.String aFilename)
This constructor allows the caller to use an elementlist of its own making. Simply passing the filename of the file suffices.

Parameters:
aFilename - String with the name of the file to be loaded. NOTE! this file must be located in the classpath and mst be a simple properties file!

MassCalc

public MassCalc(java.util.HashMap aElementList)
This constructor allows the caller to initialize the elementlist with a HashMap of its own design.
This HashMap needs be structured in the following way:

Parameters:
aElementList - HashMap with the elementlist to use.

MassCalc

public MassCalc(int aMassListIdentifier,
                java.util.HashMap aSupplElementList)
This constructor allows the caller to supplement (or to replace elements in) a built-in elementlist with a HashMap of its own design.
This HashMap needs be structured in the following way:

Parameters:
aMassListIdentifier - int with the identifier for the built-in elementlist to use.
aSupplElementList - HashMap with the supplementary elementlist to use.
Method Detail

calculateMass

public double calculateMass(java.lang.String aFormula)
                     throws UnknownElementMassException
This method attempts to calculate the mass of a chemical formula. It cannot calculate the mass of an element if it is not known to this class (i.e.: if it does not occur in the Properties instance). In that case it will flag an exception.

Parameters:
aFormula - String with the chemical formula (or bruto formula) of the compound in question.
Returns:
double with the mass of the compound.
Throws:
UnknownElementMassException - when one of the composing elements' mass is unknown to the class.

main

public static void main(java.lang.String[] args)
The main method can be used for command-line usage of this class. The parameters should be (a) chemical (or bruto) formula(e) to calculate the mass for.

Parameters:
args - String[] at least one chemical formula should be specified, up to as much as you can cramp into a single command-line.


Copyright © 2012. All Rights Reserved.