Proteome Informatics Group > Java Proteomic Library
 

Mass Calculators

Specific Accuracy Mass Calculators

An instance of Mass Calculator computes or extracts masses from molecules given as parameters.

There are only three instances of this class callable from static factory methods:

  • JPLMassCalculator.getMonoAccuracyInstance() computes mass at monoisotopic accuracy.
  • JPLMassCalculator.getAvgAccuracyInstance() computes mass at average accuracy.
  • JPLMassCalculator.getContextInstance() computes mass given the accuracy contextually defined in the chemical.

The two first static methods force and impose the accuracy and the third one is context dependant. It depends only on the chemicals to evaluate.

	// implicit monoisotopic context
	JPLIMolecule methane = JPLChemicalFacade.getMolecule("CH4");

	JPLMassCalculator monoMassCalc =
	    JPLMassCalculator.getMonoAccuracyInstance();

	JPLMassCalculator avgMassCalc =
            JPLMassCalculator.getAvgAccuracyInstance();

	JPLMassCalculator contextualMassCalc =
            JPLMassCalculator.getContextAccuracyInstance();

        monoMassCalc.getMass(methane);
	avgMassCalc.getMass(methane);

	// the default mass calculator
	Assert.assertEquals(monoMassCalc.getMass(methane), 
	   contextualMassCalc.getMass(methane));
      
Note
In the above example, methane has been defined in a monoisotopic mass context. Then getting the methanes'mass with the average instance of calculator lead to internally create another instance of JPLIMolecule composed this time of atoms and not isotopes. See this page for more informations.

Get Mass Internally

getMass(JPLIMolecule molec) method has an interesting behavior depending on the accuracy context:

When the given molecule has an internal accuracy different from the calculator, another instance of molecule is created or get from the molecular pool.

	JPLIMolecule methane = JPLChemicalFacade.getMolecule("CH4");

        JPLMassCalculator avgMassCalc =
            JPLMassCalculator.getAvgAccuracyInstance();

	avgMassCalc.getMass(methane);
      
Note
<CH4> has been instanciated internally in getMass(JPLIMolecule molec) method.

Bio-Sequence Mass Calculators

A Mass calculator can compute mass of all class implementing JPLBioSeq<JPLIMolecule>.