private void CheckPlexType(IsobaricType plexType, string expectHeader, string expectValue)
    {
      var ann = new IdentifiedSpectrum();

      var pqr = new IsobaricItem()
      {
        PlexType = plexType,
        Valid = true,
        ValidProbability = 0.0005
      };

      var refItems = plexType.GetDefinition().Items;
      foreach (var item in refItems)
      {
        pqr[item.Index] = item.Mass;
      }

      ann.SetIsobaricItem(pqr);

      //从实例构建converter
      var converter = new ITraqItemPlexConverter<IAnnotation>();
      List<IPropertyConverter<IAnnotation>> converters = new List<IPropertyConverter<IAnnotation>>();
      converters.Add(converter);
      converters.AddRange(converter.GetRelativeConverter(new IAnnotation[] { ann }.ToList()));
      CompositePropertyConverter<IAnnotation> finalConverter = new CompositePropertyConverter<IAnnotation>(converters, ',');

      if (exportToConsole)
      {
        Console.WriteLine(finalConverter.Name);
      }
      Assert.AreEqual(expectHeader, finalConverter.Name);

      var line1 = finalConverter.GetProperty(ann);
      if (exportToConsole)
      {
        Console.WriteLine(line1);
      }
      Assert.AreEqual(expectValue, line1);

      var protein2 = new IdentifiedSpectrum();

      //从factory根据header构建converter
      var finalC = IdentifiedSpectrumPropertyConverterFactory.GetInstance().GetConverters(finalConverter.Name, ',');
      finalC.SetProperty(protein2, line1);

      var line2 = finalConverter.GetProperty(protein2);
      Assert.AreEqual(line1, line2);
    }
        public void Test()
        {
            ITraqPhosphoRatioCalculator calc = new ITraqPhosphoRatioCalculator(116, 117, 114, 115);
            IsobaricItem item = new IsobaricItem()
            {
                PlexType = IsobaricType.PLEX4
            };

            item[114] = 1;
            item[115] = 1;
            item[116] = 1;
            item[117] = 1;

            Assert.IsTrue(calc.Valid(item));

            item[116] = ITraqConsts.NULL_INTENSITY;
            Assert.IsFalse(calc.Valid(item));

            item[116] = 1;
            item[117] = ITraqConsts.NULL_INTENSITY;
            Assert.IsFalse(calc.Valid(item));
        }
    public void Test()
    {
      ITraqPhosphoRatioCalculator calc = new ITraqPhosphoRatioCalculator(116, 117, 114, 115);
      IsobaricItem item = new IsobaricItem()
      {
        PlexType =  IsobaricType.PLEX4
      };

      item[114] = 1;
      item[115] = 1;
      item[116] = 1;
      item[117] = 1;

      Assert.IsTrue(calc.Valid(item));

      item[116] = ITraqConsts.NULL_INTENSITY;
      Assert.IsFalse(calc.Valid(item));

      item[116] = 1;
      item[117] = ITraqConsts.NULL_INTENSITY;
      Assert.IsFalse(calc.Valid(item));
    }
    public void Setup()
    {
      t1 = new IsobaricItem()
      {
        Experimental = "S1",
        ScanMode = "HCD",
        PlexType = IsobaricType.PLEX4,
        PrecursorPercentage = 0.85,
        Scan = new ScanTime(255, 3.4),
        RawPeaks = new PeakList<Peak>(new Peak[] { new Peak(114.1, 114.1), new Peak(115.1, 115.1), new Peak(116.1, 116.1), new Peak(117.1, 117.1) }.ToList()),
        PeakInIsolationWindow = new PeakList<Peak>(new Peak[] { new Peak(214.1, 114.1), new Peak(215.1, 115.1), new Peak(216.1, 116.1), new Peak(217.1, 117.1) }.ToList())
        {
          Precursor = new PrecursorPeak()
          {
            MasterScan = 1,
            Charge = 2,
            Intensity = 3.0,
            IsolationMass = 1800.1,
            IsolationWidth = 2.0,
            MonoIsotopicMass = 1879.1
          }
        }
      };

      t1[114] = 4.5;
      t1[115] = 5.5;
      t1[116] = 6.5;
      t1[117] = 7.5;

      t2 = new IsobaricItem()
      {
        Experimental = "S2",
        ScanMode = "ETD",
        PlexType = IsobaricType.PLEX8,
        PrecursorPercentage = 0.33,
        Scan = new ScanTime(355, 4.4),
        RawPeaks = new PeakList<Peak>(new Peak[] { new Peak(114.1, 1114.1), new Peak(115.1, 1115.1), new Peak(116.1, 1116.1), new Peak(117.1, 1117.1) }.ToList()),
        PeakInIsolationWindow = new PeakList<Peak>(new Peak[] { new Peak(1214.1, 114.1), new Peak(1215.1, 115.1), new Peak(1216.1, 116.1), new Peak(1217.1, 117.1) }.ToList())
        {
          Precursor = new PrecursorPeak()
          {
            MasterScan = 3,
            Charge = 3,
            Intensity = 4.0,
            IsolationMass = 2800.1,
            IsolationWidth = 3.0,
            MonoIsotopicMass = 2879.1
          }
        }
      };

      t2[113] = 3.5;
      t2[114] = 4.5;
      t2[115] = 5.5;
      t2[116] = 6.5;
      t2[117] = 7.5;
      t2[118] = 8.5;
      t2[119] = 9.5;
      t2[121] = 11.5;

      tr = new IsobaricResult();
      tr.Mode = "PQD";
      tr.Add(t1);
      tr.Add(t2);
    }