Example #1
0
        public static void TestFlashLfq()
        {
            // get the raw file paths
            SpectraFileInfo raw  = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"), "a", 0, 0, 0);
            SpectraFileInfo mzml = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"), "a", 0, 1, 0);

            // create some PSMs
            var            pg  = new ProteinGroup("MyProtein", "gene", "org");
            Identification id1 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });
            Identification id2 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <ProteinGroup> {
                pg
            });
            Identification id3 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });
            Identification id4 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <ProteinGroup> {
                pg
            });

            // create the FlashLFQ engine
            FlashLFQEngine engine = new FlashLFQEngine(new List <Identification> {
                id1, id2, id3, id4
            }, normalize: true);

            // run the engine
            var results = engine.Run();

            // check raw results
            Assert.That(results.Peaks[raw].Count == 1);
            Assert.That(results.Peaks[raw].First().Intensity > 0);
            Assert.That(!results.Peaks[raw].First().IsMbrFeature);
            Assert.That(results.PeptideBaseSequences["EGFQVADGPLYR"].GetIntensity(raw) > 0);
            Assert.That(results.PeptideModifiedSequences["EGFQVADGPLYR"].GetIntensity(raw) > 0);
            Assert.That(results.ProteinGroups["MyProtein"].GetIntensity(raw) > 0);

            // check mzml results
            Assert.That(results.Peaks[mzml].Count == 1);
            Assert.That(results.Peaks[mzml].First().Intensity > 0);
            Assert.That(!results.Peaks[mzml].First().IsMbrFeature);
            Assert.That(results.PeptideBaseSequences["EGFQVADGPLYR"].GetIntensity(mzml) > 0);
            Assert.That(results.PeptideModifiedSequences["EGFQVADGPLYR"].GetIntensity(mzml) > 0);
            Assert.That(results.ProteinGroups["MyProtein"].GetIntensity(mzml) > 0);

            // check that condition normalization worked
            int int1 = (int)System.Math.Round(results.Peaks[mzml].First().Intensity, 0);
            int int2 = (int)System.Math.Round(results.Peaks[raw].First().Intensity, 0);

            Assert.That(int1 == int2);

            // test peak output
            results.WriteResults(
                Path.Combine(TestContext.CurrentContext.TestDirectory, @"peaks.tsv"),
                Path.Combine(TestContext.CurrentContext.TestDirectory, @"modSeq.tsv"),
                Path.Combine(TestContext.CurrentContext.TestDirectory, @"baseSeq.tsv"),
                Path.Combine(TestContext.CurrentContext.TestDirectory, @"protein.tsv"));
        }
Example #2
0
        public static void TestPeakSplittingRight()
        {
            string fileToWrite = "myMzml.mzML";
            string peptide     = "PEPTIDE";
            double intensity   = 1e6;

            Loaders.LoadElements(Path.Combine(TestContext.CurrentContext.TestDirectory, @"elements.dat"));

            // generate mzml file

            // 1 MS1 scan per peptide
            MsDataScan[] scans = new MsDataScan[10];
            double[]     intensityMultipliers = { 1, 3, 5, 10, 5, 3, 1, 1, 3, 1 };

            for (int s = 0; s < scans.Length; s++)
            {
                ChemicalFormula      cf          = new Proteomics.AminoAcidPolymer.Peptide(peptide).GetChemicalFormula();
                IsotopicDistribution dist        = IsotopicDistribution.GetDistribution(cf, 0.125, 1e-8);
                double[]             mz          = dist.Masses.Select(v => v.ToMz(1)).ToArray();
                double[]             intensities = dist.Intensities.Select(v => v * intensity * intensityMultipliers[s]).ToArray();

                // add the scan
                scans[s] = new MsDataScan(massSpectrum: new MzSpectrum(mz, intensities, false), oneBasedScanNumber: s + 1, msnOrder: 1, isCentroid: true,
                                          polarity: Polarity.Positive, retentionTime: 1.0 + s / 10.0, scanWindowRange: new MzRange(400, 1600), scanFilter: "f",
                                          mzAnalyzer: MZAnalyzerType.Orbitrap, totalIonCurrent: intensities.Sum(), injectionTime: 1.0, noiseData: null, nativeId: "scan=" + (s + 1));
            }

            // write the .mzML
            IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(new FakeMsDataFile(scans),
                                                                          Path.Combine(TestContext.CurrentContext.TestDirectory, fileToWrite), false);

            // set up spectra file info
            SpectraFileInfo file1 = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, fileToWrite), "", 0, 0, 0);

            // create some PSMs
            var pg = new ProteinGroup("MyProtein", "gene", "org");

            Identification id1 = new Identification(file1, peptide, peptide,
                                                    new Proteomics.AminoAcidPolymer.Peptide(peptide).MonoisotopicMass, 1.3 + 0.001, 1, new List <ProteinGroup> {
                pg
            });

            // create the FlashLFQ engine
            FlashLFQEngine engine = new FlashLFQEngine(new List <Identification> {
                id1
            });

            // run the engine
            var results = engine.Run();
            ChromatographicPeak peak = results.Peaks.First().Value.First();

            Assert.That(peak.Apex.RetentionTime == 1.3);
            Assert.That(peak.SplitRT == 1.6);
            Assert.That(!peak.IsotopicEnvelopes.Any(p => p.RetentionTime > 1.6));
            Assert.That(peak.IsotopicEnvelopes.Count == 6);
        }
Example #3
0
        private void changeSettingsMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new SettingsWindow();

            dialog.PopulateSettings(flashLfqEngine);

            if (dialog.ShowDialog() == true)
            {
                flashLfqEngine = dialog.TempFlashLfqEngine;
            }
        }
Example #4
0
        public void PopulateSettings(FlashLFQEngine engine)
        {
            normalize.IsChecked            = engine.Normalize;
            ppmTolerance.Text              = engine.PpmTolerance.ToString(CultureInfo.InvariantCulture);
            mbr.IsChecked                  = engine.MatchBetweenRuns;
            advancedProteinQuant.IsChecked = engine.AdvancedProteinQuant;

            integrate.IsChecked               = engine.Integrate;
            precursorChargeOnly.IsChecked     = engine.IdSpecificChargeState;
            requireMonoisotopicPeak.IsChecked = engine.RequireMonoisotopicMass;
            isotopeTolerance.Text             = engine.IsotopePpmTolerance.ToString(CultureInfo.InvariantCulture);
            numIsotopePeak.Text               = engine.NumIsotopesRequired.ToString();
            maxMbrWindow.Text = engine.MbrRtWindow.ToString(CultureInfo.InvariantCulture);
        }
Example #5
0
        private void RunFlashLfq()
        {
            // read IDs
            var ids = new List <Identification>();

            foreach (var identFile in identFilesForDataGrid)
            {
                ids = ids.Concat(PsmReader.ReadPsms(identFile.FilePath, false, spectraFileInfo)).ToList();
            }

            // run FlashLFQ engine
            try
            {
                flashLfqEngine = new FlashLFQEngine(
                    allIdentifications: ids,
                    normalize: flashLfqEngine.Normalize,
                    ppmTolerance: flashLfqEngine.PpmTolerance,
                    isotopeTolerancePpm: flashLfqEngine.IsotopePpmTolerance,
                    matchBetweenRuns: flashLfqEngine.MatchBetweenRuns,
                    matchBetweenRunsPpmTolerance: flashLfqEngine.MbrPpmTolerance,
                    integrate: flashLfqEngine.Integrate,
                    numIsotopesRequired: flashLfqEngine.NumIsotopesRequired,
                    idSpecificChargeState: flashLfqEngine.IdSpecificChargeState,
                    requireMonoisotopicMass: flashLfqEngine.RequireMonoisotopicMass,
                    silent: false,
                    optionalPeriodicTablePath: null,
                    maxMbrWindow: flashLfqEngine.MbrRtWindow,
                    advancedProteinQuant: flashLfqEngine.AdvancedProteinQuant);

                results = flashLfqEngine.Run();
            }
            catch (Exception ex)
            {
                MessageBox.Show("FlashLFQ has crashed with the following error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
            }

            // write output
            try
            {
                OutputWriter.WriteOutput(Directory.GetParent(spectraFileInfo.First().FullFilePathWithExtension).FullName, results, outputFolderPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not write FlashLFQ output: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
            }
        }
Example #6
0
        public MainWindow()
        {
            InitializeComponent();

            spectraFilesForDataGrid = new ObservableCollection <SpectraFileForDataGrid>();
            identFilesForDataGrid   = new ObservableCollection <IdentificationFileForDataGrid>();
            worker         = new BackgroundWorker();
            worker.DoWork += new DoWorkEventHandler(RunProgram);

            flashLfqEngine  = new FlashLFQEngine(new List <Identification>());
            spectraFileInfo = new List <SpectraFileInfo>();

            identFilesDataGrid.DataContext   = identFilesForDataGrid;
            dataGridSpectraFiles.DataContext = spectraFilesForDataGrid;

            var _writer = new TextBoxWriter(notificationsTextBox);

            Console.SetOut(_writer);
        }
Example #7
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckForValidEntries())
            {
                return;
            }

            TempFlashLfqEngine = new FlashLFQEngine(new List <Identification>(),
                                                    advancedProteinQuant: advancedProteinQuant.IsChecked.Value,
                                                    normalize: normalize.IsChecked.Value,
                                                    ppmTolerance: double.Parse(ppmTolerance.Text),
                                                    matchBetweenRuns: mbr.IsChecked.Value,
                                                    integrate: integrate.IsChecked.Value,
                                                    idSpecificChargeState: precursorChargeOnly.IsChecked.Value,
                                                    requireMonoisotopicMass: requireMonoisotopicPeak.IsChecked.Value,
                                                    isotopeTolerancePpm: double.Parse(isotopeTolerance.Text),
                                                    numIsotopesRequired: int.Parse(numIsotopePeak.Text),
                                                    maxMbrWindow: double.Parse(maxMbrWindow.Text));

            DialogResult = true;
        }
Example #8
0
        public static void TestFlashLFQ()
        {
            // get the raw file paths
            RawFileInfo raw  = new RawFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"));
            RawFileInfo mzml = new RawFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"));

            // create some PSMs
            Identification id1 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <string> {
                "MyProtein"
            });
            Identification id2 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <string> {
                "MyProtein"
            });
            Identification id3 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <string> {
                "MyProtein"
            });
            Identification id4 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <string> {
                "MyProtein"
            });

            // create the FlashLFQ engine
            FlashLFQEngine engine = new FlashLFQEngine(new List <Identification> {
                id1, id2, id3, id4
            });

            // run the engine
            var results = engine.Run();

            // check raw results
            Assert.That(results.peaks[raw].Count == 1);
            Assert.That(results.peaks[raw].First().intensity > 0);
            Assert.That(!results.peaks[raw].First().isMbrFeature);
            Assert.That(results.peptideBaseSequences["EGFQVADGPLYR"].intensities[raw] > 0);
            Assert.That(results.peptideModifiedSequences["EGFQVADGPLYR"].intensities[raw] > 0);
            Assert.That(results.proteinGroups["MyProtein"].intensities[raw] > 0);

            // check mzml results
            Assert.That(results.peaks[mzml].Count == 1);
            Assert.That(results.peaks[mzml].First().intensity > 0);
            Assert.That(!results.peaks[mzml].First().isMbrFeature);
            Assert.That(results.peptideBaseSequences["EGFQVADGPLYR"].intensities[mzml] > 0);
            Assert.That(results.peptideModifiedSequences["EGFQVADGPLYR"].intensities[mzml] > 0);
            Assert.That(results.proteinGroups["MyProtein"].intensities[mzml] > 0);

            // test peak output
            List <string> output = new List <string>()
            {
                FlashLFQ.ChromatographicPeak.TabSeparatedHeader
            };

            foreach (var peak in results.peaks.SelectMany(p => p.Value))
            {
                output.Add(peak.ToString());
            }
            Assert.That(output.Count == 3);

            // test peptide base sequence output
            output = new List <string>()
            {
                Peptide.TabSeparatedHeader
            };
            foreach (var pep in results.peptideBaseSequences)
            {
                output.Add(pep.Value.ToString());
            }
            Assert.That(output.Count == 2);

            // test peptide mod sequence output
            output = new List <string>()
            {
                Peptide.TabSeparatedHeader
            };
            foreach (var pep in results.peptideModifiedSequences)
            {
                output.Add(pep.Value.ToString());
            }
            Assert.That(output.Count == 2);

            // test protein output
            output = new List <string>()
            {
                ProteinGroup.TabSeparatedHeader
            };
            foreach (var protein in results.proteinGroups)
            {
                output.Add(protein.Value.ToString());
            }
            Assert.That(output.Count == 2);
        }
Example #9
0
        public static void TestExternalNoPassedFile()
        {
            Console.WriteLine("UNIT TEST - Entering unit test");
            string[] filePaths = Directory.GetFiles(TestContext.CurrentContext.TestDirectory).Where(f => f.Substring(f.IndexOf('.')).ToUpper().Equals(".RAW") || f.Substring(f.IndexOf('.')).ToUpper().Equals(".MZML")).ToArray();
            string   elements  = Path.Combine(TestContext.CurrentContext.TestDirectory, "elements.dat");
            string   ident     = Path.Combine(TestContext.CurrentContext.TestDirectory, "aggregatePSMs_5ppmAroundZero.psmtsv");

            FlashLFQEngine engine = new FlashLFQEngine();

            Console.WriteLine("UNIT TEST - About to load elements");
            Loaders.LoadElements(elements);
            Console.WriteLine("UNIT TEST - Finished loading elements");

            engine.PassFilePaths(filePaths);
            Assert.That(engine.ParseArgs(new string[] {
                "--ppm 5",
                "--sil false",
                "--pau false",
                "--mbr true"
            }
                                         ));
            Console.WriteLine("UNIT TEST - Done making engine");
            engine.globalStopwatch.Start();
            engine.SetParallelization(1);

            Console.WriteLine("UNIT TEST - Adding identifications");
            var ids       = File.ReadAllLines(ident);
            int lineCount = 1;

            foreach (var line in ids)
            {
                if (lineCount != 1)
                {
                    var splitLine = line.Split('\t');
                    engine.AddIdentification(Path.GetFileNameWithoutExtension(splitLine[0]), splitLine[20], splitLine[21], double.Parse(splitLine[27]), double.Parse(splitLine[2]), (int)double.Parse(splitLine[6]), new List <string> {
                        splitLine[14]
                    });
                }
                lineCount++;
            }
            Console.WriteLine("UNIT TEST - Finished adding IDs");

            engine.ConstructIndexTemplateFromIdentifications();
            Console.WriteLine("UNIT TEST - Finished constructing bins");
            Assert.That(engine.observedMzsToUseForIndex.Count > 0);
            Assert.That(engine.baseSequenceToIsotopicDistribution.Count > 0);
            Console.WriteLine("UNIT TEST - Bins are OK");

            for (int i = 0; i < engine.filePaths.Length; i++)
            {
                Console.WriteLine("UNIT TEST - Quantifying file " + (i + 1));
                try
                {
                    Assert.That(engine.Quantify(null, engine.filePaths[i]));
                }
                catch (AssertionException)
                {
                    Console.WriteLine("UNIT TEST - Could not quantify file \"" + engine.filePaths[i] + "\"");
                }
            }

            //if (engine.mbr)
            //    engine.RetentionTimeCalibrationAndErrorCheckMatchedFeatures();

            Console.WriteLine("UNIT TEST - Quantifying proteins ");
            engine.QuantifyProteins();

            Console.WriteLine("UNIT TEST - Asserting results");
            Assert.That(engine.SumFeatures(engine.allFeaturesByFile.SelectMany(p => p), true).Any());
            Assert.That(engine.SumFeatures(engine.allFeaturesByFile.SelectMany(p => p), false).Any());

            Assert.That(engine.allFeaturesByFile[0].First().intensity > 0);
            Assert.That(engine.allFeaturesByFile[1].First().intensity > 0);

            Assert.That(!engine.allFeaturesByFile[0].First().isMbrFeature);
            Assert.That(!engine.allFeaturesByFile[1].First().isMbrFeature);
            Console.WriteLine("UNIT TEST - All passed");
        }
Example #10
0
        public static void TestEverything()
        {
            Console.WriteLine("UNIT TEST - Entering unit test");
            string elements = Path.Combine(TestContext.CurrentContext.TestDirectory, "elements.dat");
            string files    = TestContext.CurrentContext.TestDirectory;
            string ident    = Path.Combine(TestContext.CurrentContext.TestDirectory, "aggregatePSMs_5ppmAroundZero.psmtsv");

            FlashLFQEngine engine = new FlashLFQEngine();

            Console.WriteLine("UNIT TEST - About to load elements");
            Loaders.LoadElements(elements);
            Console.WriteLine("UNIT TEST - Finished loading elements");

            Assert.That(engine.ParseArgs(new string[] {
                "--idt " + ident,
                "--rep " + files,
                "--ppm 5",
                "--sil false",
                "--pau false",
                "--mbr true"
            }
                                         ));
            Console.WriteLine("UNIT TEST - Done making engine");
            engine.globalStopwatch.Start();
            Assert.That(engine.outputFolder != null);
            engine.SetParallelization(1);

            //Assert.That(engine.ReadPeriodicTable());

            Console.WriteLine("UNIT TEST - About to read TSV file");
            Assert.That(engine.ReadIdentificationsFromTSV());
            Console.WriteLine("UNIT TEST - Finished reading TSV");
            engine.ConstructIndexTemplateFromIdentifications();
            Console.WriteLine("UNIT TEST - Finished constructing bins");
            Assert.That(engine.observedMzsToUseForIndex.Count > 0);
            Assert.That(engine.baseSequenceToIsotopicDistribution.Count > 0);
            Console.WriteLine("UNIT TEST - Bins are OK");

            for (int i = 0; i < engine.filePaths.Length; i++)
            {
                Console.WriteLine("UNIT TEST - Quantifying file " + (i + 1));
                try
                {
                    Assert.That(engine.Quantify(null, engine.filePaths[i]));
                }
                catch (AssertionException)
                {
                    Console.WriteLine("UNIT TEST - Could not quantify file \"" + engine.filePaths[i] + "\"");
                }
            }

            //if (engine.mbr)
            //    engine.RetentionTimeCalibrationAndErrorCheckMatchedFeatures();

            Console.WriteLine("UNIT TEST - Quantifying proteins ");
            engine.QuantifyProteins();

            Console.WriteLine("UNIT TEST - Asserting results");
            Assert.That(engine.SumFeatures(engine.allFeaturesByFile.SelectMany(p => p), true).Any());
            Assert.That(engine.SumFeatures(engine.allFeaturesByFile.SelectMany(p => p), false).Any());

            Assert.That(engine.allFeaturesByFile[0].First().intensity > 0);
            Assert.That(engine.allFeaturesByFile[1].First().intensity > 0);

            Assert.That(engine.allFeaturesByFile[0].Count == 1);
            Assert.That(engine.allFeaturesByFile[1].Count == 1);

            Assert.That(!engine.allFeaturesByFile[0].First().isMbrFeature);
            Assert.That(!engine.allFeaturesByFile[1].First().isMbrFeature);
            Console.WriteLine("UNIT TEST - All passed");
        }
        static void Main(string[] args)
        {
            FlashLFQEngine engine = new FlashLFQEngine();

            engine.globalStopwatch.Start();

            if (!engine.ReadPeriodicTable(null))
            {
                return;
            }

            if (!engine.ParseArgs(args))
            {
                return;
            }

            if (!engine.ReadIdentificationsFromTSV())
            {
                return;
            }

            engine.ConstructIndexTemplateFromIdentifications();

            Parallel.For(0, engine.filePaths.Length,
                         new ParallelOptions {
                MaxDegreeOfParallelism = 1
            },
                         fileNumber =>
            {
                if (!engine.Quantify(null, engine.filePaths[fileNumber]) && !engine.silent)
                {
                    Console.WriteLine("Error quantifying file " + engine.filePaths[fileNumber]);
                }
                GC.Collect();
            }
                         );

            if (engine.mbr)
            {
                engine.RetentionTimeCalibrationAndErrorCheckMatchedFeatures();
            }

            if (!engine.WriteResults("_FlashLFQ_", true, true, true))
            {
                return;
            }

            if (!engine.silent)
            {
                Console.WriteLine("All done");
            }

            if (!engine.silent)
            {
                Console.WriteLine("Analysis time: " + engine.globalStopwatch.Elapsed.Hours + "h " + engine.globalStopwatch.Elapsed.Minutes + "m " +
                                  engine.globalStopwatch.Elapsed.Seconds + "s");
            }

            if (engine.pause)
            {
                Console.ReadKey();
            }
        }
Example #12
0
        public static void Main(string[] args)
        {
            // parameters
            List <string> acceptedSpectrumFileFormats = new List <string> {
                ".RAW", ".MZML"
            };

            // setup parameters
            var p = new FluentCommandLineParser <ApplicationArguments>();

            p.SetupHelp("?", "help")
            .Callback(text => Console.WriteLine(
                          "Valid arguments:\n" +
                          "--idt [string|identification file path (TSV format)]\n" +
                          "--rep [string|directory containing spectrum data files]\n" +
                          "--out [string|output directory]\n" +
                          "--ppm [double|ppm tolerance]\n" +
                          "--iso [double|isotopic distribution tolerance in ppm]\n" +
                          "--sil [bool|silent mode]\n" +
                          "--int [bool|integrate features]\n" +
                          "--mbr [bool|match between runs]\n" +
                          "--mrt [double|maximum MBR window in minutes]\n" +
                          "--chg [bool|use only precursor charge state]\n" +
                          "--rmm [bool|require observed monoisotopic mass peak]\n" +
                          "--nis [int|number of isotopes required to be observed]\n" +
                          "--nor [bool|normalize intensity results]\n" +
                          "--pro [bool|advanced protein quantification]\n"
                          ));

            p.Setup(arg => arg.PsmInputPath) // PSMs file
            .As("idt").
            Required();

            p.Setup(arg => arg.RawFilesPath) // spectrum files
            .As("rep").
            Required();

            p.Setup(arg => arg.OutputPath) // output path
            .As("out");

            p.Setup(arg => arg.PpmTolerance) // ppm tolerance
            .As("ppm");

            p.Setup(arg => arg.IsotopePpmTolerance) // isotope ppm tolerance
            .As("iso");

            p.Setup(arg => arg.Silent) // do not display output messages
            .As("sil");

            p.Setup(arg => arg.Integrate) // integrate
            .As("int");

            p.Setup(arg => arg.MatchBetweenRuns) // match between runs
            .As("mbr");

            p.Setup(arg => arg.MbrRtWindow) // maximum match-between-runs window in minutes
            .As("mrt");

            p.Setup(arg => arg.IdSpecificChargeState) // only use PSM-identified charge states
            .As("chg");

            p.Setup(arg => arg.RequireMonoisotopicMass) // require observation of monoisotopic peak
            .As("rmm");

            p.Setup(arg => arg.NumIsotopesRequired) // num of isotopes required
            .As("nis");

            p.Setup(arg => arg.Normalize) // normalize
            .As("nor");

            p.Setup(arg => arg.AdvancedProteinQuant) // advanced protein quant
            .As("pro");

            // args are OK - run FlashLFQ
            if (!p.Parse(args).HasErrors&& p.Object.PsmInputPath != null)
            {
                if (!File.Exists(p.Object.PsmInputPath))
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("Could not locate identification file " + p.Object.PsmInputPath);
                    }
                    return;
                }

                if (!Directory.Exists(p.Object.RawFilesPath))
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("Could not locate folder " + p.Object.RawFilesPath);
                    }
                    return;
                }

                string assumedPathToExpDesign = Path.Combine(p.Object.RawFilesPath, "ExperimentalDesign.tsv");
                if (p.Object.Normalize && !File.Exists(assumedPathToExpDesign))
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("Could not find experimental design file (required for normalization): " + assumedPathToExpDesign);
                    }
                    return;
                }

                // set up spectra file info
                // get experimental design info for normalization
                List <SpectraFileInfo> spectraFileInfos = new List <SpectraFileInfo>();
                IEnumerable <string>   files            = Directory.GetFiles(p.Object.RawFilesPath)
                                                          .Where(f => acceptedSpectrumFileFormats.Contains(Path.GetExtension(f).ToUpperInvariant()));

                if (p.Object.Normalize)
                {
                    var experimentalDesign = File.ReadAllLines(assumedPathToExpDesign)
                                             .ToDictionary(v => v.Split('\t')[0], v => v);

                    foreach (var file in files)
                    {
                        string filename = Path.GetFileNameWithoutExtension(file);

                        var expDesignForThisFile = experimentalDesign[filename];
                        var split = expDesignForThisFile.Split('\t');

                        string condition = split[1];
                        int    biorep    = int.Parse(split[2]);
                        int    fraction  = int.Parse(split[3]);
                        int    techrep   = int.Parse(split[4]);

                        // experimental design info passed in here for each spectra file
                        spectraFileInfos.Add(new SpectraFileInfo(fullFilePathWithExtension: file,
                                                                 condition: condition,
                                                                 biorep: biorep - 1,
                                                                 fraction: fraction - 1,
                                                                 techrep: techrep - 1));
                    }
                }
                else
                {
                    foreach (var file in files)
                    {
                        spectraFileInfos.Add(new SpectraFileInfo(fullFilePathWithExtension: file,
                                                                 condition: "",
                                                                 biorep: 0,
                                                                 fraction: 0,
                                                                 techrep: 0));
                    }
                }

                // set up IDs
                List <Identification> ids;
                try
                {
                    ids = PsmReader.ReadPsms(p.Object.PsmInputPath, p.Object.Silent, spectraFileInfos);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Problem reading PSMs: " + e.Message);
                    return;
                }

                if (ids.Any())
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("Setup is OK; read in " + ids.Count + " identifications; starting FlashLFQ engine");
                    }

                    // make engine with desired settings
                    FlashLFQEngine engine = new FlashLFQEngine(
                        allIdentifications: ids,
                        normalize: p.Object.Normalize,
                        ppmTolerance: p.Object.PpmTolerance,
                        isotopeTolerancePpm: p.Object.IsotopePpmTolerance,
                        matchBetweenRuns: p.Object.MatchBetweenRuns,
                        matchBetweenRunsPpmTolerance: p.Object.MbrPpmTolerance,
                        integrate: p.Object.Integrate,
                        numIsotopesRequired: p.Object.NumIsotopesRequired,
                        idSpecificChargeState: p.Object.IdSpecificChargeState,
                        requireMonoisotopicMass: p.Object.RequireMonoisotopicMass,
                        silent: p.Object.Silent,
                        optionalPeriodicTablePath: null,
                        maxMbrWindow: p.Object.MbrRtWindow,
                        advancedProteinQuant: p.Object.AdvancedProteinQuant);

                    // run
                    var results = engine.Run();

                    // output
                    OutputWriter.WriteOutput(p.Object.PsmInputPath, results, p.Object.OutputPath);
                }
                else
                {
                    if (!p.Object.Silent)
                    {
                        Console.WriteLine("No peptide IDs for the specified spectra files were found! " +
                                          "Check to make sure the spectra file names match between the ID file and the spectra files");
                    }
                }
            }
            else if (p.Parse(args).HasErrors == false && p.Object.PsmInputPath == null)
            {
                // no errors - just requesting help?
            }
            else
            {
                Console.WriteLine("Invalid arguments - type \"--help\" for valid arguments");
            }
        }
Example #13
0
        public static void TestFlashLfqNormalization()
        {
            // ********************************* check biorep normalization *********************************
            // get the raw file paths
            SpectraFileInfo raw  = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"), "a", 0, 0, 0);
            SpectraFileInfo mzml = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"), "a", 1, 0, 0);

            // create some PSMs
            var            pg  = new ProteinGroup("MyProtein", "gene", "org");
            Identification id1 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });
            Identification id2 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });

            // create the FlashLFQ engine
            var results = new FlashLFQEngine(new List <Identification> {
                id1, id2
            }, normalize: true).Run();

            // check that biorep normalization worked
            int int1 = (int)System.Math.Round(results.Peaks[mzml].First().Intensity, 0);
            int int2 = (int)System.Math.Round(results.Peaks[raw].First().Intensity, 0);

            Assert.That(int1 > 0);
            Assert.That(int1 == int2);

            // ********************************* check condition normalization *********************************
            raw  = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"), "a", 0, 0, 0);
            mzml = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"), "b", 0, 0, 0);

            id1 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });
            id2 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });

            results = new FlashLFQEngine(new List <Identification> {
                id1, id2
            }, normalize: true).Run();

            int int3 = (int)System.Math.Round(results.Peaks[mzml].First().Intensity, 0);
            int int4 = (int)System.Math.Round(results.Peaks[raw].First().Intensity, 0);

            Assert.That(int3 > 0);
            Assert.That(int3 == int4);

            // ********************************* check techrep normalization *********************************
            raw  = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"), "a", 0, 0, 0);
            mzml = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"), "a", 0, 1, 0);

            id1 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });
            id2 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });

            results = new FlashLFQEngine(new List <Identification> {
                id1, id2
            }, normalize: true).Run();

            int int5 = (int)System.Math.Round(results.Peaks[mzml].First().Intensity, 0);
            int int6 = (int)System.Math.Round(results.Peaks[raw].First().Intensity, 0);

            Assert.That(int5 > 0);
            Assert.That(int5 == int6);

            Assert.That(int1 == int3);
            Assert.That(int1 == int5);


            // ********************************* check fraction normalization *********************************
            raw = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"), "a", 0, 0, 0);
            var raw2 = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"), "a", 0, 0, 1);

            mzml = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"), "a", 1, 0, 0);
            var mzml2 = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"), "a", 1, 0, 1);

            id1 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });
            id2 = new Identification(raw2, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });
            var id3 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });
            var id4 = new Identification(mzml2, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pg
            });

            results = new FlashLFQEngine(new List <Identification> {
                id1, id2, id3, id4
            }, normalize: true).Run();

            int int7 = (int)System.Math.Round(results.PeptideBaseSequences["EGFQVADGPLYR"].GetIntensity(raw) + results.PeptideBaseSequences["EGFQVADGPLYR"].GetIntensity(raw2));
            int int8 = (int)System.Math.Round(results.PeptideBaseSequences["EGFQVADGPLYR"].GetIntensity(mzml) + results.PeptideBaseSequences["EGFQVADGPLYR"].GetIntensity(mzml2));

            Assert.That(int7 > 0);
            Assert.That(int7 == int8);
        }
Example #14
0
        public static void TestFlashLfqMatchBetweenRunsProteinQuant()
        {
            List <string> filesToWrite = new List <string> {
                "mzml_1", "mzml_2"
            };
            List <string> pepSequences = new List <string> {
                "PEPTIDE", "PEPTIDEV", "PEPTIDEVV", "PEPTIDEVVV", "PEPTIDEVVVV"
            };
            double intensity = 1e6;

            double[] file1Rt = new double[] { 1.01, 1.02, 1.03, 1.04, 1.05 };
            double[] file2Rt = new double[] { 1.015, 1.030, 1.036, 1.050, 1.065 };

            Loaders.LoadElements(Path.Combine(TestContext.CurrentContext.TestDirectory, @"elements.dat"));

            // generate mzml files (5 peptides each)
            for (int f = 0; f < filesToWrite.Count; f++)
            {
                // 1 MS1 scan per peptide
                MsDataScan[] scans = new MsDataScan[5];

                for (int p = 0; p < pepSequences.Count; p++)
                {
                    ChemicalFormula      cf          = new Proteomics.AminoAcidPolymer.Peptide(pepSequences[p]).GetChemicalFormula();
                    IsotopicDistribution dist        = IsotopicDistribution.GetDistribution(cf, 0.125, 1e-8);
                    double[]             mz          = dist.Masses.Select(v => v.ToMz(1)).ToArray();
                    double[]             intensities = dist.Intensities.Select(v => v * intensity).ToArray();
                    double rt;
                    if (f == 0)
                    {
                        rt = file1Rt[p];
                    }
                    else
                    {
                        rt = file2Rt[p];
                    }

                    // add the scan
                    scans[p] = new MsDataScan(massSpectrum: new MzSpectrum(mz, intensities, false), oneBasedScanNumber: p + 1, msnOrder: 1, isCentroid: true,
                                              polarity: Polarity.Positive, retentionTime: rt, scanWindowRange: new MzRange(400, 1600), scanFilter: "f",
                                              mzAnalyzer: MZAnalyzerType.Orbitrap, totalIonCurrent: intensities.Sum(), injectionTime: 1.0, noiseData: null, nativeId: "scan=" + (p + 1));
                }

                // write the .mzML
                IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(new FakeMsDataFile(scans),
                                                                              Path.Combine(TestContext.CurrentContext.TestDirectory, filesToWrite[f] + ".mzML"), false);
            }

            // set up spectra file info
            SpectraFileInfo file1 = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, filesToWrite[0] + ".mzML"), "a", 0, 0, 0);
            SpectraFileInfo file2 = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, filesToWrite[1] + ".mzML"), "a", 1, 0, 0);

            // create some PSMs
            var pg = new ProteinGroup("MyProtein", "gene", "org");
            var myMbrProteinGroup = new ProteinGroup("MyMbrProtein", "MbrGene", "org");

            Identification id1 = new Identification(file1, "PEPTIDE", "PEPTIDE",
                                                    new Proteomics.AminoAcidPolymer.Peptide("PEPTIDE").MonoisotopicMass, file1Rt[0] + 0.001, 1, new List <ProteinGroup> {
                pg
            });
            Identification id2 = new Identification(file1, "PEPTIDEV", "PEPTIDEV",
                                                    new Proteomics.AminoAcidPolymer.Peptide("PEPTIDEV").MonoisotopicMass, file1Rt[1] + 0.001, 1, new List <ProteinGroup> {
                pg
            });
            Identification id3 = new Identification(file1, "PEPTIDEVV", "PEPTIDEVV",
                                                    new Proteomics.AminoAcidPolymer.Peptide("PEPTIDEVV").MonoisotopicMass, file1Rt[2] + 0.001, 1, new List <ProteinGroup> {
                myMbrProteinGroup
            });
            Identification id4 = new Identification(file1, "PEPTIDEVVV", "PEPTIDEVVV",
                                                    new Proteomics.AminoAcidPolymer.Peptide("PEPTIDEVVV").MonoisotopicMass, file1Rt[3] + 0.001, 1, new List <ProteinGroup> {
                pg
            });
            Identification id5 = new Identification(file1, "PEPTIDEVVVV", "PEPTIDEVVVV",
                                                    new Proteomics.AminoAcidPolymer.Peptide("PEPTIDEVVVV").MonoisotopicMass, file1Rt[4] + 0.001, 1, new List <ProteinGroup> {
                pg
            });

            Identification id6 = new Identification(file2, "PEPTIDE", "PEPTIDE",
                                                    new Proteomics.AminoAcidPolymer.Peptide("PEPTIDE").MonoisotopicMass, file2Rt[0] + 0.001, 1, new List <ProteinGroup> {
                pg
            });
            Identification id7 = new Identification(file2, "PEPTIDEV", "PEPTIDEV",
                                                    new Proteomics.AminoAcidPolymer.Peptide("PEPTIDEV").MonoisotopicMass, file2Rt[1] + 0.001, 1, new List <ProteinGroup> {
                pg
            });
            // missing ID 8 - MBR feature
            Identification id9 = new Identification(file2, "PEPTIDEVVV", "PEPTIDEVVV",
                                                    new Proteomics.AminoAcidPolymer.Peptide("PEPTIDEVVV").MonoisotopicMass, file2Rt[3] + 0.001, 1, new List <ProteinGroup> {
                pg
            });
            Identification id10 = new Identification(file2, "PEPTIDEVVVV", "PEPTIDEVVVV",
                                                     new Proteomics.AminoAcidPolymer.Peptide("PEPTIDEVVVV").MonoisotopicMass, file2Rt[4] + 0.001, 1, new List <ProteinGroup> {
                pg
            });

            // test with top3 protein quant engine
            FlashLFQEngine engine = new FlashLFQEngine(new List <Identification> {
                id1, id2, id3, id4, id5, id6, id7, id9, id10
            }, matchBetweenRuns: true);
            var results = engine.Run();

            Assert.That(results.ProteinGroups["MyMbrProtein"].GetIntensity(file1) > 0);
            Assert.That(results.ProteinGroups["MyMbrProtein"].GetIntensity(file2) == 0);

            // test with advanced protein quant engine
            engine = new FlashLFQEngine(new List <Identification> {
                id1, id2, id3, id4, id5, id6, id7, id9, id10
            }, matchBetweenRuns: true, advancedProteinQuant: true);
            results = engine.Run();

            Assert.That(results.ProteinGroups["MyMbrProtein"].GetIntensity(file1) > 0);
            Assert.That(results.ProteinGroups["MyMbrProtein"].GetIntensity(file2) == 0);
        }
Example #15
0
        public static void TestFlashLfqAdvancedProteinQuant()
        {
            List <string> filesToWrite = new List <string> {
                "mzml_1", "mzml_2"
            };
            List <string> pepSequences = new List <string> {
                "PEPTIDE", "MYPEPTIDE", "VVVVVPEPTIDE"
            };

            double[,] amounts = new double[2, 3] {
                { 1000000, 1000000, 1000000 },
                { 2000000, 2000000, 900000 }
            };
            Loaders.LoadElements(Path.Combine(TestContext.CurrentContext.TestDirectory, @"elements.dat"));

            // generate mzml files (3 peptides each)
            for (int f = 0; f < filesToWrite.Count; f++)
            {
                // 1 MS1 scan per peptide
                MsDataScan[] scans = new MsDataScan[3];

                for (int p = 0; p < pepSequences.Count; p++)
                {
                    ChemicalFormula      cf          = new Proteomics.AminoAcidPolymer.Peptide(pepSequences[p]).GetChemicalFormula();
                    IsotopicDistribution dist        = IsotopicDistribution.GetDistribution(cf, 0.125, 1e-8);
                    double[]             mz          = dist.Masses.Select(v => v.ToMz(1)).ToArray();
                    double[]             intensities = dist.Intensities.Select(v => v * amounts[f, p]).ToArray();

                    // add the scan
                    scans[p] = new MsDataScan(massSpectrum: new MzSpectrum(mz, intensities, false), oneBasedScanNumber: p + 1, msnOrder: 1, isCentroid: true,
                                              polarity: Polarity.Positive, retentionTime: 1.0 + (p / 10.0), scanWindowRange: new MzRange(400, 1600), scanFilter: "f",
                                              mzAnalyzer: MZAnalyzerType.Orbitrap, totalIonCurrent: intensities.Sum(), injectionTime: 1.0, noiseData: null, nativeId: "scan=" + (p + 1));
                }

                // write the .mzML
                IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(new FakeMsDataFile(scans),
                                                                              Path.Combine(TestContext.CurrentContext.TestDirectory, filesToWrite[f] + ".mzML"), false);
            }

            // set up spectra file info
            SpectraFileInfo file1 = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, filesToWrite[0] + ".mzML"), "a", 0, 0, 0);
            SpectraFileInfo file2 = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, filesToWrite[1] + ".mzML"), "a", 1, 0, 0);

            // create some PSMs
            var            pg  = new ProteinGroup("MyProtein", "gene", "org");
            Identification id1 = new Identification(file1, "PEPTIDE", "PEPTIDE", 799.35996, 1.01, 1, new List <ProteinGroup> {
                pg
            });
            Identification id2 = new Identification(file1, "MYPEPTIDE", "MYPEPTIDE", 1093.46377, 1.11, 1, new List <ProteinGroup> {
                pg
            });
            Identification id3 = new Identification(file1, "VVVVVPEPTIDE", "VVVVVPEPTIDE", 1294.70203, 1.21, 1, new List <ProteinGroup> {
                pg
            });

            Identification id4 = new Identification(file2, "PEPTIDE", "PEPTIDE", 799.35996, 1.01, 1, new List <ProteinGroup> {
                pg
            });
            Identification id5 = new Identification(file2, "MYPEPTIDE", "MYPEPTIDE", 1093.46377, 1.11, 1, new List <ProteinGroup> {
                pg
            });
            Identification id6 = new Identification(file2, "VVVVVPEPTIDE", "VVVVVPEPTIDE", 1294.70203, 1.21, 1, new List <ProteinGroup> {
                pg
            });

            // create the FlashLFQ engine
            FlashLFQEngine engine = new FlashLFQEngine(new List <Identification> {
                id1, id2, id3, id4, id5, id6
            }, normalize: false, advancedProteinQuant: true);

            // run the engine
            var results = engine.Run();

            // third peptide should be low-weighted
            // protein should be ~sum of first two peptide intensities (a little lower, because some smaller isotope peaks get skipped)
            double file1ProteinIntensity = results.ProteinGroups["MyProtein"].GetIntensity(file1);

            Assert.That(file1ProteinIntensity < 2e6);
            Assert.That(file1ProteinIntensity > 1e6);

            double file2ProteinIntensity = results.ProteinGroups["MyProtein"].GetIntensity(file2);

            Assert.That(file2ProteinIntensity < 4e6);
            Assert.That(file2ProteinIntensity > 3e6);
        }
Example #16
0
        public static void TestFlashLfqMergeResults()
        {
            SpectraFileInfo rawA  = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"), "a", 0, 0, 0);
            SpectraFileInfo mzmlA = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"), "a", 0, 1, 0);

            // create some PSMs
            var            pgA  = new ProteinGroup("MyProtein", "gene", "org");
            Identification id1A = new Identification(rawA, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pgA
            });
            Identification id2A = new Identification(rawA, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <ProteinGroup> {
                pgA
            });
            Identification id3A = new Identification(mzmlA, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pgA
            });
            Identification id4A = new Identification(mzmlA, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <ProteinGroup> {
                pgA
            });

            // create the FlashLFQ engine
            FlashLFQEngine engineA = new FlashLFQEngine(new List <Identification> {
                id1A, id2A, id3A, id4A
            });

            // run the engine
            var resultsA = engineA.Run();

            SpectraFileInfo rawB  = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw"), "b", 0, 0, 0);
            SpectraFileInfo mzmlB = new SpectraFileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml"), "b", 0, 1, 0);

            // create some PSMs
            var            pgB = new ProteinGroup("MyProtein", "gene", "org");
            Identification id1 = new Identification(rawB, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pgB
            });
            Identification id2 = new Identification(rawB, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <ProteinGroup> {
                pgB
            });
            Identification id3 = new Identification(mzmlB, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <ProteinGroup> {
                pgB
            });
            Identification id4 = new Identification(mzmlB, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <ProteinGroup> {
                pgB
            });

            // create the FlashLFQ engine
            FlashLFQEngine engineB = new FlashLFQEngine(new List <Identification> {
                id1, id2, id3, id4
            });

            // run the engine
            var resultsB = engineB.Run();

            resultsA.MergeResultsWith(resultsB);
            Assert.AreEqual(4, resultsA.Peaks.Count);
            Assert.AreEqual(1, resultsA.PeptideBaseSequences.Count);
            Assert.AreEqual(1, resultsA.PeptideModifiedSequences.Count);
            Assert.AreEqual(1, resultsA.ProteinGroups.Count);
            Assert.AreEqual(4, resultsA.SpectraFiles.Count);
        }