示例#1
0
        private static CensusPeptideItem Parse(string line)
        {
            var result = new CensusPeptideItem();

            if (line.StartsWith("S\t"))
            {
                result.Singleton = false;
            }
            else if (line.StartsWith("&S\t"))
            {
                result.Singleton = true;
            }
            else
            {
                return(null);
            }

            string[] parts = line.Split(new[] { '\t' });
            if (parts.Length < 13)
            {
                return(null);
            }

            result.Unique = parts[1];

            result.Sequence = parts[2];

            result.Ratio = MyConvert.ToDouble(parts[3]);

            result.RegressionFactor = MyConvert.ToDouble(parts[4]);

            result.DeterminantFactor = MyConvert.ToDouble(parts[5]);

            result.Score = MyConvert.ToDouble(parts[6]);

            result.DeltaScore = MyConvert.ToDouble(parts[7]);

            result.SampleIntensity = MyConvert.ToDouble(parts[8]);

            result.ReferenceIntensity = MyConvert.ToDouble(parts[9]);

            result.AreaRatio = MyConvert.ToDouble(parts[10]);

            result.SingletonScore = MyConvert.ToDouble(parts[11]);

            if (parts[12].EndsWith("."))
            {
                result.Filename = SequestFilename.Parse(parts[12]);
            }
            else
            {
                result.Filename = SequestFilename.Parse(parts[12] + ".");
            }

            return(result);
        }
示例#2
0
        public bool IsSameChro(CensusPeptideItem another)
        {
            if (null == another)
            {
                return(false);
            }

            return(Filename.Experimental.Equals(another.Filename.Experimental) &&
                   Filename.Charge.Equals(another.Filename.Charge) &&
                   Sequence.Equals(another.Sequence) &&
                   Ratio.Equals(another.Ratio) &&
                   SampleIntensity.Equals(another.SampleIntensity) &&
                   ReferenceIntensity.Equals(another.ReferenceIntensity));
        }
        private List <CensusProteinItem> ReadProteins(string filename)
        {
            var result     = new List <CensusProteinItem>();
            var peptideMap = new Dictionary <string, CensusPeptideItem>();

            var lastItem = new CensusProteinItem();

            using (var sr = new StreamReader(filename))
            {
                string lastLine = sr.ReadLine();
                while (lastLine != null)
                {
                    lastLine = lastLine.Trim();

                    if (lastLine.StartsWith("S") || (lastLine.StartsWith("&S") && this.readSingleton))
                    {
                        CensusPeptideItem pepItem = this.peptideFormat.ParseString(lastLine);
                        if (pepItem.Ratio != 0.0)
                        {
                            string longFilename = pepItem.Filename.LongFileName;
                            if (peptideMap.ContainsKey(longFilename))
                            {
                                lastItem.Peptides.Add(peptideMap[longFilename]);
                            }
                            else
                            {
                                peptideMap[longFilename] = pepItem;
                                lastItem.Peptides.Add(pepItem);
                            }
                        }
                    }
                    else if (lastLine.StartsWith("P"))
                    {
                        lastItem = this.proteinFormat.ParseString(lastLine);
                        result.Add(lastItem);
                    }

                    lastLine = sr.ReadLine();
                }
            }

            result.ForEach(m => m.ValidatePeptides());

            result.RemoveAll(m => m.Peptides.Count == 0);

            return(result);
        }
        public List <CensusPeptideItem> ReadPeptides(string filename)
        {
            var peptideMap = new Dictionary <string, CensusPeptideItem>();

            List <string> headers = CensusUtils.ReadHeaders(filename);

            InitFormat(headers);

            using (var sr = new StreamReader(filename))
            {
                string lastLine;
                while ((lastLine = sr.ReadLine()) != null)
                {
                    lastLine = lastLine.Trim();

                    if (lastLine.StartsWith("S") || lastLine.StartsWith("&S"))
                    {
                        CensusPeptideItem pepItem = this.peptideFormat.ParseString(lastLine);
                        if (pepItem.Ratio != 0.0)
                        {
                            string longFilename = pepItem.Filename.LongFileName;
                            if (peptideMap.ContainsKey(longFilename))
                            {
                                continue;
                            }
                            else
                            {
                                peptideMap[longFilename] = pepItem;
                            }
                        }
                    }
                }
            }

            return(new List <CensusPeptideItem>(peptideMap.Values));
        }