Esempio n. 1
0
        public void TestKeepDistinctPeptideOnly()
        {
            var spectrum1 = new IdentifiedSpectrum();
            var pep1      = spectrum1.NewPeptide();

            var spectrum2 = new IdentifiedSpectrum();
            var pep2      = spectrum2.NewPeptide();

            var spectrum3 = new IdentifiedSpectrum();
            var pep3      = spectrum3.NewPeptide();

            var spectrum4 = new IdentifiedSpectrum();
            var pep4      = spectrum4.NewPeptide();

            var protein1 = new IdentifiedProtein();

            protein1.Peptides.Add(pep1);
            protein1.Peptides.Add(pep2);

            var protein2 = new IdentifiedProtein();

            protein2.Peptides.Add(pep1);
            protein2.Peptides.Add(pep3);

            var protein3 = new IdentifiedProtein();

            protein3.Peptides.Add(pep2);
            protein3.Peptides.Add(pep4);

            var g1 = new IdentifiedProteinGroup();

            g1.Add(protein1);

            var g2 = new IdentifiedProteinGroup();

            g2.Add(protein2);

            var g3 = new IdentifiedProteinGroup();

            g3.Add(protein3);

            IIdentifiedResult ir = new IdentifiedResult();

            ir.Add(g1);
            ir.Add(g2);
            ir.Add(g3);

            new DistinctResultDistiller().KeepDistinctPeptideOnly(ir);

            Assert.AreEqual(2, ir.Count);
            Assert.AreEqual(g2, ir[0]);
            Assert.AreEqual(g3, ir[1]);

            Assert.AreEqual(1, ir[0].GetPeptides().Count);
            Assert.AreEqual(spectrum3, ir[0].GetPeptides()[0]);

            Assert.AreEqual(1, ir[1].GetPeptides().Count);
            Assert.AreEqual(spectrum4, ir[1].GetPeptides()[0]);
        }
    public void TestKeepDistinctPeptideOnly()
    {
      var spectrum1 = new IdentifiedSpectrum();
      var pep1 = spectrum1.NewPeptide();

      var spectrum2 = new IdentifiedSpectrum();
      var pep2 = spectrum2.NewPeptide();

      var spectrum3 = new IdentifiedSpectrum();
      var pep3 = spectrum3.NewPeptide();

      var spectrum4 = new IdentifiedSpectrum();
      var pep4 = spectrum4.NewPeptide();

      var protein1 = new IdentifiedProtein();
      protein1.Peptides.Add(pep1);
      protein1.Peptides.Add(pep2);

      var protein2 = new IdentifiedProtein();
      protein2.Peptides.Add(pep1);
      protein2.Peptides.Add(pep3);

      var protein3 = new IdentifiedProtein();
      protein3.Peptides.Add(pep2);
      protein3.Peptides.Add(pep4);

      var g1 = new IdentifiedProteinGroup();
      g1.Add(protein1);

      var g2 = new IdentifiedProteinGroup();
      g2.Add(protein2);

      var g3 = new IdentifiedProteinGroup();
      g3.Add(protein3);

      IIdentifiedResult ir = new IdentifiedResult();
      ir.Add(g1);
      ir.Add(g2);
      ir.Add(g3);

      new DistinctResultDistiller().KeepDistinctPeptideOnly(ir);

      Assert.AreEqual(2, ir.Count);
      Assert.AreEqual(g2, ir[0]);
      Assert.AreEqual(g3, ir[1]);

      Assert.AreEqual(1, ir[0].GetPeptides().Count);
      Assert.AreEqual(spectrum3, ir[0].GetPeptides()[0]);

      Assert.AreEqual(1, ir[1].GetPeptides().Count);
      Assert.AreEqual(spectrum4, ir[1].GetPeptides()[0]);
    }
        private IIdentifiedSpectrum ParsePeptide(string line)
        {
            IIdentifiedSpectrum result = new IdentifiedSpectrum();

            string[] parts = line.Split(splits);
            result.Query.FileScan.Experimental = parts[bestLocalizationRawFileIndex];
            result.Query.FileScan.FirstScan    = int.Parse(parts[bestLocalizationScanNumberIndex]);
            result.Query.FileScan.LastScan     = result.Query.FileScan.FirstScan;
            result.Query.FileScan.Charge       = int.Parse(parts[chargeIndex]);
            result.Score       = MyConvert.ToDouble(parts[scoreIndex]);
            result.DeltaScore  = MyConvert.ToDouble(parts[scoreDiffIndex]);
            result.ExpectValue = MyConvert.ToDouble(parts[pepIndex]);
            result.Probability = MyConvert.ToDouble(parts[localizationProbIndex]);

            string seq           = parts[sequenceWindowIndex];
            string modifications = parts[modificationWindowIndex];

            seq = GetModifiedSequence(seq, modifications);
            seq = seq.Replace("_", "");

            Match m = modReg.Match(seq);

            if (m.Success)
            {
                while (m.Success)
                {
                    string mod = m.Groups[1].Value;
                    if (!modCharMap.ContainsKey(mod))
                    {
                        modCharMap[mod] = ModificationConsts.MODIFICATION_CHAR.Substring(modCharMap.Count + 1, 1);
                    }
                    m = m.NextMatch();
                }

                seq = ReplaceModificationStringToChar(seq);
            }

            result.NewPeptide().Sequence = seq;

            StringBuilder sb = new StringBuilder();

            foreach (var mod in modCharMap)
            {
                if (seq.Contains(mod.Value))
                {
                    sb.Append(MyConvert.Format("{0}={1};", mod.Value, mod.Key));
                }
            }
            result.Modifications = sb.ToString();

            return(result);
        }