Exemplo n.º 1
0
        public void DoAgilentMseChromatogramTest(RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules, small_mol_mode smallMolMode = small_mol_mode.simple, string expectedError = null)
        {
            if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none && !RunSmallMoleculeTestVersions && smallMolMode == small_mol_mode.simple)
            {
                System.Console.Write(MSG_SKIPPING_SMALLMOLECULE_TEST_VERSION);
                return;
            }

            var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);

            string      docPath;
            SrmDocument document = InitAgilentMseDocument(testFilesDir, out docPath);

            if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none)
            {
                var refine = new RefinementSettings();
                document = refine.ConvertToSmallMolecules(document, testFilesDir.FullPath, asSmallMolecules, smallMolMode == small_mol_mode.simple ? RefinementSettings.ConvertToSmallMoleculesChargesMode.none : RefinementSettings.ConvertToSmallMoleculesChargesMode.invert);
            }
            using (var docContainer = new ResultsTestDocumentContainer(document, docPath))
            {
                var doc = docContainer.Document;
                var listChromatograms = new List <ChromatogramSet>();
                var path = MsDataFileUri.Parse(smallMolMode == small_mol_mode.invert_charges_and_data ? @"AgilentMse\BSA-AI-0-10-25-41_first_100_scans_neg.mzML" : @"AgilentMse\BSA-AI-0-10-25-41_first_100_scans.mzML");
                listChromatograms.Add(AssertResult.FindChromatogramSet(doc, path) ??
                                      new ChromatogramSet(path.GetFileName().Replace('.', '_'), new[] { path }));
                var docResults = doc.ChangeMeasuredResults(new MeasuredResults(listChromatograms));
                Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                if (expectedError != null)
                {
                    docContainer.AssertError(expectedError);
                }
                else
                {
                    docContainer.AssertComplete();
                    document = docContainer.Document;

                    float tolerance = (float)document.Settings.TransitionSettings.Instrument.MzMatchTolerance;
                    var   results   = document.Settings.MeasuredResults;
                    foreach (var pair in document.MoleculePrecursorPairs)
                    {
                        ChromatogramGroupInfo[] chromGroupInfo;
                        Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup,
                                                                  tolerance, true, out chromGroupInfo));
                        Assert.AreEqual(1, chromGroupInfo.Length);
                        VerifyMs1Truncated(chromGroupInfo.First());
                    }

                    // now drill down for specific values
                    int nPeptides = 0;
                    foreach (var nodePep in document.Molecules.Where(nodePep => !nodePep.Results[0].IsEmpty))
                    {
                        // expecting just one peptide result in this small data set
                        if (nodePep.Results[0].Any(chromInfo => chromInfo.PeakCountRatio > 0))
                        {
                            Assert.AreEqual(0.25205,
                                            (double)nodePep.GetMeasuredRetentionTime(0), .0001, "averaged retention time differs in node " + nodePep.ModifiedTarget);
                            Assert.AreEqual(0.3333, (double)nodePep.GetPeakCountRatio(0), 0.0001);
                            nPeptides++;
                        }
                    }
                    Assert.AreEqual(smallMolMode == small_mol_mode.invert_charges ? 0 : 1, nPeptides); // If we switched document polarity, we'd expect no chromatograms extracted
                }
            }
            testFilesDir.Dispose();
        }