コード例 #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)));
                }
            }
        }
        private void ResetSpectrumFactory()
        {
            var formatScore = StringUtils.GetDoubleFormat(this.ScoreDecimal);
            var formatDiff  = StringUtils.GetDoubleFormat(this.DiffDecimal);

            var factory = IdentifiedSpectrumPropertyConverterFactory.GetInstance();

            factory.InsertConverter(new IdentifiedSpectrumTheoreticalMinusExperimentalMassConverter <IIdentifiedSpectrum>(formatDiff));
            factory.InsertConverter(new IdentifiedSpectrumScoreConverter <IIdentifiedSpectrum>(formatScore));
            this.format.PeptideFormat.Factory = factory;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public List <IIdentifiedSpectrum> ReadFromFile(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException("File not exist : " + filename);
            }

            var result = new List <IIdentifiedSpectrum>();

            long fileSize = new FileInfo(filename).Length;

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

                    PeptideFormat = new LineFormat <IIdentifiedSpectrum>(IdentifiedSpectrumPropertyConverterFactory.GetInstance(),
                                                                         line, "sequest");

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

                        Progress.SetPosition(br.BaseStream.Position);

                        result.Add(PeptideFormat.ParseString(line));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(MyConvert.Format("Reading from file {0} error :\n" + ex.Message, filename), ex);
            }

            string enzymeFile = filename + ".enzyme";

            if (File.Exists(enzymeFile))
            {
                new ProteaseFile().Fill(enzymeFile, result);
            }

            return(result);
        }
コード例 #5
0
        public O18QuantificationSummaryViewerUI()
        {
            InitializeComponent();

            this.Text = Constants.GetSQHTitle(title, version);

            this.exportFile = new SaveFileArgument("O18 Quantification Result", "ProO18Quant");

            InitializeSummaryFile();

            var factory = IdentifiedSpectrumPropertyConverterFactory.GetInstance();

            factory.InsertConverter(new IdentifiedSpectrumTheoreticalMinusExperimentalMassConverter <IIdentifiedSpectrum>("{0:0.000}"));
            factory.InsertConverter(new IdentifiedSpectrumScoreConverter <IIdentifiedSpectrum>("{0:0}"));

            this.format.PeptideFormat = new LineFormat <IIdentifiedSpectrum>(factory, "");
        }
コード例 #6
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 SilacQuantificationSummaryViewerUI()
        {
            InitializeComponent();

            Text = Constants.GetSQHTitle(title, version);

            this.calc = new SilacProteinRatioCalculator();

            this.option = new SilacQuantificationSummaryOption();

            this.exportFile = new SaveFileArgument("SILAC Quantification Result", "ProSILACQuant");

            InitializeSummaryFile();

            var factory = IdentifiedSpectrumPropertyConverterFactory.GetInstance();

            factory.InsertConverter(new IdentifiedSpectrumTheoreticalMinusExperimentalMassConverter <IIdentifiedSpectrum>("{0:0.000}"));
            factory.InsertConverter(new IdentifiedSpectrumScoreConverter <IIdentifiedSpectrum>("{0:0}"));

            this.format.PeptideFormat = new LineFormat <IIdentifiedSpectrum>(factory, "");

            this.proteinRSquare.Box.TextChanged += ProteinRSquareChanged;
            this.peptideRSquare.Box.TextChanged += PeptideRSquareChanged;
        }
        public override IEnumerable <string> Process(string fileName)
        {
            var ratioResult = fileName + ".dist";

            using (StreamReader sr = new StreamReader(fileName))
                using (StreamWriter sw = new StreamWriter(ratioResult))
                {
                    var header        = sr.ReadLine();
                    var peptideFormat = new LineFormat <IIdentifiedSpectrum>(IdentifiedSpectrumPropertyConverterFactory.GetInstance(), header, "mascot");
                    var spectrum      = peptideFormat.ParseString(sr.ReadLine());
                    var itemList      = spectrum.GetMaxQuantItemList();
                    sw.Write("Peptide");
                    foreach (var func in funcs)
                    {
                        foreach (var item in itemList)
                        {
                            sw.Write("\t" + func.Name + ' ' + item.Name);
                        }
                    }
                    sw.WriteLine();

                    while (spectrum != null)
                    {
                        var curItem = spectrum.GetMaxQuantItemList();
                        if (curItem.QuantifiedExperimentCount >= minCount)
                        {
                            StringBuilder sb = new StringBuilder(spectrum.Peptide.Sequence);

                            bool bHasValue = false;
                            foreach (var func in funcs)
                            {
                                foreach (var item in curItem)
                                {
                                    var value = func.ItemFunc(item);

                                    if (value == string.Empty)
                                    {
                                        sb.Append("\tNA");
                                    }
                                    else
                                    {
                                        bHasValue = true;
                                        sb.AppendFormat("\t{0}", value);
                                    }
                                }
                            }

                            if (bHasValue)
                            {
                                sw.WriteLine(sb.ToString());
                            }
                        }

                        string line = sr.ReadLine();
                        if (line == null)
                        {
                            break;
                        }

                        spectrum = peptideFormat.ParseString(line);
                    }

                    return(new[] { ratioResult });
                }
        }
コード例 #9
0
 public SequestPeptideTextFormat(string header)
 {
     this.PeptideFormat = new LineFormat <IIdentifiedSpectrum>(
         IdentifiedSpectrumPropertyConverterFactory.GetInstance(), header, "sequest");
 }
コード例 #10
0
 public SequestPeptideTextFormat()
 {
     this.PeptideFormat = new LineFormat <IIdentifiedSpectrum>(
         IdentifiedSpectrumPropertyConverterFactory.GetInstance(), SequestHeader.SEQUEST_PEPTIDE_HEADER, "sequest");
 }