示例#1
0
        public void AddPsm(PSM psm)
        {
            if (BestMatch == null)
            {
                BestMatch = psm;
            }
            else
            {
                if (psm.Score < BestMatch.Score)
                {
                    BestMatch = psm;
                }
                else if (psm.Score.FussyEquals(BestMatch.Score))
                {
                    if (Math.Abs(psm.CorrectedPrecursorMassError) < CorrectedPrecursorErrorPPM)
                    {
                        BestMatch = psm;
                    }
                }
            }

            // Be conservative, if the peptide sequence is both forward and decoy, favor decoy
            if (psm.IsDecoy)
            {
                IsDecoy = true;
            }
            PSMs.Add(psm);
        }
示例#2
0
        public void Read(IList <Modification> fixedModifications, int numberOfTopHits = 1, bool higherScoresAreBetter = false)
        {
            _data.Clear();
            bool first = true;

            using (CsvReader reader = new CsvReader(new StreamReader(FilePath), true))
            {
                string[] headers = reader.GetFieldHeaders();
                HasPPMInfo = headers.Contains("Precursor Mass Error (ppm)");
                while (reader.ReadNextRecord())
                {
                    if (first)
                    {
                        RawFileName = reader["Filename/id"].Split('.')[0];
                        first       = false;
                    }

                    int scanNumber = int.Parse(reader["Spectrum number"]);

                    PSM psm = new PSM(scanNumber)
                    {
                        Score = double.Parse(reader["E-value"])
                    };
                    SortedMaxSizedContainer <PSM> peptides;
                    if (!_data.TryGetValue(scanNumber, out peptides))
                    {
                        peptides = new SortedMaxSizedContainer <PSM>(numberOfTopHits);
                        _data.Add(scanNumber, peptides);
                    }

                    if (!peptides.Add(psm))
                    {
                        continue;
                    }
                    psm.FileName = reader["Filename/id"];
                    psm.Charge   = int.Parse(reader["Charge"]);
                    psm.IsDecoy  = reader["Defline"].StartsWith("DECOY_");
                    if (HasPPMInfo)
                    {
                        psm.PrecursorMassError = double.Parse(reader["Precursor Mass Error (ppm)"]);
                    }
                    psm.SetSequenceAndMods(reader["Peptide"].ToUpper(), fixedModifications, reader["Mods"]);
                }
            }

            PeptideSpectralMatches.Clear();
            foreach (SortedMaxSizedContainer <PSM> set in _data.Values)
            {
                PeptideSpectralMatches.AddRange(set);
            }
        }
示例#3
0
文件: PSM.cs 项目: trishorts/Compass
 public int CompareTo(PSM other)
 {
     return(Score.CompareTo(other.Score));
 }
示例#4
0
 public Peptide(PSM psm)
 {
     PSMs    = new List <PSM>();
     IsDecoy = false;
     AddPsm(psm);
 }