Пример #1
0
        public void TestFitMinusOneScore(int precursor, string adduct, string commonName, string id, string rawFilePath)
        {
            var lipid = new Lipid()
            {
                AdductFull = adduct, CommonName = commonName
            };
            var lipidTarget = lipid.CreateLipidTarget();

            var composition = lipidTarget.Composition;
            var compMinus1  = new Composition(composition.C, composition.H - 1, composition.N, composition.O, composition.S, composition.P); //Subtract one hydrogen to make this a minus1 fit score

            var lcmsRun = PbfLcMsRun.GetLcMsRun(rawFilePath);

            var spectrum = lcmsRun.GetSpectrum(precursor);

            var relativeIntensityThreshold = 0.1;

            var tolerance = new Tolerance(30, ToleranceUnit.Ppm);

            //Get the values to use to calculate pearson correlation
            var observedPeaks = LipidUtil.GetAllIsotopePeaks(spectrum, compMinus1, tolerance,
                                                             relativeIntensityThreshold);

            if (observedPeaks == null)
            {
                Console.WriteLine("Observed peaks is null for scan " + id);
            }

            var isotopomerEnvelope = IsoProfilePredictor.GetIsotopomerEnvelop(
                compMinus1.C,
                compMinus1.H,
                compMinus1.N,
                compMinus1.O,
                compMinus1.S);

            var observedIntensities = new double[observedPeaks.Length];

            for (var i = 0; i < observedPeaks.Length; i++)
            {
                var observedPeak = observedPeaks[i];
                observedIntensities[i] = observedPeak != null ? (float)observedPeak.Intensity : 0.0;
            }

            Console.WriteLine("The theoretical y values are: ");
            foreach (var value in isotopomerEnvelope.Envolope)
            {
                Console.WriteLine(value + ", ");
            }

            Console.WriteLine("The observed peak intensity x values are: ");
            foreach (var value in observedIntensities)
            {
                Console.WriteLine(value + ", ");
            }
        }