コード例 #1
0
        protected void DoTest()
        {
            if (TestFilesZipPaths != null)
            {
                TestFilesDirs = new TestFilesDir[TestFilesZipPaths.Length];
                for (int i = 0; i < TestFilesZipPaths.Length; i++)
                {
                    TestFilesDirs[i] = new TestFilesDir(TestContext, TestFilesZipPaths[i], TestDirectoryName,
                                                        TestFilesPersistent, IsExtractHere(i));
                }
            }

            File.Copy(_baseSkyFile, _skyFile, true);
            Stopwatch loadStopwatch = new Stopwatch();

            loadStopwatch.Start();
            var doc = ResultsUtil.DeserializeDocument(_skyFile);

            doc = ConnectLibrarySpecs(doc, _skyFile);
            using (var docContainer = new ResultsTestDocumentContainer(doc, _skyFile))
            {
                var chromSets = new[]
                {
                    new ChromatogramSet(_replicateName, new[]
                                        { new MsDataFilePath(_dataFile, null, _centroided, _centroided), }),
                };
                var docResults = doc.ChangeMeasuredResults(new MeasuredResults(chromSets));
                Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                docContainer.AssertComplete();
            }
            loadStopwatch.Stop();

            DebugLog.Info("{0} load time = {1}", _dataFile, loadStopwatch.ElapsedMilliseconds);
        }
コード例 #2
0
        private static ResultsTestDocumentContainer MinimizeCacheFile(SrmDocument document,
                                                                      ChromCacheMinimizer.Settings settings, string skyFilePath)
        {
            Assert.IsNotNull(skyFilePath);  // For ReSharper
            string skydFilePath = Path.ChangeExtension(skyFilePath, ChromatogramCache.EXT);
            ChromCacheMinimizer chromCacheMinimizer = document.Settings.MeasuredResults.GetChromCacheMinimizer(document);

            using (var fs = new FileSaver(skydFilePath))
                using (var fsScans = new FileSaver(skydFilePath + ChromatogramCache.SCANS_EXT, true))
                    using (var fsPeaks = new FileSaver(skydFilePath + ChromatogramCache.PEAKS_EXT, true))
                        using (var fsScores = new FileSaver(skydFilePath + ChromatogramCache.SCORES_EXT, true))
                        {
                            fs.Stream = File.OpenWrite(fs.SafeName);
                            chromCacheMinimizer.Minimize(settings, null, fs.Stream,
                                                         fsScans.FileStream, fsPeaks.FileStream, fsScores.FileStream);
                            fs.Commit();
                        }
            using (var writer = new XmlTextWriter(skyFilePath, Encoding.UTF8)
            {
                Formatting = Formatting.Indented
            })
            {
                var ser = new XmlSerializer(typeof(SrmDocument));
                ser.Serialize(writer, document);

                writer.Flush();
                writer.Close();
            }
            var container = new ResultsTestDocumentContainer(document, skyFilePath, false);

            Assert.IsTrue(container.SetDocument(ResultsUtil.DeserializeDocument(skyFilePath), document, true));
            return(container);
        }
コード例 #3
0
        public void TestColumnsFromResultsTables()
        {
            SrmDocument srmDocument = ResultsUtil.DeserializeDocument("silac_1_to_4.sky", GetType());

            using (Database database = new Database())
            {
                database.AddSrmDocument(srmDocument);
                SimpleReport report = new SimpleReport
                {
                    Columns = new[]
                    {
                        new ReportColumn(typeof(DbTransitionResult),
                                         "PrecursorResult", "PeptideResult", "ProteinResult", "ReplicateName"),
                        new ReportColumn(typeof(DbTransition), "Precursor", "Peptide", "Protein", "Name"),
                        new ReportColumn(typeof(DbTransition), "Precursor", "Peptide", "Sequence"),
                        new ReportColumn(typeof(DbTransitionResult), "Area"),
                    },
                };
                ColumnSet columnSet = ColumnSet.GetTransitionsColumnSet(database.GetSchema());
                TreeView  treeView  = new TreeView();
                treeView.Nodes.AddRange(columnSet.GetTreeNodes().ToArray());
                List <NodeData> columnInfos;
                columnSet.GetColumnInfos(report, treeView, out columnInfos);
                Assert.AreEqual(report.Columns.Count, columnInfos.Count);
                SimpleReport reportCompare = (SimpleReport)columnSet.GetReport(columnInfos, null);
                Assert.IsTrue(ArrayUtil.EqualsDeep(report.Columns, reportCompare.Columns));
            }
        }
コード例 #4
0
ファイル: ImportSimTest.cs プロジェクト: rfellers/pwiz
        private void DoTestImportSim(bool asSmallMolecules)
        {
            if (asSmallMolecules && !RunSmallMoleculeTestVersions)
            {
                System.Console.Write(MSG_SKIPPING_SMALLMOLECULE_TEST_VERSION);
                return;
            }

            var    testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);
            string docPath      = testFilesDir.GetTestPath(DOCUMENT_NAME);
            string cachePath    = ChromatogramCache.FinalPathForName(docPath, null);

            FileEx.SafeDelete(cachePath);
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            var pepdoc = doc;

            if (asSmallMolecules)
            {
                var refine = new RefinementSettings();
                doc = refine.ConvertToSmallMolecules(pepdoc, TestContext.ResultsDirectory);
            }

            using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
            {
                // Import the mzML file and verify Mz range
                Import(docContainer, testFilesDir.GetTestPath(RESULTS_NAME), 510, 512);
                Import(docContainer, testFilesDir.GetTestPath(RESULTS_NAME2), 555, 557);
            }
        }
コード例 #5
0
        public void WatersLockmassCmdlinePerfTest()
        {
            if (IsPerfTest && !RunPerfTests)
            {
                return; // Don't want to run this lengthy test right now
            }

            TestFilesZip        = "https://skyline.gs.washington.edu/perftests/PerfTestLockmass.zip";
            TestFilesPersistent = new[] { "ID19638_01_UCA195_2533_082715.raw" }; // List of files that we'd like to unzip alongside parent zipFile, and (re)use in place
            TestFilesDir        = new TestFilesDir(TestContext, TestFilesZip, "CmdlineTest", TestFilesPersistent);

            var skyfile = GetTestPath("2533_FattyAcids.sky");

            var          rawPath          = GetTestPath(TestFilesPersistent[0]);
            const double lockmassNegative = 554.2615;

            // Exercise the commandline
            var outPathUncorrected = TestFilesDir.GetTestPath("cmdlineTestUncorrected.sky");
            var outPathCorrected   = TestFilesDir.GetTestPath("cmdlineTestCorrected.sky");

            RunCommand("--in=" + skyfile,
                       "--import-file=" + rawPath,
                       "--out=" + outPathUncorrected);
            FileEx.SafeDelete(Path.ChangeExtension(skyfile, ChromatogramCache.EXT));
            var cmdDocUncorrected = ResultsUtil.DeserializeDocument(outPathUncorrected);

            RunCommand("--in=" + skyfile,
                       "--import-file=" + rawPath,
                       "--import-lockmass-negative=" + lockmassNegative,
                       "--out=" + outPathCorrected);
            var cmdDocCorrected = ResultsUtil.DeserializeDocument(outPathCorrected);

            ComparePeaks(cmdDocCorrected, cmdDocUncorrected);
        }
コード例 #6
0
        public void TestMeasuredDriftValues()
        {
            var testFilesDir = new TestFilesDir(TestContext, @"Test\Results\BlibDriftTimeTest.zip"); // Re-used from BlibDriftTimeTest
            // Open document with some peptides but no results
            var         docPath      = testFilesDir.GetTestPath("BlibDriftTimeTest.sky");
            SrmDocument docOriginal  = ResultsUtil.DeserializeDocument(docPath);
            var         docContainer = new ResultsTestDocumentContainer(docOriginal, docPath);
            var         doc          = docContainer.Document;

            // Import an mz5 file that contains drift info
            const string replicateName = "ID12692_01_UCA168_3727_040714";
            var          chromSets     = new[]
            {
                new ChromatogramSet(replicateName, new[]
                                    { new MsDataFilePath(testFilesDir.GetTestPath("ID12692_01_UCA168_3727_040714.mz5")), }),
            };
            var docResults = doc.ChangeMeasuredResults(new MeasuredResults(chromSets));

            Assert.IsTrue(docContainer.SetDocument(docResults, docOriginal, true));
            docContainer.AssertComplete();
            var document = docContainer.Document;

            document = document.ChangeSettings(document.Settings.ChangePeptidePrediction(prediction => new PeptidePrediction(null, DriftTimePredictor.EMPTY)));

            // Verify ability to extract predictions from raw data
            var newPred = document.Settings.PeptideSettings.Prediction.DriftTimePredictor.ChangeMeasuredDriftTimesFromResults(
                document, docContainer.DocumentFilePath);
            var result = newPred.MeasuredDriftTimePeptides;

            Assert.AreEqual(TestSmallMolecules? 2: 1, result.Count);
            const double expectedDT     = 4.0019;
            var          expectedOffset = .4829;

            Assert.AreEqual(expectedDT, result.Values.First().DriftTimeMsec(false).Value, .001);
            Assert.AreEqual(expectedOffset, result.Values.First().HighEnergyDriftTimeOffsetMsec, .001);

            // Check ability to update, and to preserve unchanged
            var revised = new Dictionary <LibKey, DriftTimeInfo>();
            var libKey  = result.Keys.First();

            revised.Add(libKey, new DriftTimeInfo(4, 0.234));
            var libKey2 = new LibKey("DEADEELS", 2);

            revised.Add(libKey2, new DriftTimeInfo(5, 0.123));
            document =
                document.ChangeSettings(
                    document.Settings.ChangePeptidePrediction(prediction => new PeptidePrediction(null, new DriftTimePredictor("test", revised, null, null, 40))));
            newPred = document.Settings.PeptideSettings.Prediction.ChangeDriftTimePredictor(
                document.Settings.PeptideSettings.Prediction.DriftTimePredictor.ChangeMeasuredDriftTimesFromResults(
                    document, docContainer.DocumentFilePath)).DriftTimePredictor;
            result = newPred.MeasuredDriftTimePeptides;
            Assert.AreEqual(TestSmallMolecules ? 3 : 2, result.Count);
            Assert.AreEqual(expectedDT, result[libKey].DriftTimeMsec(false).Value, .001);
            Assert.AreEqual(expectedOffset, result[libKey].HighEnergyDriftTimeOffsetMsec, .001);
            Assert.AreEqual(5, result[libKey2].DriftTimeMsec(false).Value, .001);
            Assert.AreEqual(0.123, result[libKey2].HighEnergyDriftTimeOffsetMsec, .001);


            docContainer.Release();
        }
コード例 #7
0
ファイル: ExplicitModTest.cs プロジェクト: rfellers/pwiz
        private SrmDocument CreateStudy7Doc()
        {
            SrmDocument docStudy7 = ResultsUtil.DeserializeDocument("Study7.sky", GetType());

            AssertEx.IsDocumentState(docStudy7, 0, 7, 11, 22, 66);
            return(docStudy7);
        }
コード例 #8
0
        public void Wiff2ResultsTest()
        {
            TestFilesDir testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);

            string      docPath = testFilesDir.GetTestPath("OnyxTOFMS.sky");
            SrmDocument doc     = ResultsUtil.DeserializeDocument(docPath);

            //AssertEx.IsDocumentState(doc, 0, 1, 1, 4);

            using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
            {
                const string replicateName = "Wiff2Test";
                string       extRaw        = ExtensionTestContext.ExtAbWiff2;
                string       suffix        = ExtensionTestContext.CanImportAbWiff2 ? "" : "-sample-centroid";
                var          chromSets     = new[]
                {
                    new ChromatogramSet(replicateName, new[]
                                        { new MsDataFilePath(TestFilesDir.GetVendorTestData(TestFilesDir.VendorDir.ABI, "swath.api" + suffix + extRaw)), }),
                };
                var docResults = doc.ChangeMeasuredResults(new MeasuredResults(chromSets));
                Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                docContainer.AssertComplete();
                docResults = docContainer.Document;
                //AssertResult.IsDocumentResultsState(docResults, replicateName,
                //    doc.MoleculeCount, doc.MoleculeTransitionGroupCount, 0, doc.MoleculeTransitionCount, 0);
            }

            testFilesDir.Dispose();
        }
コード例 #9
0
        public void ConsoleMProphetModelTest()
        {
            var          testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);
            const string docName      = "mProphetModel.sky";
            var          docPath      = testFilesDir.GetTestPath(docName);
            const string modelName    = "testModel";

            // with mods and invalid cutoff score
            var output = RunCommand("--in=" + docPath,
                                    "--reintegrate-model-name=" + modelName,
                                    "--reintegrate-create-model",
                                    "--reintegrate-overwrite-peaks",
                                    "--save"
                                    );

            AssertEx.Contains(output, string.Format(Resources.CommandLine_CreateScoringModel_Creating_scoring_model__0_, modelName));
            var doc = ResultsUtil.DeserializeDocument(docPath);

            foreach (var peakFeatureCalculator in MProphetPeakScoringModel.GetDefaultCalculators(doc))
            {
                // Not all of the default calculators for the document are valid
                if (peakFeatureCalculator is MQuestRetentionTimePredictionCalc ||
                    peakFeatureCalculator is MQuestRetentionTimeSquaredPredictionCalc ||
                    peakFeatureCalculator is MQuestIntensityCorrelationCalc ||
                    peakFeatureCalculator is NextGenProductMassErrorCalc ||
                    peakFeatureCalculator is NextGenCrossWeightedShapeCalc ||
                    peakFeatureCalculator is LegacyIdentifiedCountCalc)
                {
                    continue;
                }

                AssertEx.Contains(output, peakFeatureCalculator.Name);
            }
            AssertEx.Contains(output, string.Format(Resources.CommandLine_SaveFile_File__0__saved_, docName));
        }
コード例 #10
0
        private static ResultsTestDocumentContainer InitMatchDocContainer(TestFilesDir testFilesDir)
        {
            string      docPath = testFilesDir.GetTestPath("modmatch.sky");
            SrmDocument doc     = ResultsUtil.DeserializeDocument(docPath);

            return(new ResultsTestDocumentContainer(doc, docPath));
        }
コード例 #11
0
ファイル: CommandLineWiffTest.cs プロジェクト: rfellers/pwiz
        private static void CheckDocument(string docPath, string[] rawPaths, int importCount)
        {
            var doc = ResultsUtil.DeserializeDocument(docPath);

            Assert.IsTrue(doc.Settings.HasResults);
            Assert.AreEqual(SAMPLE_NAMES.Count * importCount, doc.Settings.MeasuredResults.Chromatograms.Count);
            for (int i = 0; i < SAMPLE_NAMES.Count; i++)
            {
                for (int j = 1; j <= importCount; j++)
                {
                    var chromIndex      = i + SAMPLE_NAMES.Count * (j - 1);
                    var chromatogramSet = doc.Settings.MeasuredResults.Chromatograms[chromIndex];

                    var replicateName = SAMPLE_NAMES[i] + (j > 1 ? j.ToString() : "");
                    Assert.AreEqual(replicateName, chromatogramSet.Name);

                    Assert.AreEqual(1, chromatogramSet.MSDataFilePaths.Count());
                    var msDataFilePath = chromatogramSet.MSDataFilePaths.First() as MsDataFilePath;
                    Assert.IsNotNull(msDataFilePath);
                    Assert.AreEqual(i, msDataFilePath.SampleIndex);
                    Assert.AreEqual(SAMPLE_NAMES[i], msDataFilePath.SampleName);
                    Assert.AreEqual(rawPaths[j - 1], msDataFilePath.FilePath);
                }
            }
        }
コード例 #12
0
        private static SrmDocument InitExplicitRTDocument(TestFilesDir testFilesDir, string fileName, out string docPath)
        {
            docPath = testFilesDir.GetTestPath(fileName);
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            return(doc);
        }
コード例 #13
0
        private void TestSchemaValidation(Stream schemaFile, string doc08Path, string docCurrentPath)
        {
            // get the schema
            XmlTextReader schemaReader = new XmlTextReader(schemaFile);
            XmlSchema     schema       = XmlSchema.Read(schemaReader, ValidationCallBack);

            // create the validation settings
            XmlReaderSettings readerSettings = new XmlReaderSettings
            {
                ValidationType = ValidationType.Schema
            };

            readerSettings.Schemas.Add(schema);
            readerSettings.ValidationFlags        |= XmlSchemaValidationFlags.ReportValidationWarnings;
            readerSettings.ValidationEventHandler += ValidationCallBack;

            // Read the Skyline version 0.8 document
            XmlReader reader = XmlReader.Create(doc08Path, readerSettings);

            // Read the file with a validating reader
            while (reader.Read())
            {
            }
            reader.Close();
            // The document should not validate.
            Assert.IsTrue(_errorCount > 0);


            var doc08 = ResultsUtil.DeserializeDocument(doc08Path);

            Assert.IsNotNull(doc08);
            AssertEx.IsDocumentState(doc08, 0, 7, 11, 22, 66);



            // Save the document.
            // IMPORTANT: update the default modifications first.
            doc08.Settings.UpdateDefaultModifications(true);
            WriteDocument(doc08, docCurrentPath);

            Assert.IsTrue(File.Exists(docCurrentPath));
            var docCurrent = ResultsUtil.DeserializeDocument(docCurrentPath);

            Assert.IsNotNull(docCurrent);
            AssertEx.IsDocumentState(docCurrent, 0, 7, 11, 22, 66);

            AssertEx.DocumentCloned(doc08, docCurrent); // Make sure that the documents are the same


            _errorCount = 0;
            reader      = XmlReader.Create(docCurrentPath, readerSettings);
            // Read the file with a validating reader
            while (reader.Read())
            {
            }
            reader.Close();
            // The document should validate without any errors.
            Assert.AreEqual(0, _errorCount);
        }
コード例 #14
0
        public void TestCollectStatistics()
        {
            var         testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);
            string      docPath      = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi.sky");
            SrmDocument doc          = ResultsUtil.DeserializeDocument(docPath);
            var         docContainer = new ResultsTestDocumentContainer(doc, docPath);

            // Import the first RAW file (or mzML for international)
            string rawPath = testFilesDir.GetTestPath("ah_20101011y_BSA_MS-MS_only_5-2" +
                                                      ExtensionTestContext.ExtThermoRaw);
            var measuredResults = new MeasuredResults(new[] { new ChromatogramSet("Single", new[] { MsDataFileUri.Parse(rawPath) }) });

            SrmDocument docResults = docContainer.ChangeMeasuredResults(measuredResults, 3, 3, 21);

            ChromCacheMinimizer chromCacheMinimizer =
                docResults.Settings.MeasuredResults.GetChromCacheMinimizer(docResults);

            ChromCacheMinimizer.Settings settings =
                new ChromCacheMinimizer.Settings().SetDiscardUnmatchedChromatograms(true);
            ChromCacheMinimizer.MinStatistics minStatistics = null;
            chromCacheMinimizer.Minimize(settings, s => minStatistics = s, null);
            Assert.AreEqual(100, minStatistics.PercentComplete);
            Assert.AreEqual(1.0, minStatistics.MinimizedRatio);

            var docMissingFirstPeptide =
                (SrmDocument)
                docResults.ReplaceChild(
                    docResults.PeptideGroups.First().RemoveChild(docResults.PeptideGroups.First().Children[0]));
            var docWithOnlyFirstPeptide =
                (SrmDocument)
                docResults.ReplaceChild(
                    docResults.PeptideGroups.First().ChangeChildren(new[] { docResults.PeptideGroups.First().Children[0] }));

            ChromCacheMinimizer.MinStatistics statsMissingFirstProtein  = null;
            ChromCacheMinimizer.MinStatistics statsWithOnlyFirstProtein = null;

            settings = settings.SetDiscardUnmatchedChromatograms(true);
            ChromCacheMinimizer minimizerMissingFirstProtein =
                docMissingFirstPeptide.Settings.MeasuredResults.GetChromCacheMinimizer(docMissingFirstPeptide);
            ChromCacheMinimizer minimizerWithOnlyFirstProtein =
                docWithOnlyFirstPeptide.Settings.MeasuredResults.GetChromCacheMinimizer(docWithOnlyFirstPeptide);

            minimizerMissingFirstProtein.Minimize(settings, s => statsMissingFirstProtein   = s, null);
            minimizerWithOnlyFirstProtein.Minimize(settings, s => statsWithOnlyFirstProtein = s, null);
            Assert.AreEqual(100, statsMissingFirstProtein.PercentComplete);
            Assert.AreEqual(100, statsWithOnlyFirstProtein.PercentComplete);
            Assert.AreEqual(1.0, statsMissingFirstProtein.MinimizedRatio + statsWithOnlyFirstProtein.MinimizedRatio,
                            .00001);
            settings = settings.SetDiscardUnmatchedChromatograms(false);
            ChromCacheMinimizer.MinStatistics statsMissingFirstProteinKeepAll  = null;
            ChromCacheMinimizer.MinStatistics statsWithOnlyFirstProteinKeepAll = null;
            minimizerMissingFirstProtein.Minimize(settings, s => statsMissingFirstProteinKeepAll   = s, null);
            minimizerWithOnlyFirstProtein.Minimize(settings, s => statsWithOnlyFirstProteinKeepAll = s, null);
            Assert.AreEqual(100, statsMissingFirstProteinKeepAll.PercentComplete);
            Assert.AreEqual(1.0, statsMissingFirstProteinKeepAll.MinimizedRatio);
            Assert.AreEqual(100, statsWithOnlyFirstProteinKeepAll.PercentComplete);
            Assert.AreEqual(1.0, statsWithOnlyFirstProteinKeepAll.MinimizedRatio);
            docContainer.Release();
        }
コード例 #15
0
ファイル: WatersCalcurveTest.cs プロジェクト: zrolfs/pwiz
        private static SrmDocument InitWatersDocument(TestFilesDir testFilesDir, string fileName, out string docPath)
        {
            docPath = testFilesDir.GetTestPath(fileName);
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 1, 12, 12, 24);
            return(doc);
        }
コード例 #16
0
        private static SrmDocument InitAgilentMseDocument(TestFilesDir testFilesDir, string fileName, out string docPath)
        {
            docPath = testFilesDir.GetTestPath(fileName);
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 1, 14, 14, 45);  // int revision, int groups, int peptides, int tranGroups, int transitions
            return(doc);
        }
コード例 #17
0
ファイル: RefineTest.cs プロジェクト: rfellers/pwiz
        private SrmDocument InitRefineDocumentSprg()
        {
            TestFilesDir testFilesDir = new TestFilesDir(TestContext, @"TestData\Refine.zip");
            var          doc          = ResultsUtil.DeserializeDocument(testFilesDir.GetTestPath("sprg_all_charges-mini.sky"));

            AssertEx.IsDocumentState(doc, null, 1, 3, 6, 54);
            return(doc);
        }
コード例 #18
0
ファイル: RefineTest.cs プロジェクト: rfellers/pwiz
        private SrmDocument InitRefineDocumentIprg()
        {
            TestFilesDir testFilesDir = new TestFilesDir(TestContext, @"TestData\Refine.zip");
            var          doc          = ResultsUtil.DeserializeDocument(testFilesDir.GetTestPath("iPRG 2015 Study-mini.sky"));

            AssertEx.IsDocumentState(doc, null, 1, 4, 6, 18);
            return(doc);
        }
コード例 #19
0
ファイル: RefineTest.cs プロジェクト: suchp-max/proteowizard
        private static SrmDocument InitRefineDocument(TestFilesDir testFilesDir)
        {
            string      docPath = testFilesDir.GetTestPath("SRM_mini.sky");
            SrmDocument doc     = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 4, 36, 38, 334);
            return(doc);
        }
コード例 #20
0
        private static SrmDocument InitShimadzuDocument(TestFilesDir testFilesDir, out string docPath)
        {
            docPath = testFilesDir.GetTestPath("Alan_BSA_new.sky");
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 1, 15, 72);
            return(doc);
        }
コード例 #21
0
        private static SrmDocument InitUnmixedDocument(TestFilesDir testFilesDir, out string docPath)
        {
            docPath = testFilesDir.GetTestPath("Site20_Study9p_unmixed.sky");
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 1, 4, 8, 24);
            return(doc);
        }
コード例 #22
0
ファイル: AgilentMixTest.cs プロジェクト: zrolfs/pwiz
        private static SrmDocument InitAgilentDocument(TestFilesDir testFilesDir, out string docPath)
        {
            docPath = testFilesDir.GetTestPath("Bovine_std_curated_seq_small2.sky");
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 4, 5, 20);
            return(doc);
        }
コード例 #23
0
        private static SrmDocument InitThermoDocument(TestFilesDir testFilesDir, out string docPath)
        {
            docPath = testFilesDir.GetTestPath("Site20_Study9p.sky");
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 2, 10, 18, 54);
            return(doc);
        }
コード例 #24
0
        public void GenerateDecoysTest()
        {
            TestFilesDir testFilesDir = new TestFilesDir(TestContext, @"TestA\SimpleDecoys.zip");

            string      docPath         = testFilesDir.GetTestPath("SimpleDecoys.sky");
            SrmDocument simpleDecoysDoc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(simpleDecoysDoc, 0, 1, 18, 18, 56);

            // First check right number of decoy peptide groups and transtions are generated
            var refineSettings = new RefinementSettings();
            int numDecoys      = simpleDecoysDoc.PeptideCount;
            var decoysDoc      = refineSettings.GenerateDecoys(simpleDecoysDoc, numDecoys, DecoyGeneration.ADD_RANDOM);

            ValidateDecoys(simpleDecoysDoc, decoysDoc, false);

            // Second call to generate decoys to make sure that it removes the original Decoys group and generates a completely new one.
            var newDecoysDoc = refineSettings.GenerateDecoys(decoysDoc, numDecoys, DecoyGeneration.ADD_RANDOM);

            Assert.AreNotEqual(decoysDoc.PeptideGroups.First(nodePeptideGroup => nodePeptideGroup.IsDecoy),
                               newDecoysDoc.PeptideGroups.First(nodePeptideGroup => nodePeptideGroup.IsDecoy));

            // MS1 document with precursors and variable modifications, shuffled
            docPath = testFilesDir.GetTestPath("Ms1FilterTutorial.sky");
            SrmDocument variableDecoysDoc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(variableDecoysDoc, 0, 11, 50, 51, 153);
            numDecoys = variableDecoysDoc.PeptideCount;
            var decoysVariableShuffle = refineSettings.GenerateDecoys(variableDecoysDoc, numDecoys, DecoyGeneration.SHUFFLE_SEQUENCE);

            ValidateDecoys(variableDecoysDoc, decoysVariableShuffle, true);

            // Document with explicit modifications, reversed
            SrmDocument docStudy7 = ResultsUtil.DeserializeDocument("Study7.sky", GetType());

            AssertEx.IsDocumentState(docStudy7, 0, 7, 11, 22, 66);
            numDecoys = docStudy7.PeptideCount;
            var decoysExplicitReverse = refineSettings.GenerateDecoys(docStudy7, numDecoys, DecoyGeneration.REVERSE_SEQUENCE);

            ValidateDecoys(docStudy7, decoysExplicitReverse, true);

            // Random mass shifts with precursors (used to throw an exception due to bad range check that assumed product ions only)
            while (true)
            {
                // As this is random we may need to make a few attempts before we get the values we need
                SrmDocument doc = ResultsUtil.DeserializeDocument(testFilesDir.GetTestPath("precursor_decoy_test.sky"));
                AssertEx.IsDocumentState(doc, null, 1, 1, 2, 6);
                numDecoys = 2;
                var decoysRandom = refineSettings.GenerateDecoys(doc, numDecoys, DecoyGeneration.ADD_RANDOM);
                // Verify that we successfully set a precursor transition decoy mass outside the allowed range of product transitions
                if (decoysRandom.PeptideTransitions.Any(x => x.IsDecoy &&
                                                        (x.Transition.DecoyMassShift > Transition.MAX_PRODUCT_DECOY_MASS_SHIFT ||
                                                         x.Transition.DecoyMassShift < Transition.MIN_PRODUCT_DECOY_MASS_SHIFT)))
                {
                    break;
                }
            }
        }
コード例 #25
0
        public void FullScanPrecursorTransitionsTest()
        {
            TestFilesDir testFilesDir = new TestFilesDir(TestContext, @"Test\FullScanPrecursor.zip");

            string      docPath = testFilesDir.GetTestPath("FullScanPrecursor.sky");
            SrmDocument doc     = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 1, 4, 5, 52);
            using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
            {
                var mitoLibSpec = new BiblioSpecLiteSpec("mito2", testFilesDir.GetTestPath("mito2.blib"));
                doc = docContainer.ChangeLibSpecs(new[] { mitoLibSpec });
                Assert.IsTrue(doc.IsLoaded);

                // Switch to only precursor ions
                var docPrecOnly = doc.ChangeSettings(doc.Settings.ChangeTransitionFilter(filter =>
                                                                                         filter.ChangePeptideIonTypes(new[] { IonType.precursor })));
                // All precursors should have 3 precursor transitions (M, M+1 and M+2)
                AssertEx.IsDocumentState(docPrecOnly, 3, 1, 4, 5, 15);
                Assert.IsFalse(docPrecOnly.PeptideTransitions.Any(nodeTran => nodeTran.Transition.IonType != IonType.precursor));

                // Use low resolution MS1 filtering
                var docLowMs1 = docPrecOnly.ChangeSettings(docPrecOnly.Settings.ChangeTransitionFullScan(fs =>
                                                                                                         fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, null)
                                                                                                         .ChangePrecursorResolution(FullScanMassAnalyzerType.qit, 0.5, null)));
                // All precursors should have one precursor transition
                AssertEx.IsDocumentState(docLowMs1, 4, 1, 4, 5, 5);

                // Add y-ions to low resolution filtering
                var docLowMs1Y = docLowMs1.ChangeSettings(docLowMs1.Settings.ChangeTransitionFilter(filter =>
                                                                                                    filter.ChangePeptideIonTypes(new[] { IonType.precursor, IonType.y })));
                AssertEx.IsDocumentState(docLowMs1Y, 5, 1, 4, 5, 33);

                // Turn off MS1 filtering
                var docNoMs1 = docPrecOnly.ChangeSettings(docPrecOnly.Settings.ChangeTransitionFullScan(fs =>
                                                                                                        fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.None, null, null)));
                // One of the precursors should have no transitions, since its spectrum has no precursor match
                AssertEx.IsDocumentState(docNoMs1, 4, 1, 4, 5, 4);

                // Turn off MS/MS library matching
                var docNoLibMatch = docNoMs1.ChangeSettings(docNoMs1.Settings.ChangeTransitionLibraries(lib =>
                                                                                                        lib.ChangePick(TransitionLibraryPick.none)));
                // All precursors should have a single precursor transition
                AssertEx.IsDocumentState(docNoLibMatch, 5, 1, 4, 5, 5);

                // Use library plus filter matching
                var docLibPlusMatch = docNoMs1.ChangeSettings(docNoMs1.Settings.ChangeTransitionLibraries(lib =>
                                                                                                          lib.ChangePick(TransitionLibraryPick.all_plus)));
                // All precursors should have a single precursor transition
                AssertEx.IsDocumentState(docLibPlusMatch, 5, 1, 4, 5, 5);

                // Release the library stream, and dispose of the directory
                docContainer.ChangeLibSpecs(new LibrarySpec[0]);
            }
            testFilesDir.Dispose();
        }
コード例 #26
0
        public void TestBlibDriftTimes()
        {
            var testFilesDir = new TestFilesDir(TestContext, @"Test\Results\BlibDriftTimeTest.zip");
            // Open document with some peptides but no results
            var         docPath      = testFilesDir.GetTestPath("BlibDriftTimeTest.sky");
            SrmDocument docOriginal  = ResultsUtil.DeserializeDocument(docPath);
            var         docContainer = new ResultsTestDocumentContainer(docOriginal, docPath);
            var         doc          = docContainer.Document;

            // Use the bare drift times in the spectral library
            var librarySpec = new BiblioSpecLiteSpec("drift test",
                                                     testFilesDir.GetTestPath("BlibDriftTimeTest.blib"));

            doc = doc.ChangeSettings(
                doc.Settings.ChangePeptideLibraries(lib => lib.ChangeLibrarySpecs(new[] { librarySpec })).
                ChangePeptidePrediction(p => p.ChangeLibraryDriftTimesResolvingPower(20)).
                ChangePeptidePrediction(p => p.ChangeUseLibraryDriftTimes(true))
                );

            // Import an mz5 file that needs drift info that's in the original data set,
            // but preserved in the .blib file associated with a different raw source
            // Without the bugfix this won't get any drift time filtering.
            const string replicateName = "ID12692_01_UCA168_3727_040714";
            var          chromSets     = new[]
            {
                new ChromatogramSet(replicateName, new[]
                                    { new MsDataFilePath(testFilesDir.GetTestPath("ID12692_01_UCA168_3727_040714.mz5")), }),
            };
            var docResults = doc.ChangeMeasuredResults(new MeasuredResults(chromSets));

            Assert.IsTrue(docContainer.SetDocument(docResults, docOriginal, true));
            docContainer.AssertComplete();
            var document = docContainer.Document;

            float  tolerance = (float)document.Settings.TransitionSettings.Instrument.MzMatchTolerance;
            double maxHeight = 0;
            var    results   = document.Settings.MeasuredResults;

            Assert.AreEqual(2, document.PeptidePrecursorPairs.Count());
            var pair = document.PeptidePrecursorPairs.ToArray()[1];

            ChromatogramGroupInfo[] chromGroupInfo;
            Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup,
                                                      tolerance, true, out chromGroupInfo));
            Assert.AreEqual(1, chromGroupInfo.Length);
            var chromGroup = chromGroupInfo[0];

            Assert.AreEqual(2, chromGroup.NumPeaks);  // This will be higher if we don't filter on DT
            foreach (var tranInfo in chromGroup.TransitionPointSets)
            {
                maxHeight = Math.Max(maxHeight, tranInfo.MaxIntensity);
            }
            Assert.AreEqual(278, maxHeight, 1);   // Without DT filtering, this will be much greater - about 996

            docContainer.Release();
        }
コード例 #27
0
        private long GetCacheSize(int docIndex, SrmDocument docInitial = null)
        {
            if (docInitial == null)
            {
                docInitial = ResultsUtil.DeserializeDocument(_documentPaths[docIndex]);
            }
            int  dataGroupCount = _groupCounts[docIndex];
            int  dataTranCount  = _tranCounts[docIndex];
            long format3Size    = _cacheSizes[docIndex];

            long cacheSize       = format3Size;
            int  fileCachedCount = docInitial.Settings.MeasuredResults.MSDataFileInfos.Count();

            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_3)
            {
                // Cache version 4 stores instrument information, and is bigger in size.
                cacheSize += sizeof(int) * fileCachedCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_4)
            {
                // Cache version 5 adds an int for flags for each file
                // Allow for a difference in sizes due to the extra information.
                int fileFlagsSize = sizeof(int) * fileCachedCount;
                // And SeqIndex, SeqCount, StartScoreIndex and padding
                int groupHeadersSize = ChromGroupHeaderInfo5.DeltaSize5 * dataGroupCount;
                // And flags for each transition
                int transitionFlagsSize = ChromTransition5.DeltaSize5 * dataTranCount;
                // And num seq byte count, seq location, score types, num scores and score location
                const int headerScoreSize = sizeof(int) + sizeof(long) + sizeof(int) + sizeof(int) + sizeof(long);
                cacheSize += groupHeadersSize + fileFlagsSize + transitionFlagsSize + headerScoreSize;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_5)
            {
                // Cache version 6 adds status graph dimensions for every file
                cacheSize += sizeof(float) * 2 * fileCachedCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_6)
            {
                // Cache version 7 adds ion mobility information
                cacheSize += sizeof(float) * 2 * dataTranCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_8)
            {
                // Cache version 9 adds scan id values for every file
                cacheSize += (sizeof(int) + sizeof(long)) * fileCachedCount;
                // And scan ids location to global header
                cacheSize += sizeof(long);
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE >= ChromatogramCache.FORMAT_VERSION_CACHE_11)
            {
                // Version 11 adds uncompressed buffer size for convenience, and some time span metadata
                cacheSize += ChromGroupHeaderInfo.DeltaSize11 * dataGroupCount;
            }
            return(cacheSize);
        }
コード例 #28
0
ファイル: PwizFileInfoTest.cs プロジェクト: rfellers/pwiz
        public void TestQcTraces()
        {
            const string testZipPath = @"TestData\PressureTracesTest.zip";

            var testFilesDir = new TestFilesDir(TestContext, testZipPath);

            using (var msDataFile = new MsDataFileImpl(testFilesDir.GetTestPath("PressureTrace1" + ExtensionTestContext.ExtAbWiff)))
            {
                var pressureTraces = msDataFile.GetQcTraces();

                VerifyQcTrace(pressureTraces[0], "Column Pressure (channel 1)", 1148, 0, 9.558333, 1470, 210, MsDataFileImpl.QcTraceQuality.Pressure, MsDataFileImpl.QcTraceUnits.PoundsPerSquareInch);
                VerifyQcTrace(pressureTraces[1], "Pump A Flowrate (channel 2)", 1148, 0, 9.558333, 91590, 89120, MsDataFileImpl.QcTraceQuality.FlowRate, MsDataFileImpl.QcTraceUnits.MicrolitersPerMinute);
                VerifyQcTrace(pressureTraces[2], "Pump B Flowrate (channel 3)", 1148, 0, 9.558333, 0, 840, MsDataFileImpl.QcTraceQuality.FlowRate, MsDataFileImpl.QcTraceUnits.MicrolitersPerMinute);
                VerifyQcTrace(pressureTraces[3], "Column Pressure (channel 4)", 3508, 0, 29.225, 1396, 1322, MsDataFileImpl.QcTraceQuality.Pressure, MsDataFileImpl.QcTraceUnits.PoundsPerSquareInch);
                VerifyQcTrace(pressureTraces[4], "Pump A Flowrate (channel 5)", 3508, 0, 29.225, 7038, 7833, MsDataFileImpl.QcTraceQuality.FlowRate, MsDataFileImpl.QcTraceUnits.MicrolitersPerMinute);
                VerifyQcTrace(pressureTraces[5], "Pump B Flowrate (channel 6)", 3508, 0, 29.225, 680, 151, MsDataFileImpl.QcTraceQuality.FlowRate, MsDataFileImpl.QcTraceUnits.MicrolitersPerMinute);

                string      docPath = testFilesDir.GetTestPath("PressureTrace1.sky");
                SrmDocument doc     = ResultsUtil.DeserializeDocument(docPath);
                AssertEx.IsDocumentState(doc, 0, 1, 3, 9);

                using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
                {
                    const string replicateName = "PressureTrace1";
                    string       extRaw        = ExtensionTestContext.ExtAbWiff;
                    var          chromSets     = new[]
                    {
                        new ChromatogramSet(replicateName, new[]
                                            { new MsDataFilePath(testFilesDir.GetTestPath("PressureTrace1" + extRaw)), }),
                    };
                    var docResults = doc.ChangeMeasuredResults(new MeasuredResults(chromSets));
                    Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                    docContainer.AssertComplete();
                    docResults = docContainer.Document;

                    var chromCache = docResults.Settings.MeasuredResults.GetChromCacheMinimizer(docResults).ChromatogramCache;
                    var tic        = chromCache.LoadAllIonsChromatogramInfo(ChromExtractor.summed, chromSets[0]);
                    var bpc        = chromCache.LoadAllIonsChromatogramInfo(ChromExtractor.base_peak, chromSets[0]);
                    var qc         = chromCache.LoadAllIonsChromatogramInfo(ChromExtractor.qc, chromSets[0]);

                    Assert.AreEqual(0, tic.Count());    // No longer expect these in SRM data
                    Assert.AreEqual(0, bpc.Count());    // No longer expect these in SRM data
                    var qcNames = qc.Select(o => o.TextId).ToArray();
                    Assert.AreEqual(6, qcNames.Length);
                    CollectionAssert.IsSubsetOf(new [] { "Column Pressure (channel 1)",
                                                         "Pump A Flowrate (channel 2)",
                                                         "Pump B Flowrate (channel 3)",
                                                         "Column Pressure (channel 4)",
                                                         "Pump A Flowrate (channel 5)",
                                                         "Pump B Flowrate (channel 6)" },
                                                qcNames);
                }
            }
        }
コード例 #29
0
        private long GetCacheSize(int docIndex, SrmDocument docInitial = null)
        {
            if (docInitial == null)
            {
                docInitial = ResultsUtil.DeserializeDocument(_documentPaths[docIndex]);
            }
            int  dataGroupCount = _groupCounts[docIndex];
            int  dataTranCount  = _tranCounts[docIndex];
            long format3Size    = _cacheSizes[docIndex];
            int  peakCount      = _peakCounts[docIndex];

            return(ResultsUtil.CacheSize(docInitial, format3Size, dataGroupCount, dataTranCount, peakCount));
        }
コード例 #30
0
        private void IsDocumentState(string docPath, int proteins, int lists,
                                     int peptides, int molecules, int tranGroups, int transitions,
                                     string output = null)
        {
            if (output != null)
            {
                AssertEx.Contains(output, CommandLine.RemovedText(_initProt - proteins, _initList - lists,
                                                                  _initPep - peptides, _initMol - molecules, _initPrec - tranGroups, _initTran - transitions));
            }
            var doc = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, null, proteins + lists, peptides + molecules, tranGroups, transitions);
        }