Beispiel #1
0
        public void TestReadWrite()
        {
            var ann = new IdentifiedProtein();

            var pqr = new ProteinQuantificationResult();

            pqr.Items["D1"] = new QuantificationItem()
            {
                Enabled            = true,
                Ratio              = 1.5,
                SampleIntensity    = 150,
                ReferenceIntensity = 100,
                Correlation        = 0.9,
                ScanCount          = 55,
                Filename           = "test1.silac"
            };

            pqr.Items["D2"] = new QuantificationItem()
            {
                Enabled            = false,
                Ratio              = 3,
                SampleIntensity    = 250,
                ReferenceIntensity = 200,
                Correlation        = 0.8,
                ScanCount          = 77,
                Filename           = "test2.silac"
            };

            ann.Annotations[SilacQuantificationConstants.SILAC_KEY] = pqr;

            var converter = new SilacProteinQuantificationResultConverter2 <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, ',');

            Assert.AreEqual("S_COUNT,SE_D1,SR_D1,SRC_D1,SSI_D1,SRI_D1,SE_D2,SR_D2,SRC_D2,SSI_D2,SRI_D2", finalConverter.Name);

            var line1 = finalConverter.GetProperty(ann);

            Assert.AreEqual("2,True,1.5000,0.9000,150.0,100.0,False,3.0000,0.8000,250.0,200.0", line1);

            var protein2 = new IdentifiedProtein();
            var finalC   = IdentifiedProteinPropertyConverterFactory.GetInstance().GetConverters(finalConverter.Name, ',');

            finalC.SetProperty(protein2, line1);

            var line2 = finalConverter.GetProperty(protein2);

            Assert.AreEqual(line1, line2);
        }
    public void TestReadWrite()
    {
      var ann = new IdentifiedProtein();

      var pqr = new ProteinQuantificationResult();
      
      pqr.Items["D1"] = new QuantificationItem()
      {
        Enabled = true,
        Ratio = 1.5,
        SampleIntensity = 150,
        ReferenceIntensity = 100,
        Correlation = 0.9,
        ScanCount = 55,
        Filename = "test1.silac"
      };

      pqr.Items["D2"] = new QuantificationItem()
      {
        Enabled = false,
        Ratio = 3,
        SampleIntensity = 250,
        ReferenceIntensity = 200,
        Correlation = 0.8,
        ScanCount = 77,
        Filename = "test2.silac"
      };

      ann.Annotations[SilacQuantificationConstants.SILAC_KEY] = pqr;

      var converter = new SilacProteinQuantificationResultConverter2<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, ',');

      Assert.AreEqual("S_COUNT,SE_D1,SR_D1,SRC_D1,SSI_D1,SRI_D1,SE_D2,SR_D2,SRC_D2,SSI_D2,SRI_D2", finalConverter.Name);

      var line1 = finalConverter.GetProperty(ann);
      Assert.AreEqual("2,True,1.5000,0.9000,150.0,100.0,False,3.0000,0.8000,250.0,200.0", line1);

      var protein2 = new IdentifiedProtein();
      var finalC = IdentifiedProteinPropertyConverterFactory.GetInstance().GetConverters(finalConverter.Name, ',');
      finalC.SetProperty(protein2, line1);

      var line2 = finalConverter.GetProperty(protein2);
      Assert.AreEqual(line1, line2);
    }
        public override IEnumerable <string> Process(string filename)
        {
            string        resultFile = filename + ".SILACsummary";
            FileInfo      resultFI   = new FileInfo(resultFile);
            DirectoryInfo detailDir  = new DirectoryInfo(resultFI.DirectoryName + "\\" + resultFI.Name + ".details");

            if (!detailDir.Exists)
            {
                detailDir.Create();
            }

            builder.Progress = this.Progress;

            IIdentifiedResult sr = resultFormat.ReadFromFile(filename);

            var spectra = sr.GetSpectra();

            builder.Quantify(spectra, detailDir.FullName);

            SilacQuantificationSummaryOption option = new SilacQuantificationSummaryOption()
            {
                MinimumPeptideRSquare = this.MinPeptideRegressionCorrelation
            };

            spectra.ForEach(m =>
            {
                m.SetEnabled(option.IsPeptideRatioValid(m) && !option.IsPeptideOutlier(m));

                var dupSpectra = m.GetDuplicatedSpectra();

                dupSpectra.ForEach(n => n.SetEnabled(option.IsPeptideRatioValid(n) && !option.IsPeptideOutlier(n)));
            });

            var calc = new ExtendSilacProteinRatioCalculator();

            Dictionary <string, string> datasetMap = new Dictionary <string, string>();

            foreach (var ds in datasets)
            {
                var lst = ds.Value;
                lst.ForEach(m => datasetMap[m] = ds.Key);
            }

            foreach (IIdentifiedProteinGroup mpg in sr)
            {
                var realSpectra = new List <IIdentifiedSpectrum>(mpg.GetPeptides());
                foreach (var spectrum in realSpectra)
                {
                    var dupSpectra = spectrum.GetDuplicatedSpectra();
                    mpg.AddIdentifiedSpectra(dupSpectra);
                }

                ProteinQuantificationResult pr = new ProteinQuantificationResult();
                foreach (var ds in datasets)
                {
                    var lst = ds.Value;

                    pr.Items[ds.Key] = calc.Calculate(mpg, m => lst.Contains(m.Query.FileScan.Experimental));
                }

                bool valid = pr.Items.Values.FirstOrDefault(m => m.Enabled) != null;
                foreach (IIdentifiedProtein protein in mpg)
                {
                    protein.SetEnabled(valid);
                    protein.Annotations[SilacQuantificationConstants.SILAC_KEY] = pr;
                }
            }

            var finalSpectra = sr.GetSpectra();

            finalSpectra.ForEach(m => m.SetDataset(datasetMap[m.Query.FileScan.Experimental]));

            resultFormat.InitializeByResult(sr);
            resultFormat.WriteToFile(resultFile, sr);

            return(new[] { resultFile });
        }