/// <summary> /// joins the spectra formed by the isotopes of n elements /// </summary> /// <param name="ItPeaks">(double[elements,kmax]) spectra of the elements</param> /// <returns>(double[]) sum spectrum of the n elements</returns> private static mzI[] joinIsot(double[,] ItPeaks, double thPrecMass) { int bound = ItPeaks.GetUpperBound(1); int bound2 = ItPeaks.GetUpperBound(0); // massShift was: mass shift from each peak to the next peak // currently, as most experiments analysed by QuiXoT are 18O, // it is set to deltaR/2, where deltaR is the difference between // 16O and 16O double massShift = 2.00424578 / 2; mzI[] sum = new mzI[bound + 1]; mzI[] jIsot = new mzI[bound + 1]; //Initialize the matrix sum with the first value of the matrix ItPeaks for (int i = 0; i <= bound; i++) { sum[i].I = ItPeaks[0, i]; sum[i].mz = thPrecMass + i * massShift; } //Join the spectra in the matrix sum if (ItPeaks.GetUpperBound(0) > 1) { for (int numSpectra = 1; numSpectra <= bound2; numSpectra++) { for (int i = 0; i <= bound; i++) { for (int j = 0; j <= bound; j++) { if ((i + j) <= bound) { jIsot[i + j].I += sum[i].I * ItPeaks[numSpectra, j]; jIsot[i + j].mz = thPrecMass + (i * massShift + j); } } } jIsot.CopyTo(sum, 0); if (numSpectra < bound2) { jIsot = null; jIsot = new mzI[bound + 1]; } } } return(jIsot); }
/// <summary> /// joins the spectra formed by the isotopes of n elements /// </summary> /// <param name="ItPeaks">(double[elements,kmax]) spectra of the elements</param> /// <returns>(double[]) sum spectrum of the n elements</returns> private static mzI[] joinIsot(double[,] ItPeaks, double thPrecMass) { int bound = ItPeaks.GetUpperBound(1); int bound2 = ItPeaks.GetUpperBound(0); double massShift = 1.003; mzI[] sum = new mzI[bound + 1]; mzI[] jIsot = new mzI[bound + 1]; //Initialize the matrix sum with the first value of the matrix ItPeaks for (int i = 0; i <= bound; i++) { sum[i].I = ItPeaks[0, i]; sum[i].mz = thPrecMass + i * massShift; } //Join the spectra in the matrix sum if (ItPeaks.GetUpperBound(0) > 1) { for (int numSpectra = 1; numSpectra <= bound2; numSpectra++) { for (int i = 0; i <= bound; i++) { for (int j = 0; j <= bound; j++) { if ((i + j) <= bound) { jIsot[i + j].I += sum[i].I * ItPeaks[numSpectra, j]; jIsot[i + j].mz = thPrecMass + (i * massShift + j); } } } jIsot.CopyTo(sum, 0); if (numSpectra < bound2) { jIsot = null; jIsot = new mzI[bound + 1]; } } } return(jIsot); }
public static ArrayList calIntensitiesAveragine(double MHplus, int charge, double calibrationError) { ArrayList spectrums = new ArrayList(); mzI[] resultSpectrum = new mzI[5]; //double[] I = new double[5]; double protonMass = 1.007276466812; // source: http://physics.nist.gov/cgi-bin/cuu/Value?mpu // massShift was: mass shift from each peak to the next peak // currently, as most experiments analysed by QuiXoT are 18O, // it is set to deltaR/2, where deltaR is the difference between // 16O and 16O double massShift = 2.00424578 / 2; double M = MHplus - protonMass; double y0 = -0.01709; double A0 = 2 * 0.50059; double t0 = 1767.46064; double A1_0 = 0.0347; double A1_1 = 4.78949e-4; double A1_2 = -2.5366e-7; double A1_3 = 5.44242e-11; double A1_4 = -4.67415e-15; double A2_0 = -0.02581; double A2_1 = 1.18353e-4; double A2_2 = 3.05798e-8; double A2_3 = -1.95685e-11; double A2_4 = 2.18143e-15; double A3_0 = 0.01197; double A3_1 = -3.95885e-5; double A3_2 = 7.06503e-8; double A3_3 = -1.77963e-11; double A3_4 = 1.41202e-15; double A4_0 = 0.0107; double A4_1 = -2.85332e-5; double A4_2 = 2.6899e-8; double A4_3 = -3.7105e-12; double A4_4 = 1.98749e-16; // I0 = y0+A0*exp(-M/t0) // Ii = A1_0 + A1_1 * M + A1_2 * M^2 + A1_3 * M^3 + A1_4 * M^4 resultSpectrum[0].I = y0 + A0 * Math.Exp(-M / t0); resultSpectrum[1].I = A1_0 + A1_1 * M + A1_2 * M * M + A1_3 * M * M * M + A1_4 * M * M * M * M; resultSpectrum[2].I = A2_0 + A2_1 * M + A2_2 * M * M + A2_3 * M * M * M + A2_4 * M * M * M * M; resultSpectrum[3].I = A3_0 + A3_1 * M + A3_2 * M * M + A3_3 * M * M * M + A3_4 * M * M * M * M; resultSpectrum[4].I = A4_0 + A4_1 * M + A4_2 * M * M + A4_3 * M * M * M + A4_4 * M * M * M * M; //Correction by Mass to precursor mass --> monoisotopic mass int correctionByMass = 0; double maxI = 0; for (int i = 0; i < 5; i++) { if (resultSpectrum[i].I > maxI) { maxI = resultSpectrum[i].I; correctionByMass = i; } } int secondMostIntense = 0; double secMaxI = 0; for (int i = 0; i < 5; i++) { if (resultSpectrum[i].I > secMaxI && i != correctionByMass) { secMaxI = resultSpectrum[i].I; secondMostIntense = i; } } resultSpectrum[0].mz = -calibrationError + (M + charge * protonMass - massShift * correctionByMass) / charge; for (int i = 1; i < 5; i++) { resultSpectrum[i].mz = resultSpectrum[0].mz + i * massShift / charge; } spectrums.Add(resultSpectrum.Clone()); //uncertainty region for the monoisotopic mass determination //We solve it by proposing several monoisotopic masses, and testing them by fitting & weighting the results if (Math.Abs(maxI - secMaxI) <= 0.1) { resultSpectrum[0].mz = -calibrationError + (M + charge * protonMass - massShift * secondMostIntense) / charge; for (int i = 1; i < 5; i++) { resultSpectrum[i].mz = resultSpectrum[0].mz + i * massShift / charge; } spectrums.Add(resultSpectrum.Clone()); } return(spectrums); }