/// <summary>
 /// Remove a Protein-Spectrum-Match identification from the tree.
 /// </summary>
 /// <param name="id">Protein-Spectrum-Match to remove.</param>
 public void Remove(PrSm id)
 {
     if (Proteins.ContainsKey(id.ProteinName))
     {
         Proteins[id.ProteinName].Remove(id);
     }
 }
Exemple #2
0
 /// <summary>
 /// Remove a Protein-Spectrum-Match identification.
 /// </summary>
 /// <param name="id">Protein-Spectrum-Match to remove.</param>
 public void Remove(PrSm id)
 {
     if (this.ChargeStates.ContainsKey(id.Charge))
     {
         this.ChargeStates[id.Charge].Remove(id);
     }
 }
Exemple #3
0
 /// <summary>
 /// Remove a Protein-Spectrum-Match identification.
 /// </summary>
 /// <param name="id">Protein-Spectrum-Match to remove.</param>
 public void Remove(PrSm id)
 {
     if (Proteoforms.ContainsKey(id.SequenceText))
     {
         Proteoforms[id.SequenceText].Remove(id);
     }
 }
Exemple #4
0
 public ChargeStateId(PrSm prsm)
 {
     Charge      = prsm.Charge;
     ProteinName = prsm.ProteinName;
     ProteinDesc = prsm.ProteinDesc;
     Mass        = prsm.Mass;
     Mz          = prsm.PrecursorMz;
     PrSms       = new Dictionary <Tuple <int, string>, PrSm>();
 }
Exemple #5
0
        /// <summary>
        /// Remove a Protein-Spectrum-Match identification.
        /// </summary>
        /// <param name="id">Protein-Spectrum-Match to remove.</param>
        public void Remove(PrSm id)
        {
            var key = new Tuple <int, string>(id.Scan, id.RawFileName);

            if (PrSms.ContainsKey(key))
            {
                PrSms.Remove(key);
            }
        }
 /// <summary>
 /// Remove unidentified scans given a PRSM ID containing protein name, proteoform, and scan number.
 /// </summary>
 /// <param name="data">PRSM to remove.</param>
 public void RemoveUnidentifiedScan(PrSm data)
 {
     if (Proteins.TryGetValue(string.Empty, out var protein) &&
         protein.Proteoforms.TryGetValue(string.Empty, out var proteoform) &&
         proteoform.ChargeStates.TryGetValue(0, out var chargeState))
     {
         chargeState.Remove(data);
     }
 }
Exemple #7
0
        /// <summary>
        /// Add a Protein-Spectrum-Match identification.
        /// </summary>
        /// <param name="id">Protein-Spectrum-Math to add</param>
        public void Add(PrSm id)
        {
            if (!this.ChargeStates.ContainsKey(id.Charge))
            {
                this.ChargeStates.Add(id.Charge, new ChargeStateId(id));
            }

            var chargeState = this.ChargeStates[id.Charge];

            chargeState.Add(id);
        }
        /// <summary>
        /// Get a protein associated with a certain ID.
        /// </summary>
        /// <param name="id">ID to search for.</param>
        /// <returns>The protein ID found.</returns>
        public ProteinId GetProtein(PrSm id)
        {
            ProteinId protein = null;

            if (Proteins.ContainsKey(id.ProteinName))
            {
                protein = Proteins[id.ProteinName];
            }

            return(protein);
        }
Exemple #9
0
        /// <summary>
        /// Add a Protein-Spectrum-Match identification.
        /// </summary>
        /// <param name="id">Protein-Spectrum-Match to add</param>
        public void Add(PrSm id)
        {
            if (!Proteoforms.ContainsKey(id.SequenceText))
            {
                Proteoforms.Add(id.SequenceText, new ProteoformId(id, Sequence));
            }

            var proteoform = Proteoforms[id.SequenceText];

            proteoform.Add(id);
        }
Exemple #10
0
        /// <summary>
        /// Set the PRSM Identifications.
        /// </summary>
        /// <param name="ids">The PRSM identifications.</param>
        /// <param name="massTolerance">Mass tolerance.</param>
        public void SetIds(IEnumerable <PrSm> ids, double massTolerance = 0.1)
        {
            if (this.Features == null || this.Features.Length == 0)
            {
                return;
            }

            var idList       = ids.ToList();
            var prsmScanComp = new PrSm.PrSmScanComparer();

            idList.Sort(prsmScanComp);
            var minPrSm = new PrSm();
            var maxPrSm = new PrSm();

            foreach (var feature in this.Features.Where(feature => feature.AssociatedMs2.Count > 0))
            {   // Associate IDs with features
                minPrSm.Scan = feature.AssociatedMs2[0];
                maxPrSm.Scan = feature.AssociatedMs2[feature.AssociatedMs2.Count - 1];

                // Find IDs in the scan range of the feature.
                var minIdIndex = Math.Abs(idList.BinarySearch(minPrSm, prsmScanComp));
                var maxIdIndex = Math.Abs(idList.BinarySearch(maxPrSm, prsmScanComp));
                minIdIndex = Math.Min(Math.Max(minIdIndex - 1, 0), idList.Count - 1);
                maxIdIndex = Math.Min(Math.Max(maxIdIndex, 0) + 1, idList.Count - 1);

                // Find identified MS/MS scans associated with the feature
                var explainedMs2Scans = new HashSet <int>();
                feature.AssociatedPrSms.Clear();
                for (int i = minIdIndex; i < maxIdIndex; i++)
                {
                    if (Math.Abs(idList[i].Mass - feature.MinPoint.Mass) < massTolerance)
                    {
                        feature.AssociatedPrSms.Add(idList[i]);
                        if (!explainedMs2Scans.Contains(idList[i].Scan))
                        {
                            explainedMs2Scans.Add(idList[i].Scan);
                        }
                    }
                }

                // Find unidentified MS/MS scans associated with the feature
                foreach (var scan in feature.AssociatedMs2)
                {
                    if (!explainedMs2Scans.Contains(scan))
                    {
                        feature.AssociatedPrSms.Add(new PrSm {
                            LcMs = this.lcms, Scan = scan, Mass = feature.MinPoint.Mass
                        });
                    }
                }
            }
        }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProteoformId"/> class.
 /// This creates the proteform from a PRSM object.
 /// </summary>
 /// <param name="prsm">The PRSM to generate the ProteoformID from.</param>
 /// <param name="proteinSequence">The sequence of the protein that this Proteoform is associated with.</param>
 public ProteoformId(PrSm prsm, Sequence proteinSequence)
 {
     this.ProteinName  = prsm.ProteinName;
     this.ProteinDesc  = prsm.ProteinDesc;
     this.Mass         = prsm.Mass;
     this.Sequence     = prsm.Sequence;
     this.SequenceText = prsm.SequenceText;
     this.PreSequence  = string.Empty;
     this.PostSequence = string.Empty;
     this.ChargeStates = new Dictionary <int, ChargeStateId>();
     this.GenerateAnnotation(prsm.Sequence, proteinSequence, prsm.ModificationLocations);
     this.FormatSequences();
 }
Exemple #12
0
        /// <summary>
        /// Add a Protein-Spectrum-Match identification.
        /// </summary>
        /// <param name="id">Protein-Spectrum-Math to add</param>
        public void Add(PrSm id)
        {
            var key = new Tuple <int, string>(id.Scan, id.RawFileName);

            if (!PrSms.ContainsKey(key))
            {
                PrSms.Add(key, id);
            }
            else
            {
                PrSms[key] = id;
            }
        }
Exemple #13
0
        /// <summary>
        /// Remove unidentified scans given a PRSM ID containing protein name, proteoform, and scan number.
        /// </summary>
        /// <param name="data">PRSM to remove.</param>
        public void RemoveUnidentifiedScan(PrSm data)
        {
            ProteinId     protein;
            ProteoformId  proteoform;
            ChargeStateId chargeState;

            if (this.Proteins.TryGetValue(string.Empty, out protein) &&
                protein.Proteoforms.TryGetValue(string.Empty, out proteoform) &&
                proteoform.ChargeStates.TryGetValue(0, out chargeState))
            {
                chargeState.Remove(data);
            }
        }
Exemple #14
0
        /// <summary>
        /// Get the PRSM in the tree with the highest score.
        /// </summary>
        /// <returns>The PRSM with the highest score.</returns>
        public PrSm GetHighestScoringPrSm()
        {
            PrSm highest = null;

            foreach (var prsm in PrSms.Values)
            {
                if (!prsm.Score.Equals(double.NaN) && (highest == null || prsm.CompareTo(highest) >= 0))
                {
                    highest = prsm;
                }
            }

            return(highest);
        }
Exemple #15
0
        /// <summary>
        /// Get the PRSM in the tree with the highest score.
        /// </summary>
        /// <returns>The PRSM with the highest score.</returns>
        public PrSm GetHighestScoringPrSm()
        {
            PrSm highest = null;

            foreach (var chargeState in this.ChargeStates.Values)
            {
                var chargeStateHighest = chargeState.GetHighestScoringPrSm();
                if (highest == null || chargeStateHighest.CompareTo(highest) >= 0)
                {
                    highest = chargeStateHighest;
                }
            }

            return(highest);
        }
Exemple #16
0
        /// <summary>
        /// Get the PRSM in the tree with the highest score.
        /// </summary>
        /// <returns>The PRSM with the highest score.</returns>
        public PrSm GetHighestScoringPrSm()
        {
            PrSm highest = null;

            foreach (var proteoform in Proteoforms.Values)
            {
                var highestProtein = proteoform.GetHighestScoringPrSm();
                if (highest == null || highestProtein.CompareTo(highest) >= 0)
                {
                    highest = highestProtein;
                }
            }

            return(highest);
        }
        /// <summary>
        /// Get a proteoform associated with a certain ID.
        /// </summary>
        /// <param name="id">ID to search for.</param>
        /// <returns>The proteoform ID found.</returns>
        public ProteoformId GetProteoform(PrSm id)
        {
            var protein = GetProtein(id);

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

            ProteoformId proteoform = null;

            if (protein.Proteoforms.ContainsKey(id.SequenceText))
            {
                proteoform = protein.Proteoforms[id.SequenceText];
            }

            return(proteoform);
        }
        /// <summary>
        /// Get a charge state associated with a certain ID.
        /// </summary>
        /// <param name="id">ID to search for.</param>
        /// <returns>The charge state ID found.</returns>
        public ChargeStateId GetChargeState(PrSm id)
        {
            var proteoform = GetProteoform(id);

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

            ChargeStateId chargeState = null;

            if (proteoform.ChargeStates.ContainsKey(id.Charge))
            {
                chargeState = proteoform.ChargeStates[id.Charge];
            }

            return(chargeState);
        }
        /// <summary>
        /// Get PRSMs with the same Protein Name, Sequence, Charge, and Scan number
        /// </summary>
        /// <param name="id">PRSM object to search for</param>
        /// <returns>PRSM found in tree with parameters specified by data</returns>
        public PrSm GetPrSm(PrSm id)
        {
            var chargeState = GetChargeState(id);

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

            PrSm prsm = null;

            if (chargeState.Contains(id))
            {
                prsm = chargeState.PrSms[new Tuple <int, string>(id.Scan, id.RawFileName)];
            }

            return(prsm);
        }
        /// <summary>
        /// Add a Protein-Spectrum-Match identification.
        /// </summary>
        /// <param name="id">Protein-Spectrum-Math to add</param>
        public void Add(PrSm id)
        {
            RemoveUnidentifiedScan(id);

            if (!allProteins.ContainsKey(id.ProteinName))
            {
                return;
                ////this.allProteins.Add(id.ProteinName, new ProteinId(id.Sequence, id.ProteinName));
            }

            if (!Proteins.ContainsKey(id.ProteinName))
            {
                Proteins.Add(id.ProteinName, allProteins[id.ProteinName]);
            }

            var protein = Proteins[id.ProteinName];

            protein.Add(id);
        }
Exemple #21
0
 /// <summary>
 /// Determines whether the item contains a given identification.
 /// </summary>
 /// <param name="id">the ID to search for.</param>
 /// <returns>A value indicating whether the item contains the identification.</returns>
 public bool Contains(PrSm id)
 {
     return(this.ChargeStates.Values.Any(chargeState => chargeState.Contains(id)));
 }
 /// <summary>
 /// Determines whether the IDTree contains a given identification.
 /// </summary>
 /// <param name="id">the ID to search for.</param>
 /// <returns>A value indicating whether the IDTree contains the identification.</returns>
 public bool Contains(PrSm id)
 {
     return(Proteins.Values.Any(protein => protein.Contains(id)));
 }
Exemple #23
0
        /// <summary>
        /// Determines whether the item contains a given identification.
        /// </summary>
        /// <param name="id">the ID to search for.</param>
        /// <returns>A value indicating whether the item contains the identification.</returns>
        public bool Contains(PrSm id)
        {
            var key = new Tuple <int, string>(id.Scan, id.RawFileName);

            return(PrSms.ContainsKey(key));
        }
Exemple #24
0
 /// <summary>
 /// Determines whether the item contains a given identification.
 /// </summary>
 /// <param name="id">the ID to search for.</param>
 /// <returns>A value indicating whether the item contains the identification.</returns>
 public bool Contains(PrSm id)
 {
     return(Proteoforms.Values.Any(proteoform => proteoform.Contains(id)));
 }