public void TestFilter()
    {
      var pro1 = new IdentifiedProtein("P1");
      pro1.Peptides.Add(new IdentifiedPeptide(new IdentifiedSpectrum() { Charge = 1 }));
      pro1.Peptides.Add(new IdentifiedPeptide(new IdentifiedSpectrum() { Charge = 2 }));

      var pro2 = new IdentifiedProtein("P2");
      pro2.Peptides.Add(new IdentifiedPeptide(new IdentifiedSpectrum() { Charge = 3 }));

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

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

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

      Assert.AreEqual(2, ir.Count);
      Assert.AreEqual(3, ir.GetSpectra().Count);

      ir.Filter(m => { return m.Spectrum.Query.Charge > 1; });

      Assert.AreEqual(2, ir.Count);
      Assert.AreEqual(2, ir.GetSpectra().Count);
      ir.GetSpectra().All(m => { return m.Charge > 1; });

      ir.Filter(m => { return m.Spectrum.Query.Charge > 2; });
      Assert.AreEqual(1, ir.Count);
      Assert.AreEqual(1, ir.GetSpectra().Count);
      ir.GetSpectra().All(m => { return m.Charge > 2; });

      Assert.AreEqual("P2", ir[0][0].Name);
    }
    public void Run()
    {
      IdentifiedProteinGroupContaminationDescriptionFilter filter = new IdentifiedProteinGroupContaminationDescriptionFilter("KERATIN");
      IdentifiedProteinGroup group = new IdentifiedProteinGroup();
      group.Add(new IdentifiedProtein("P1")
      {
        Description = "P1 Keratin"
      });

      Assert.IsTrue(filter.Accept(group));
    }
    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 TestProcess()
    {
      IIdentifiedProteinGroup group = new IdentifiedProteinGroup();
      group.Add(new IdentifiedProtein("BBBCCC"));
      group.Add(new IdentifiedProtein("AAABBB"));

      IIdentifiedProteinGroup finalGroup;
      
      ///两者都有,两个都保留
      finalGroup = new ProteinNameProcessor(new string[]{"BBB"}).Process(group);
      Assert.AreEqual(2, finalGroup.Count);

      ///两者都没有,两个都保留
      finalGroup = new ProteinNameProcessor(new string[] { "DDD" }).Process(group);
      Assert.AreEqual(2, finalGroup.Count);

      ///只有一个有,保留这一个
      finalGroup = new ProteinNameProcessor(new string[] { "AAA" }).Process(group);
      Assert.AreEqual(1, finalGroup.Count);
      Assert.AreEqual("AAABBB", finalGroup[0].Name);
    }
    public void TestFilter2()
    {
      var spectrum = new IdentifiedSpectrum();
      spectrum.Query.FileScan.LongFileName = "ABDCDD.12.123.2.dat";

      var pro1 = new IdentifiedProtein("P1");
      pro1.Peptides.Add(new IdentifiedPeptide(spectrum) { Sequence = "AAAAAAA" });

      var pro2 = new IdentifiedProtein("P2");
      pro2.Peptides.Add(new IdentifiedPeptide(spectrum) { Sequence = "BBBBBBB" });

      var g1 = new IdentifiedProteinGroup();
      g1.Add(pro1);
      g1.Add(pro2);

      IdentifiedResult ir = new IdentifiedResult();
      ir.Add(g1);

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

      ir.Filter(m =>
      {
        return m.Sequence.Contains('A');
      });

      Assert.AreEqual(1, ir.Count);
      Assert.AreEqual(1, ir[0].Count);
      Assert.AreEqual(1, ir.GetSpectra().Count);
      Assert.AreSame(pro1, ir[0][0]);

      ir.Filter(m =>
      {
        return m.Sequence.Contains('C');
      });

      Assert.AreEqual(0, ir.Count);
    }
Example #6
0
    public void TestGetAnnotationKeys()
    {
      string key1 = "TEST1";
      string key2 = "TEST2";

      var mph1 = new IdentifiedSpectrum();
      mph1.Annotations.Add(key1, null);
      mph1.Query.FileScan.Experimental = "EXP1";
      new IdentifiedPeptide(mph1);

      var mph2 = new IdentifiedSpectrum();
      mph2.Annotations.Add(key2, null);
      mph2.Query.FileScan.Experimental = "EXP2";
      new IdentifiedPeptide(mph2);

      mph1.Peptide.Sequence = "SEQ1";
      mph2.Peptide.Sequence = "SEQ2";

      var protein = new IdentifiedProtein();
      protein.Peptides.Add(mph1.Peptide);
      protein.Peptides.Add(mph2.Peptide);

      var mpg = new IdentifiedProteinGroup();
      mpg.Add(protein);

      var mr = new MascotResult();
      mr.Add(mpg);

      List<string> annotationKeys = AnnotationUtils.GetAnnotationKeys(mr.GetSpectra());
      Assert.AreEqual(2, annotationKeys.Count);
      Assert.IsTrue(annotationKeys.Contains(key1));
      Assert.IsTrue(annotationKeys.Contains(key2));
    }