Esempio n. 1
0
        public static void PeptideFDRTest()
        {
            string myFile  = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PrunedDbSpectra.mzml");
            string myFile2 = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PrunedDbSpectra2.mzml");

            if (!File.Exists(myFile2))
            {
                File.Copy(myFile, myFile2);
            }
            string    myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DbForPrunedDb.fasta");
            string    folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestPeptideFDR");
            DbForTask db         = new DbForTask(myDatabase, true);

            Directory.CreateDirectory(folderPath);

            // search something with multiple hits of the same peptide to see if peptide FDR is calculated at the end
            new SearchTask().RunTask(folderPath, new List <DbForTask> {
                db
            }, new List <string> {
                myFile, myFile2
            }, "normal");
            List <string> columns     = null;
            int           cumDecoys   = 0;
            int           cumTargets  = 0;
            double        finalQValue = 0;

            foreach (string line in File.ReadAllLines(Path.Combine(folderPath, @"AllPeptides.psmtsv")))
            {
                string[] lineline = line.Split('\t');
                if (line.StartsWith("File Name")) // header
                {
                    columns = lineline.ToList();
                }

                // since each PSM has a duplicate, these counts will be 1,3,5,7, etc. if peptide FDR isn't calculated
                // if peptide FDR is calculated, they will be 1,2,3,4, etc. as expected
                else if (lineline[columns.IndexOf("Decoy/Contaminant/Target")] == "D")
                {
                    Assert.AreEqual(++cumDecoys, int.Parse(lineline[columns.IndexOf("Cumulative Decoy")]));
                    finalQValue = double.Parse(lineline[columns.IndexOf("QValue")], CultureInfo.InvariantCulture);
                }
                else
                {
                    Assert.AreEqual(++cumTargets, int.Parse(lineline[columns.IndexOf("Cumulative Target")]));
                    finalQValue = double.Parse(lineline[columns.IndexOf("QValue")], CultureInfo.InvariantCulture);
                }
            }

            // test that the final q-value follows the (target / decoy) formula
            // intermediate q-values no longer always follow this formula, so I'm not testing them here
            Assert.AreEqual(cumDecoys / (double)cumTargets, finalQValue, 0.0001);
            Directory.Delete(folderPath, true);
        }
Esempio n. 2
0
        public static void GlyTest_RunTask()
        {
            GlycoSearchTask task = new GlycoSearchTask();

            task._glycoSearchParameters.GlycoSearchType = GlycoSearchType.NGlycanSearch;
            Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, @"TESTGlycoData"));
            DbForTask db  = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"GlycoTestData/Q9C0Y4.fasta"), false);
            string    raw = Path.Combine(TestContext.CurrentContext.TestDirectory, @"GlycoTestData/yeast_glycan_25170.mgf");

            new EverythingRunnerEngine(new List <(string, MetaMorpheusTask)> {
                ("Task", task)
            }, new List <string> {
        public static void TestLibraryGeneration()
        {
            string thisTaskOutputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SpectralLibrarySearch\FileOutput");

            SearchTask task = Toml.ReadFile <SearchTask>(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SpectralLibrarySearch\SpectralSearchTask.toml"), MetaMorpheusTask.tomlConfig);

            task.SearchParameters.WriteMzId            = true;
            task.SearchParameters.WriteSpectralLibrary = true;

            DbForTask db  = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SpectralLibrarySearch\uniprot-yeast-filtered-reviewed_yes.fasta.gz"), false);
            string    raw = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SpectralLibrarySearch\slicedYeast.raw");
            EverythingRunnerEngine MassSpectraFile = new EverythingRunnerEngine(new List <(string, MetaMorpheusTask)> {
                ("SpectraFileOutput", task)
            }, new List <string> {
Esempio n. 4
0
        public static void PostSearchNormalizeTest()
        {
            SearchTask searchTask = new SearchTask()
            {
                SearchParameters = new SearchParameters
                {
                    Normalize = true
                },
            };

            string myFile                 = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PrunedDbSpectra.mzml");
            string myDatabase             = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DbForPrunedDb.fasta");
            string folderPath             = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestNormalizationExperDesign");
            string experimentalDesignFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\ExperimentalDesign.tsv");

            using (StreamWriter output = new StreamWriter(experimentalDesignFile))
            {
                output.WriteLine("FileName\tCondition\tBiorep\tFraction\tTechrep");
                output.WriteLine("PrunedDbSpectra.mzml" + "\t" + "condition" + "\t" + "1" + "\t" + "1" + "\t" + "1");
            }
            DbForTask db = new DbForTask(myDatabase, false);

            // run the task
            Directory.CreateDirectory(folderPath);
            searchTask.RunTask(folderPath, new List <DbForTask> {
                db
            }, new List <string> {
                myFile
            }, "normal");

            Directory.Delete(folderPath, true);

            // delete the exper design and try again. this should skip quantification
            File.Delete(experimentalDesignFile);

            // run the task
            Directory.CreateDirectory(folderPath);
            searchTask.RunTask(folderPath, new List <DbForTask> {
                db
            }, new List <string> {
                myFile
            }, "normal");

            // PSMs should be present but no quant output
            Assert.That(!File.Exists(Path.Combine(folderPath, "AllQuantifiedPeptides.tsv")));
            Assert.That(File.Exists(Path.Combine(folderPath, "AllPSMs.psmtsv")));

            Directory.Delete(folderPath, true);
        }
        public static void SemiSpecificTest()
        {
            List <FragmentationTerminus> terminiToTest = new List <FragmentationTerminus>
            {
                FragmentationTerminus.N,
                FragmentationTerminus.C
            };
            string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSemiSpecific");
            string myFile       = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PrunedDbSpectra.mzml");
            string myDatabase   = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DbForPrunedDb.fasta");

            foreach (FragmentationTerminus fragTerm in terminiToTest)
            {
                SearchTask searchTask = new SearchTask()
                {
                    SearchParameters = new SearchParameters
                    {
                        SearchType         = SearchType.NonSpecific,
                        LocalFdrCategories = new List <FdrCategory>
                        {
                            FdrCategory.FullySpecific,
                            FdrCategory.SemiSpecific
                        }
                    },
                    CommonParameters = new CommonParameters(scoreCutoff: 4, addCompIons: true,
                                                            digestionParams: new DigestionParams(searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: fragTerm))
                };

                DbForTask db = new DbForTask(myDatabase, false);

                List <(string, MetaMorpheusTask)> taskList = new List <(string, MetaMorpheusTask)> {
                    ("TestSemiSpecific", searchTask)
                };

                var engine = new EverythingRunnerEngine(taskList, new List <string> {
                    myFile
                }, new List <DbForTask> {
                    new DbForTask(myDatabase, false)
                }, outputFolder);
                engine.Run();

                string outputPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSemiSpecific\TestSemiSpecific\AllPSMs.psmtsv");
                var    output     = File.ReadAllLines(outputPath);
                Assert.That(output.Length == 13); //if N is only producing 11 lines, then the c is not being searched with it. //If only 12 lines, maybe missed mono issue
            }
            Directory.Delete(outputFolder, true);
        }
Esempio n. 6
0
        public static void SemiSpecificFullAndSmallMatches()
        {
            SearchTask searchTask = new SearchTask()
            {
                SearchParameters = new SearchParameters
                {
                    WriteMzId          = true,
                    SearchType         = SearchType.NonSpecific,
                    LocalFdrCategories = new List <FdrCategory>
                    {
                        FdrCategory.FullySpecific,
                        FdrCategory.SemiSpecific
                    }
                },
                CommonParameters = new CommonParameters(addCompIons: true, scoreCutoff: 11,
                                                        digestionParams: new DigestionParams(minPeptideLength: 7, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.N))
            };

            string    myFile     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\tinySemi.mgf");
            string    myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\semiTest.fasta");
            DbForTask db         = new DbForTask(myDatabase, false);

            List <(string, MetaMorpheusTask)> taskList = new List <(string, MetaMorpheusTask)> {
                ("TestSemiSpecificSmall", searchTask)
            };


            var engine = new EverythingRunnerEngine(taskList, new List <string> {
                myFile
            }, new List <DbForTask> {
                new DbForTask(myDatabase, false)
            }, Environment.CurrentDirectory);

            engine.Run();

            string outputPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSemiSpecificSmall\AllPSMs.psmtsv");
            var    output     = File.ReadAllLines(outputPath);

            Assert.IsTrue(output.Length == 3);

            var mzId = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSemiSpecificSmall\tinySemi.mzID"));

            Assert.That(mzId[115].Equals("          <cvParam name=\"mzML format\" cvRef=\"PSI-MS\" accession=\"MS:1000584\" />"));
            Assert.That(mzId[118].Equals("          <cvParam name=\"mzML unique identifier\" cvRef=\"PSI-MS\" accession=\"MS:1001530\" />"));
            Assert.That(mzId[97].Equals("        <cvParam name=\"pep:FDR threshold\" value=\"0.01\" cvRef=\"PSI-MS\" accession=\"MS:1001448\" />"));
        }
        public static void MultipleCustomFragmentations()
        {
            string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestCustomFragmentations");
            string myFile       = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PrunedDbSpectra.mzml");
            string myDatabase   = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DbForPrunedDb.fasta");

            // create 3 search tasks with different custom fragmentation ions
            var task1 = Toml.ReadFile <SearchTask>(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\customBY.toml"), MetaMorpheusTask.tomlConfig);
            var task2 = Toml.ReadFile <SearchTask>(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\customCZ.toml"), MetaMorpheusTask.tomlConfig);
            var task3 = Toml.ReadFile <SearchTask>(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\customBCZ.toml"), MetaMorpheusTask.tomlConfig);

            // run all tasks
            DbForTask db = new DbForTask(myDatabase, false);
            List <(string, MetaMorpheusTask)> taskList = new List <(string, MetaMorpheusTask)> {
                ("TestSearchBY", task1), ("TestSearchCZ", task2), ("TestSearchBCZ", task3)
            };
            var engine = new EverythingRunnerEngine(taskList, new List <string> {
                myFile
            }, new List <DbForTask> {
                new DbForTask(myDatabase, false)
            }, outputFolder);

            engine.Run();

            // read generated toml settings and make sure custom fragmentations match are handled properly for each task
            string outputPath = Path.Combine(outputFolder, @"Task Settings");

            var task1Settings = Toml.ReadFile <SearchTask>(Path.Combine(outputPath, @"TestSearchBYConfig.toml"), MetaMorpheusTask.tomlConfig);
            var task2Settings = Toml.ReadFile <SearchTask>(Path.Combine(outputPath, @"TestSearchCZConfig.toml"), MetaMorpheusTask.tomlConfig);
            var task3Settings = Toml.ReadFile <SearchTask>(Path.Combine(outputPath, @"TestSearchBCZConfig.toml"), MetaMorpheusTask.tomlConfig);

            var task1CustomIons = task1Settings.CommonParameters.CustomIons;
            var task2CustomIons = task2Settings.CommonParameters.CustomIons;
            var task3CustomIons = task3Settings.CommonParameters.CustomIons;

            Assert.That(task1CustomIons.Contains(ProductType.b) && task1CustomIons.Contains(ProductType.y) && task1CustomIons.Count == 2);
            Assert.That(task2CustomIons.Contains(ProductType.c) && task2CustomIons.Contains(ProductType.zDot) && task2CustomIons.Count == 2);
            Assert.That(task3CustomIons.Contains(ProductType.c) && task3CustomIons.Contains(ProductType.zDot) && task3CustomIons.Contains(ProductType.b) && task3CustomIons.Count == 3);

            Directory.Delete(outputFolder, true);
        }
        public static void PostSearchNormalizeTest()
        {
            SearchTask searchTask = new SearchTask()
            {
                SearchParameters = new SearchParameters
                {
                    Normalize = true
                },
            };

            string myFile     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PrunedDbSpectra.mzml");
            string myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DbForPrunedDb.fasta");
            string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestNormalization");
            string filePath   = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\ExperimentalDesign.tsv");

            using (StreamWriter output = new StreamWriter(filePath))
            {
                output.WriteLine("FileName\tCondition\tBiorep\tFraction\tTechrep");
                output.WriteLine("PrunedDbSpectra" + "\t" + "condition" + "\t" + "1" + "\t" + "1" + "\t" + "1");
            }
            DbForTask db = new DbForTask(myDatabase, false);

            Directory.CreateDirectory(folderPath);

            searchTask.RunTask(folderPath, new List <DbForTask> {
                db
            }, new List <string> {
                myFile
            }, "normal");

            File.Delete(filePath);

            Assert.That(() => searchTask.RunTask(folderPath, new List <DbForTask> {
                db
            }, new List <string> {
                myFile
            }, "normal"),
                        Throws.TypeOf <MetaMorpheusException>());
            Directory.Delete(folderPath, true);
        }
Esempio n. 9
0
        public static void SemiSpecificFullAndSmallMatches()
        {
            SearchTask searchTask = new SearchTask()
            {
                SearchParameters = new SearchParameters
                {
                    SearchType         = SearchType.NonSpecific,
                    LocalFdrCategories = new List <FdrCategory>
                    {
                        FdrCategory.FullySpecific,
                        FdrCategory.SemiSpecific
                    }
                },
                CommonParameters = new CommonParameters(addCompIons: true, scoreCutoff: 11,
                                                        digestionParams: new DigestionParams(minPeptideLength: 7, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.N))
            };

            string    myFile     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\tinySemi.mgf");
            string    myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\semiTest.fasta");
            DbForTask db         = new DbForTask(myDatabase, false);

            List <(string, MetaMorpheusTask)> taskList = new List <(string, MetaMorpheusTask)> {
                ("TestSemiSpecificSmall", searchTask)
            };

            var engine = new EverythingRunnerEngine(taskList, new List <string> {
                myFile
            }, new List <DbForTask> {
                new DbForTask(myDatabase, false)
            }, Environment.CurrentDirectory);

            engine.Run();

            string outputPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSemiSpecificSmall\AllPSMs.psmtsv");
            var    output     = File.ReadAllLines(outputPath);

            Assert.IsTrue(output.Length == 3);
        }
        public void VariantSpecificOutputFiles()
        {
            string thisTaskOutputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantFileOutput");

            SearchTask task = Toml.ReadFile <SearchTask>(Path.Combine(TestContext.CurrentContext.TestDirectory, @"VariantSearchTaskConfig.toml"), MetaMorpheusTask.tomlConfig);

            task.SearchParameters.DecoyType = DecoyType.None;

            DbForTask noVariantDb                    = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestNoVariantDb.xml"), false);
            DbForTask frameshiftVariantDb            = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantDB_frameshift.xml"), false);
            DbForTask missenseVariantDb              = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantDB_missense.xml"), false);
            DbForTask stopGainedVariantDb            = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantDB_stopGained.xml"), false);
            DbForTask conservativeInsertionVariantDb = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantDB_conservativeInsertion.xml"), false);
            DbForTask disruptiveInsertionVariantDb   = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantDB_disruptiveInsertion.xml"), false);
            DbForTask conservativeDeletionVariantDb  = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantDB_conservativeDeletion.xml"), false);
            DbForTask disruptiveDeletionVariantDb    = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantDB_disruptiveDeletion.xml"), false);
            DbForTask stopLossVariantDb              = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantDB_stopLoss.xml"), false);

            string raw = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestVariantPep.mzML");

            EverythingRunnerEngine noVariants = new EverythingRunnerEngine(new List <(string, MetaMorpheusTask)> {
                ("NoVariantOutput", task)
            }, new List <string> {
Esempio n. 11
0
        public static void TestIndividualFileOutput()
        {
            string subFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"IndividualOutputTest");

            Directory.CreateDirectory(subFolder);
            string     outputFolder   = Path.Combine(subFolder, "Results");
            SearchTask allowFilesTask = new SearchTask();

            allowFilesTask.SearchParameters.WriteIndividualFiles    = true;
            allowFilesTask.SearchParameters.CompressIndividualFiles = false;

            SearchTask compressFilesTask = new SearchTask();

            compressFilesTask.SearchParameters.WriteIndividualFiles    = true;
            compressFilesTask.SearchParameters.CompressIndividualFiles = true;

            SearchTask noFilesTask = new SearchTask();

            noFilesTask.SearchParameters.WriteIndividualFiles = false;

            PeptideWithSetModifications       pwsm  = new PeptideWithSetModifications("AAFNSGK", null);
            List <(string, MetaMorpheusTask)> tasks = new List <(string, MetaMorpheusTask)> {
                ("allowFiles", allowFilesTask), ("compressFiles", compressFilesTask), ("noFiles", noFilesTask)
            };
            DbForTask db = new DbForTask(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "gapdh.fasta"), false);

            TestDataFile datafile = new TestDataFile(pwsm);
            string       pathOne  = Path.Combine(subFolder, "fileOne.mzml");
            string       pathTwo  = Path.Combine(subFolder, "fileTwo.mzml");

            MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(datafile, pathOne, false);
            MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(datafile, pathTwo, false);

            new EverythingRunnerEngine(tasks, new List <string> {
                pathOne, pathTwo
            }, new List <DbForTask> {
                db
            }, outputFolder).Run();

            //check that the first task wrote everything fine
            HashSet <string> expectedFiles = new HashSet <string>
            {
                ".mzID",
                "_Peptides.psmtsv",
                "_ProteinGroups.tsv",
                "_PSMs.psmtsv",
                "_PSMsFormattedForPercolator.tab",
                "_QuantifiedPeaks.tsv"
            };
            HashSet <string> writtenFiles = new HashSet <string>(Directory.GetFiles(Path.Combine(outputFolder, "allowFiles", "Individual File Results")).Select(v => Path.GetFileName(v).Substring(7)));

            //check they're the same
            Assert.IsTrue(expectedFiles.Except(writtenFiles).Count() == 0);

            //check the second one is compressed and contains all the information
            writtenFiles = new HashSet <string>(Directory.GetFiles(Path.Combine(outputFolder, "compressFiles")).Select(v => Path.GetFileName(v)));
            //check the zip exists
            Assert.IsTrue(writtenFiles.Contains("Individual File Results.zip"));
            //check the original folder does not exist
            string[] subfolders = Directory.GetDirectories(Path.Combine(outputFolder, "compressFiles"));
            Assert.IsTrue(subfolders.Length == 0);
            ZipFile.ExtractToDirectory(Path.Combine(outputFolder, "compressFiles", "Individual File Results.zip"), Path.Combine(outputFolder, "compressFiles", "Individual File Results"));
            //read the extracted files
            writtenFiles = new HashSet <string>(Directory.GetFiles(Path.Combine(outputFolder, "compressFiles", "Individual File Results")).Select(v => Path.GetFileName(v).Substring(7)));
            //check they're the same
            Assert.IsTrue(expectedFiles.Except(writtenFiles).Count() == 0);

            //check the last one to make sure nothing was written except for the mzID files
            writtenFiles = new HashSet <string>(Directory.GetFiles(Path.Combine(outputFolder, "noFiles", "Individual File Results")).Select(v => Path.GetFileName(v).Substring(7)));
            Assert.IsTrue(writtenFiles.Count == 1);
            Assert.IsTrue(writtenFiles.Contains(".mzID"));

            Directory.Delete(outputFolder, true);

            //Do a check that we don't crash if there's only one file but somebody tries to zip the individual file results
            SearchTask weirdTask = new SearchTask();

            weirdTask.SearchParameters.CompressIndividualFiles = true;
            weirdTask.SearchParameters.WriteMzId = false;
            new EverythingRunnerEngine(new List <(string, MetaMorpheusTask)> {
                ("weird", weirdTask)
            }, new List <string> {
Esempio n. 12
0
        public static void TestAutodetectDissocationTypeFromScanHeader()
        {
            SearchTask searchTask = new SearchTask()
            {
                SearchParameters = new SearchParameters
                {
                    DoQuantification = false // quant disabled just to save some time
                },

                // use DissociationType.Autodetect as the dissociation type. this signals to the search that the dissociation type
                // should be taken from the scan header on a scan-specific basis
                CommonParameters = new CommonParameters(dissociationType: DissociationType.Autodetect)
            };

            string myFile     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SmallCalibratible_Yeast.mzML");
            string myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\smalldb.fasta");
            string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestAutodetectDissocationTypeFromScanHeader");

            DbForTask db = new DbForTask(myDatabase, false);

            // run the task
            var autoTaskFolder = Path.Combine(folderPath, @"Autodetect");

            Directory.CreateDirectory(autoTaskFolder);
            searchTask.RunTask(autoTaskFolder, new List <DbForTask> {
                db
            }, new List <string> {
                myFile
            }, "");

            // run identical task but select the HCD dissociation type instead of autodetect
            var hcdTaskFolder = Path.Combine(folderPath, @"HCD");

            Directory.CreateDirectory(hcdTaskFolder);
            searchTask = new SearchTask()
            {
                SearchParameters = new SearchParameters
                {
                    DoQuantification = false
                },

                CommonParameters = new CommonParameters(dissociationType: DissociationType.HCD)
            };

            searchTask.RunTask(hcdTaskFolder, new List <DbForTask> {
                db
            }, new List <string> {
                myFile
            }, "");

            // check search results
            var psmFileAutodetect = File.ReadAllLines(Path.Combine(autoTaskFolder, "AllPSMs.psmtsv"));
            var psmFileHcd        = File.ReadAllLines(Path.Combine(hcdTaskFolder, "AllPSMs.psmtsv"));

            Assert.That(psmFileAutodetect.Length == psmFileHcd.Length);

            for (int i = 0; i < psmFileAutodetect.Length; i++)
            {
                Assert.That(psmFileAutodetect[i].Equals(psmFileHcd[i]));
            }

            // clean up
            Directory.Delete(folderPath, true);
        }
Esempio n. 13
0
        public static void InternalFragmentIonTest()
        {
            SearchTask searchTask = new SearchTask()
            {
                SearchParameters = new SearchParameters
                {
                    MinAllowedInternalFragmentLength = 1
                },
                CommonParameters = new CommonParameters(
                    digestionParams: new DigestionParams("top-down"),
                    listOfModsVariable: new List <(string, string)> {
                    ("Common Variable", "Oxidation on M"),
                    ("Common Biological", "Acetylation on K"),
                    ("Common Biological", "Acetylation on X")
                })
            };

            string    myFile     = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\InternalTest.mgf");
            string    myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\InternalTest.fasta");
            DbForTask db         = new DbForTask(myDatabase, false);

            List <(string, MetaMorpheusTask)> taskList = new List <(string, MetaMorpheusTask)> {
                ("TestInternal", searchTask)
            };


            var engine = new EverythingRunnerEngine(taskList, new List <string> {
                myFile
            }, new List <DbForTask> {
                new DbForTask(myDatabase, false)
            }, Environment.CurrentDirectory);

            engine.Run();

            string outputPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestInternal\AllPSMs.psmtsv");
            //var output = File.ReadAllLines(outputPath);
            //read the psmtsv
            List <PsmFromTsv> psms = PsmTsvReader.ReadTsv(outputPath, out var warning);

            Assert.IsTrue(psms.Count == 1);
            //check that it's been disambiguated
            Assert.IsFalse(psms[0].FullSequence.Contains("|"));
            int numTotalFragments = psms[0].MatchedIons.Count;

            //test again but no variable acetyl on K. Make sure that internal fragments are still searched even without ambiguity
            searchTask = new SearchTask()
            {
                SearchParameters = new SearchParameters
                {
                    MinAllowedInternalFragmentLength = 1
                },
                CommonParameters = new CommonParameters(
                    digestionParams: new DigestionParams("top-down"),
                    listOfModsVariable: new List <(string, string)> {
                    ("Common Variable", "Oxidation on M"),
                    ("Common Biological", "Acetylation on X")
                })
            };
            taskList = new List <(string, MetaMorpheusTask)> {
                ("TestInternal", searchTask)
            };
            engine = new EverythingRunnerEngine(taskList, new List <string> {
                myFile
            }, new List <DbForTask> {
                new DbForTask(myDatabase, false)
            }, Environment.CurrentDirectory);
            engine.Run();
            psms = PsmTsvReader.ReadTsv(outputPath, out warning);
            Assert.IsTrue(psms.Count == 1);
            Assert.IsTrue(psms[0].MatchedIons.Count == numTotalFragments);

            Directory.Delete(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestInternal"), true);
        }
Esempio n. 14
0
 public ProteinDbForDataGrid(DbForTask uu)
 {
     Use         = true;
     Contaminant = uu.IsContaminant;
     FilePath    = uu.FilePath;
 }