Exemplo n.º 1
0
        public void TestCalculateQValue()
        {
            var peptides = new MascotPeptideTextFormat().ReadFromFile(TestContext.CurrentContext.TestDirectory + "/../../../data/QTOF_Ecoli.LowRes.t.xml.peptides");

            peptides.RemoveAll(m => m.ExpectValue > 0.05 || m.Peptide.PureSequence.Length < 6);
            peptides.ForEach(m => m.FromDecoy = m.Proteins.Any(l => l.Contains("REVERSE_")));

            IdentifiedSpectrumUtils.CalculateQValue(peptides, new ExpectValueFunction(), new TargetFalseDiscoveryRateCalculator());

            Assert.AreEqual(0.0267, peptides[0].QValue, 0.0001);
        }
Exemplo n.º 2
0
        public override IEnumerable <string> Process()
        {
            var evidences = new MascotPeptideTextFormat().ReadFromFile(options.InputFile);

            //Remove the PSM without mapped to proteins, usually it is from decoy database.
            evidences.RemoveAll(m => string.IsNullOrWhiteSpace(m.Annotations["Proteins"] as string));

            if (options.RemoveContanimant)
            {
                evidences.RemoveAll(m => (m.Annotations["Proteins"] as string).Contains("CON_"));
            }

            foreach (var spectrum in evidences)
            {
                ParseMaxQuantEvidencePeptide(spectrum);
            }

            new MascotPeptideTextFormat("\tFileScan\tSequence\tObs\tMH+\tDiff(MH+)\tDiffPPM\tCharge\tRank\tScore\tExpectValue\tReference\tMissCleavage\tModification\tMatchCount\tNumProteaseTermini").WriteToFile(options.OutputFile, evidences);

            return(new string[] { options.OutputFile });
        }
        public override IEnumerable <string> Process(string fileName)
        {
            var peps = new MascotPeptideTextFormat().ReadFromFile(fileName);

            peps.RemoveAll(m => !(m.Annotations["Number of Phospho (STY)"] as string).Equals("1"));

            var silac     = new MascotResultTextFormat().ReadFromFile(silacFile);
            var silacPeps = silac.GetSpectra();

            silacPeps.RemoveAll(m => m.GetQuantificationItem() == null || !m.GetQuantificationItem().HasRatio);

            Regex reg      = new Regex(@"Cx_(.+)");
            var   silacMap = silacPeps.ToGroupDictionary(m => m.Peptide.PureSequence + GetModificationCount(m.Peptide, "STY"));

            int found  = 0;
            int missed = 0;

            var matchFile = fileName + ".match";

            using (StreamWriter sw = new StreamWriter(matchFile))
            {
                sw.Write("Sequence");
                var mq = peps[0].GetMaxQuantItemList();
                foreach (var mqi in mq)
                {
                    sw.Write("\tm_" + mqi.Name);
                    sw.Write("\ts_" + mqi.Name);
                }
                sw.WriteLine();

                foreach (var p in peps)
                {
                    var pureSeqKey = p.Peptide.PureSequence + p.Annotations["Number of Phospho (STY)"].ToString();

                    if (silacMap.ContainsKey(pureSeqKey))
                    {
                        found++;
                        Console.WriteLine("Find - " + pureSeqKey);

                        var findPep    = silacMap[pureSeqKey];
                        var findPepMap = findPep.ToGroupDictionary(m => reg.Match(m.Query.FileScan.Experimental).Groups[1].Value);

                        mq = p.GetMaxQuantItemList();
                        sw.Write(p.Peptide.PureSequence);
                        foreach (var mqi in mq)
                        {
                            if (string.IsNullOrEmpty(mqi.Ratio))
                            {
                                sw.Write("\t");
                            }
                            else
                            {
                                sw.Write("\t{0:0.00}", Math.Log(MyConvert.ToDouble(mqi.Ratio)));
                            }

                            if (!findPepMap.ContainsKey(mqi.Name))
                            {
                                sw.Write("\t");
                            }
                            else
                            {
                                var spectra = findPepMap[mqi.Name];
                                spectra.Sort((m1, m2) => m2.GetQuantificationItem().Correlation.CompareTo(m1.GetQuantificationItem().Correlation));
                                sw.Write("\t{0:0.00}", -Math.Log(spectra[0].GetQuantificationItem().Ratio));
                            }
                        }
                        sw.WriteLine();
                    }
                    else
                    {
                        missed++;
                        Console.WriteLine("Missed - " + pureSeqKey);
                    }
                }
            }

            Console.WriteLine("Found = {0}; Missed = {1}", found, missed);
//      Regex reg =new Regex(@"Cx_(.+)");

            return(new string[] { });
        }
    public void TestCalculateQValue()
    {
      var peptides = new MascotPeptideTextFormat().ReadFromFile("../../../data/QTOF_Ecoli.LowRes.t.xml.peptides");
      peptides.RemoveAll(m => m.ExpectValue > 0.05 || m.Peptide.PureSequence.Length < 6);
      peptides.ForEach(m => m.FromDecoy = m.Proteins.Any(l => l.Contains("REVERSE_")));

      IdentifiedSpectrumUtils.CalculateQValue(peptides, new ExpectValueFunction(), new TargetFalseDiscoveryRateCalculator());

      Assert.AreEqual(0.0267, peptides[0].QValue, 0.0001);
    }