コード例 #1
0
        public static HashSet <string> GetTags(string fileName, bool isProteinFile)
        {
            HashSet <string> result = new HashSet <string>();

            using (StreamReader sr = new StreamReader(fileName))
            {
                if (isProteinFile)
                {
                    sr.ReadLine();
                }
                var line     = sr.ReadLine();
                var parts    = line.Split('\t');
                var tagIndex = Array.IndexOf(parts, "Tag");
                if (tagIndex >= 0)
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (isProteinFile && IdentifiedResultUtils.IsProteinLine(line))
                        {
                            continue;
                        }

                        parts = line.Split('\t');
                        if (parts.Length <= tagIndex)
                        {
                            break;
                        }

                        result.Add(parts[tagIndex]);
                    }
                }
            }

            return(result);
        }
コード例 #2
0
        public HashSet <string> ReadFromFile(string fileName)
        {
            HashSet <string> result = new HashSet <string>();

            SequestFilename sf = new SequestFilename();

            using (StreamReader sr = new StreamReader(fileName))
            {
                //ignore header lines
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] parts = line.Trim().Split(chars);
                    try
                    {
                        sf.ShortFileName = parts[0];
                        break;
                    }
                    catch (Exception)
                    { }
                }

                if (line != null)
                {
                    result.Add(sf.Experimental);
                }

                while ((line = sr.ReadLine()) != null)
                {
                    line = line.Trim();

                    if (line.Length == 0)
                    {
                        break;
                    }

                    if (IdentifiedResultUtils.IsProteinLine(line))
                    {
                        continue;
                    }

                    string[] parts = line.Split(chars);
                    sf.ShortFileName = parts[0];

                    result.Add(sf.Experimental);
                }
            }

            return(result);
        }
コード例 #3
0
        private IIdentifiedProteinGroup ReadNextProteinGroup(StreamReader filein, Dictionary <string, IIdentifiedSpectrum> peptideMap, ref string lastLine)
        {
            Progress.SetPosition(filein.BaseStream.Position);

            while (!IdentifiedResultUtils.IsProteinLine(lastLine) && (lastLine = filein.ReadLine()) != null)
            {
            }

            if (lastLine == null)
            {
                return(null);
            }

            IIdentifiedProteinGroup result = new IdentifiedProteinGroup();

            while (IdentifiedResultUtils.IsProteinLine(lastLine))
            {
                IIdentifiedProtein protein = ProteinFormat.ParseString(lastLine);
                result.Add(protein);

                protein.GroupIndex = IdentifiedResultUtils.GetGroupIndex(lastLine);

                lastLine = filein.ReadLine();
            }

            List <IIdentifiedSpectrum> peptides = new List <IIdentifiedSpectrum>();

            while (!IdentifiedResultUtils.IsProteinLine(lastLine))
            {
                if (Progress.IsCancellationPending())
                {
                    throw new UserTerminatedException();
                }

                IIdentifiedSpectrum mphit = PeptideFormat.ParseString(lastLine);

                string id = string.Format("{0}-{1}-{2}-{3}", mphit.Query.FileScan.LongFileName, mphit.Rank, mphit.Engine, mphit.Tag);

                if (!peptideMap.ContainsKey(id))
                {
                    peptideMap[id] = mphit;
                }
                else
                {
                    mphit = peptideMap[id];
                }

                peptides.Add(mphit);

                lastLine = filein.ReadLine();

                if (lastLine == null || lastLine.Trim().Length == 0)
                {
                    break;
                }
            }

            foreach (IIdentifiedSpectrum hit in peptides)
            {
                result.AddIdentifiedSpectrum(hit);
            }

            return(result);
        }