示例#1
0
        public void WriteToFile(string proteinFile, IIdentifiedResult mr)
        {
            if (this.proteinConverter == null)
            {
                this.proteinConverter =
                    IdentifiedProteinPropertyConverterFactory.GetInstance().GetConverters(
                        "Locus\tSequence Count\tSpectrum Count\tSequence Coverage\tLength\tMolWt\tpI\tValidation Status\tDescriptive Name",
                        '\t', "Dtaselect");
                this.peptideConverter =
                    IdentifiedSpectrumPropertyConverterFactory.GetInstance().GetConverters(
                        "Unique\tFileName\tScore\tDeltCN\tM+H+\tCalcM+H+\tTotalIntensity\tSpRank\tSpScore\tIonProportion\tRedundancy\tSequence",
                        '\t', "Dtaselect");
            }

            using (var sw = new StreamWriter(proteinFile))
            {
                sw.WriteLine("DTASelect v1.9");
                sw.WriteLine();
                sw.WriteLine("true	Use criteria");
                sw.WriteLine();
                sw.WriteLine(this.proteinConverter.Name);
                sw.WriteLine(this.peptideConverter.Name);

                foreach (IdentifiedProteinGroup mpg in mr)
                {
                    for (int proteinIndex = 0; proteinIndex < mpg.Count; proteinIndex++)
                    {
                        IIdentifiedProtein mpro = mpg[proteinIndex];
                        sw.WriteLine(this.proteinConverter.GetProperty(mpro));
                    }

                    mpg.GetSortedPeptides().ForEach(m => sw.WriteLine(this.peptideConverter.GetProperty(m)));
                }
            }
        }
        public List <IIdentifiedProtein> ReadFromFile(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException("File not exist : " + filename);
            }

            var result = new List <IIdentifiedProtein>();

            long fileSize = new FileInfo(filename).Length;

            Progress.SetRange(0, fileSize);
            using (var br = new StreamReader(filename))
            {
                String line = br.ReadLine();

                ProteinFormat = new LineFormat <IIdentifiedProtein>(IdentifiedProteinPropertyConverterFactory.GetInstance(), line, engineName);

                while ((line = br.ReadLine()) != null)
                {
                    if (0 == line.Trim().Length)
                    {
                        break;
                    }

                    Progress.SetPosition(br.BaseStream.Position);

                    result.Add(ProteinFormat.ParseString(line));
                }
            }

            return(result);
        }
示例#3
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);
        }
示例#4
0
        public IIdentifiedResult ReadFromFile(string proteinFile)
        {
            if (!File.Exists(proteinFile))
            {
                throw new FileNotFoundException("File not exist : " + proteinFile);
            }

            var result = new MascotResult();

            var peptideMap = new Dictionary <string, IIdentifiedSpectrum>();

            using (var filein = new StreamReader(proteinFile))
            {
                string lastLine;
                while ((lastLine = filein.ReadLine()) != null)
                {
                    if (lastLine.StartsWith("Locus"))
                    {
                        this.proteinConverter = IdentifiedProteinPropertyConverterFactory.GetInstance().GetConverters(lastLine, '\t',
                                                                                                                      "Dtaselect");
                    }

                    if (lastLine.StartsWith("Unique"))
                    {
                        this.peptideConverter = IdentifiedSpectrumPropertyConverterFactory.GetInstance().GetConverters(lastLine,
                                                                                                                       '\t',
                                                                                                                       "Dtaselect");
                        break;
                    }
                }

                IIdentifiedProteinGroup group;
                lastLine = null;
                while ((group = ReadNextProteinGroup(filein, peptideMap, ref lastLine)) != null)
                {
                    result.Add(group);
                }
            }

            return(result);
        }
        public void TestReadWrite()
        {
            var ann = new IdentifiedProtein();

            var pqr = new ITraqQuantificationResult();

            pqr.DatasetMap["D1"] = new ITraqQuantificationDatasetItem()
            {
                DatasetName = "D1"
            };

            pqr.DatasetMap["D1"].RatioMap["R114/REF"] = new ITraqQuantificationChannelItem()
            {
                ChannelName = "R114/REF",
                Ratio       = 1.5
            };

            pqr.DatasetMap["D1"].RatioMap["R115/REF"] = new ITraqQuantificationChannelItem()
            {
                ChannelName = "R115/REF",
                Ratio       = 1.8
            };

            pqr.DatasetMap["D2"] = new ITraqQuantificationDatasetItem()
            {
                DatasetName = "D2"
            };

            pqr.DatasetMap["D2"].RatioMap["R116/REF"] = new ITraqQuantificationChannelItem()
            {
                ChannelName = "R116/REF",
                Ratio       = 2.5
            };

            pqr.DatasetMap["D2"].RatioMap["R117/REF"] = new ITraqQuantificationChannelItem()
            {
                ChannelName = "R117/REF",
                Ratio       = 3.8
            };


            ann.Annotations[ITraqConsts.ITRAQ_KEY] = pqr;

            var converter = new ITraqQuantificationResultConverter <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("ITRAQ_COUNT,IR_D1_R114/REF,IR_D1_R115/REF,IR_D2_R116/REF,IR_D2_R117/REF", finalConverter.Name);

            var line1 = finalConverter.GetProperty(ann);

            if (exportToConsole)
            {
                Console.WriteLine(line1);
            }
            Assert.AreEqual("2,1.5000,1.8000,2.5000,3.8000", 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 MascotProteinTextReader2(string headers)
 {
     this.converter = IdentifiedProteinPropertyConverterFactory.GetInstance().GetConverters(headers, '\t');
 }