/****************************************************************************
* Copyright (C) 2008 Peter Mortensen and Matthias Mann *
* This file is part of MSQuant. *
* *
* MSQuant is distributed under the terms of *
* the GNU General Public License. See src/COPYING.TXT or *
* <http://www.gnu.org/licenses/gpl.txt> for details. *
* *
* MSQuant is free software; you can redistribute it *
* and/or modify it under the terms of the GNU *
* General Public License as published by the Free *
* Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* MSQuant is distributed in the hope that it will be *
* useful, but WITHOUT ANY WARRANTY; without even the *
* implied warranty of MERCHANTABILITY or FITNESS FOR *
* A PARTICULAR PURPOSE. See the GNU General Public *
* License for more details. *
* *
* You should have received a copy of the GNU General *
* Public License along with MSQuant; if not, write to *
* the Free Software Foundation, Inc., 59 Temple *
* Place, Suite 330, Boston, MA 02111-1307 USA *
* *
* Purpose: Various routines for computing mass errors, *
* charge-transform, etc. *
* *
****************************************************************************/
/****************************************************************************
* CEBI *
* Software Development Group *
* Peter Mortensen *
* E-mail: NUKESPAMMERSdrmortensen@get2netZZZZZZ.dk *
* WWW: http://www.cebi.sdu.dk/ *
* *
* Program for post-processing of result from search in mass *
* spectrometric data. *
* *
* FILENAME: PILmassCalc.cs *
* TYPE: CSHARP *
* *
* CREATED: PM 2008-02-28 Vrs 1.0. *
* UPDATED: PM 2008-xx-xx *
* *
* *
****************************************************************************/
//Future:
// 1.
//
// 2.
//using System;
//using System.Collections.Generic;
//using System.Text;
//using System.Diagnostics; //For Trace. And its Assert.
// Usage: Trace.Assert((aStr != null),
// "PIL ASSERT. XYZ");
namespace massSpectrometryBase
{
//Changed PM_REFACTOR 2008-02-28. Moved from clsMolShrStruct.vb.
//Changed PM_REFACTOR 2007-09-02
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
public struct massErrorStructure
{
public double uncalibMCRError;
public double uncalibMCRRelativeError;
public double calibMCRError;
public double calibMCRRelativeError;
public double uncalibMassError;
public double uncalibMassRelativeError;
public double calibMassError;
public double calibMassRelativeError;
} //massErrorStructure
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
public class PILmassCalc
{
//****************************************************************************
//* <placeholder for header> *
//****************************************************************************
public static double chargeTransform(
double aMCRvalue, int aFromCharge, int aToCharge)
{
//Changed PM_MASS_CORRECTIONS 2008-05-20. Use official constant instead.
//const double PROTON_MASS = 1.0072627;0
//Not good: repeated somewhere
// else.
double neutralMass = aMCRvalue;
if ( aFromCharge>0)
{
neutralMass = (aMCRvalue - MSconstants.PROTON_MASS_2) * aFromCharge;
}
double toReturn = neutralMass;
if ( aToCharge>0 ) //If it is zero then we already have it and we
//avoid infinity by the division.
{
toReturn = neutralMass / aToCharge + MSconstants.PROTON_MASS_2;
}
return toReturn;
} //chargeTransform
//Changed PM_REFACTOR 2008-02-28. Moved from clsMolShrStruct.vb.
////Changed PM_REFACTOR 2007-11-19
//****************************************************************************
//* *
//* Derives various mass errors for a peptide: calibrated and *
//* uncalibrated, absolute and relative, signed and unsigned (absolute). *
//* *
//****************************************************************************
public static massErrorStructure massErrors(
double aBaseMCRValue, double anUncalibMCRValue,
double aCalibMCRValue, int aCharge)
{
massErrorStructure toReturn;
//As in old other function...
double theoMass = aBaseMCRValue;
double uncalibMCR = anUncalibMCRValue;
double calibMCR = aCalibMCRValue;
int charge = aCharge;
double ppmf = 1000000.0;
//Changed PM_REFACTOR 2008-02-28
//double uncalibMass = (uncalibMCR - PROTON_MASS) * charge;
//double calibMass = (calibMCR - PROTON_MASS) * charge;
//double theoMCR = theoMass / charge + PROTON_MASS;
double uncalibMass = chargeTransform(uncalibMCR, charge, 0);
double calibMass = chargeTransform(calibMCR, charge, 0);
double theoMCR = chargeTransform(theoMass, 0,charge); //Note: reverse.
double uncalibMCRError = uncalibMCR - theoMCR;
double calibMCRError = calibMCR - theoMCR;
double uncalibMCRRelativeError = ppmf * uncalibMCRError / theoMCR;
double calibMCRRelativeError = ppmf * calibMCRError / theoMCR;
double uncalibMassError = uncalibMass - theoMass;
double calibMassError = calibMass - theoMass;
double uncalibMassRelativeError = ppmf * uncalibMassError / theoMass;
double calibMassRelativeError = ppmf * calibMassError / theoMass;
if (true)
{
toReturn.uncalibMCRError = uncalibMCRError;
toReturn.uncalibMCRRelativeError = uncalibMCRRelativeError;
toReturn.calibMCRError = calibMCRError;
toReturn.calibMCRRelativeError = calibMCRRelativeError;
toReturn.uncalibMassError = uncalibMassError;
toReturn.uncalibMassRelativeError = uncalibMassRelativeError;
toReturn.calibMassError = calibMassError;
toReturn.calibMassRelativeError = calibMassRelativeError;
}
return toReturn;
} //massErrors
} //class PILmassCalc
} //namespace massSpectrometryBase
Generated by script codePublish.pl at 2008-09-23T11:59:18.