Ejemplo n.º 1
0
        public void TestPPMConversion(double massToConvert, double currentMz, double expectedPPM)
        {
            var convertedPPM = PeptideMassCalculator.MassToPPM(massToConvert, currentMz);

            var reconvertedMass = PeptideMassCalculator.PPMToMass(convertedPPM, currentMz);

            Console.WriteLine("DelM of {0} Da converts to {1:F5} ppm at {2:F5} m/z ", massToConvert, convertedPPM, currentMz);

            Assert.AreEqual(expectedPPM, convertedPPM, 0.0001, "PPM Conversion error");

            Assert.AreEqual(massToConvert, reconvertedMass, 1E-05, "Da to PPM to Da round trip error");
        }
Ejemplo n.º 2
0
        private static string GetCorrectedMassErrorPPM(PSM psm, out int intIsotopeError)
        {
            const double MASS_C13 = 1.00335483;

            double dblMassErrorPPM = 0;

            intIsotopeError = 0;

            if (double.TryParse(psm.MassErrorDa, out var dblDelM))
            {
                // Examine dblDelM to determine which isotope was chosen
                if (dblDelM >= -0.5)
                {
                    // This is the typical case
                    while (dblDelM > 0.5)
                    {
                        dblDelM         -= MASS_C13;
                        intIsotopeError += 1;
                    }
                }
                else
                {
                    // This happens less often; but we'll still account for it
                    // In this case, intCorrectionCount will be negative
                    while (dblDelM < -0.5)
                    {
                        dblDelM         += MASS_C13;
                        intIsotopeError -= 1;
                    }
                }

                dblMassErrorPPM = PeptideMassCalculator.MassToPPM(dblDelM, psm.PrecursorNeutralMass);
            }

            return(dblMassErrorPPM.ToString("0.0000"));
        }