コード例 #1
0
        /// <summary>
        /// Creates a PeptideWithSetModifications object from a sequence string.
        /// Useful for reading in MetaMorpheus search engine output into mzLib objects.
        /// </summary>
        public PeptideWithSetModifications(string sequence, Dictionary <string, Modification> allKnownMods, int numFixedMods = 0,
                                           DigestionParams digestionParams         = null, Protein p = null, int oneBasedStartResidueInProtein = int.MinValue,
                                           int oneBasedEndResidueInProtein         = int.MinValue, int missedCleavages = int.MinValue,
                                           CleavageSpecificity cleavageSpecificity = CleavageSpecificity.Full, string peptideDescription = null)
            : base(p, oneBasedStartResidueInProtein, oneBasedEndResidueInProtein, missedCleavages, cleavageSpecificity, peptideDescription)
        {
            if (sequence.Contains("|"))
            {
                throw new MzLibUtil.MzLibException("Ambiguous peptide cannot be parsed from string: " + sequence);
            }

            FullSequence = sequence;
            GetModsAfterDeserialization(allKnownMods, out _baseSequence);
            NumFixedMods     = numFixedMods;
            _digestionParams = digestionParams;

            if (p != null)
            {
                ProteinAccession = p.Accession;
            }
            if (digestionParams != null)
            {
                DigestionParamString = digestionParams.ToString();
            }
        }
コード例 #2
0
 /// <summary>
 /// Initializes digestion object
 /// </summary>
 /// <param name="digestionParams"></param>
 /// <param name="allKnownFixedModifications"></param>
 /// <param name="variableModifications"></param>
 public ProteinDigestion(DigestionParams digestionParams, IEnumerable <Modification> allKnownFixedModifications, List <Modification> variableModifications)
 {
     DigestionParams             = digestionParams;
     Protease                    = digestionParams.Protease;
     MaximumMissedCleavages      = digestionParams.MaxMissedCleavages;
     InitiatorMethionineBehavior = digestionParams.InitiatorMethionineBehavior;
     MinPeptidesLength           = digestionParams.MinPeptideLength;
     MaxPeptidesLength           = digestionParams.MaxPeptideLength;
     AllKnownFixedModifications  = allKnownFixedModifications ?? new List <Modification>();
     VariableModifications       = variableModifications ?? new List <Modification>();
 }
コード例 #3
0
        private readonly string ProteinAccession; // used to get protein object after deserialization

        /// <summary>
        /// Creates a PeptideWithSetModifications object from a protein. Used when a Protein is digested.
        /// </summary>
        public PeptideWithSetModifications(Protein protein, DigestionParams digestionParams, int oneBasedStartResidueInProtein,
                                           int oneBasedEndResidueInProtein, CleavageSpecificity cleavageSpecificity, string peptideDescription, int missedCleavages,
                                           Dictionary <int, Modification> allModsOneIsNterminus, int numFixedMods, string baseSequence = null)
            : base(protein, oneBasedStartResidueInProtein, oneBasedEndResidueInProtein, missedCleavages, cleavageSpecificity, peptideDescription, baseSequence)
        {
            _allModsOneIsNterminus = allModsOneIsNterminus;
            NumFixedMods           = numFixedMods;
            _digestionParams       = digestionParams;
            DetermineFullSequence();
            ProteinAccession = protein.Accession;
            UpdateCleavageSpecificity();
        }
コード例 #4
0
        private readonly string ProteinAccession;     // used to get protein object after deserialization

        /// <summary>
        /// Creates a PeptideWithSetModifications object from a protein. Used when a Protein is digested.
        /// </summary>
        public PeptideWithSetModifications(Protein protein, DigestionParams digestionParams, int oneBasedStartResidueInProtein,
                                           int oneBasedEndResidueInProtein, string peptideDescription, int missedCleavages,
                                           Dictionary <int, Modification> allModsOneIsNterminus, int numFixedMods)
            : base(protein, oneBasedStartResidueInProtein, oneBasedEndResidueInProtein, missedCleavages, peptideDescription)
        {
            _allModsOneIsNterminus = allModsOneIsNterminus;
            NumFixedMods           = numFixedMods;
            _digestionParams       = digestionParams;
            DetermineFullSequence();
            ProteinAccession     = protein.Accession;
            DigestionParamString = digestionParams.ToString();
        }
コード例 #5
0
        public override bool Equals(object obj)
        {
            DigestionParams a = obj as DigestionParams;

            return(a != null &&
                   this.MaxMissedCleavages.Equals(a.MaxMissedCleavages) &&
                   this.MinPeptideLength.Equals(a.MinPeptideLength) &&
                   this.MaxPeptideLength.Equals(a.MaxPeptideLength) &&
                   this.InitiatorMethionineBehavior.Equals(a.InitiatorMethionineBehavior) &&
                   this.MaxModificationIsoforms.Equals(a.MaxModificationIsoforms) &&
                   this.MaxModsForPeptide.Equals(a.MaxModsForPeptide) &&
                   this.Protease.Equals(a.Protease) &&
                   this.SemiProteaseDigestion.Equals(a.SemiProteaseDigestion) &&
                   this.TerminusTypeSemiProtease.Equals(a.TerminusTypeSemiProtease));
        }
コード例 #6
0
 /// <summary>
 /// This should be run after deserialization of a PeptideWithSetModifications, in order to set its Protein and Modification objects, which were not serialized
 /// </summary>
 public void SetNonSerializedPeptideInfo(Dictionary <string, Modification> idToMod, Dictionary <string, Protein> accessionToProtein, DigestionParams dp)
 {
     GetModsAfterDeserialization(idToMod);
     GetProteinAfterDeserialization(accessionToProtein);
     _digestionParams = dp;
 }
コード例 #7
0
        /// <summary>
        /// Gets the peptides for a specific protein interval
        /// </summary>
        /// <param name="interval"></param>
        /// <param name="allKnownFixedModifications"></param>
        /// <param name="digestionParams"></param>
        /// <param name="variableModifications"></param>
        /// <returns></returns>
        internal IEnumerable <PeptideWithSetModifications> GetModifiedPeptides(IEnumerable <Modification> allKnownFixedModifications,
                                                                               DigestionParams digestionParams, List <Modification> variableModifications)
        {
            int peptideLength = OneBasedEndResidueInProtein - OneBasedStartResidueInProtein + 1;
            int maximumVariableModificationIsoforms = digestionParams.MaxModificationIsoforms;
            int maxModsForPeptide = digestionParams.MaxModsForPeptide;
            var twoBasedPossibleVariableAndLocalizeableModifications = new Dictionary <int, List <Modification> >(peptideLength + 4);

            var pepNTermVariableMods = new List <Modification>();

            twoBasedPossibleVariableAndLocalizeableModifications.Add(1, pepNTermVariableMods);

            var pepCTermVariableMods = new List <Modification>();

            twoBasedPossibleVariableAndLocalizeableModifications.Add(peptideLength + 2, pepCTermVariableMods);

            foreach (Modification variableModification in variableModifications)
            {
                // Check if can be a n-term mod
                if (CanBeNTerminalMod(variableModification, peptideLength) && !ModificationLocalization.UniprotModExists(Protein, 1, variableModification))
                {
                    pepNTermVariableMods.Add(variableModification);
                }

                for (int r = 0; r < peptideLength; r++)
                {
                    if (ModificationLocalization.ModFits(variableModification, Protein.BaseSequence, r + 1, peptideLength, OneBasedStartResidueInProtein + r) &&
                        variableModification.LocationRestriction == "Anywhere." && !ModificationLocalization.UniprotModExists(Protein, r + 1, variableModification))
                    {
                        if (!twoBasedPossibleVariableAndLocalizeableModifications.TryGetValue(r + 2, out List <Modification> residueVariableMods))
                        {
                            residueVariableMods = new List <Modification> {
                                variableModification
                            };
                            twoBasedPossibleVariableAndLocalizeableModifications.Add(r + 2, residueVariableMods);
                        }
                        else
                        {
                            residueVariableMods.Add(variableModification);
                        }
                    }
                }
                // Check if can be a c-term mod
                if (CanBeCTerminalMod(variableModification, peptideLength) && !ModificationLocalization.UniprotModExists(Protein, peptideLength, variableModification))
                {
                    pepCTermVariableMods.Add(variableModification);
                }
            }

            // LOCALIZED MODS
            foreach (var kvp in Protein.OneBasedPossibleLocalizedModifications)
            {
                bool inBounds = kvp.Key >= OneBasedStartResidueInProtein && kvp.Key <= OneBasedEndResidueInProtein;
                if (!inBounds)
                {
                    continue;
                }

                int locInPeptide = kvp.Key - OneBasedStartResidueInProtein + 1;
                foreach (Modification modWithMass in kvp.Value)
                {
                    if (modWithMass is Modification variableModification)
                    {
                        // Check if can be a n-term mod
                        if (locInPeptide == 1 && CanBeNTerminalMod(variableModification, peptideLength) && !Protein.IsDecoy)
                        {
                            pepNTermVariableMods.Add(variableModification);
                        }

                        int r = locInPeptide - 1;
                        if (r >= 0 && r < peptideLength &&
                            (Protein.IsDecoy ||
                             (ModificationLocalization.ModFits(variableModification, Protein.BaseSequence, r + 1, peptideLength, OneBasedStartResidueInProtein + r) &&
                              variableModification.LocationRestriction == "Anywhere.")))
                        {
                            if (!twoBasedPossibleVariableAndLocalizeableModifications.TryGetValue(r + 2, out List <Modification> residueVariableMods))
                            {
                                residueVariableMods = new List <Modification> {
                                    variableModification
                                };
                                twoBasedPossibleVariableAndLocalizeableModifications.Add(r + 2, residueVariableMods);
                            }
                            else
                            {
                                residueVariableMods.Add(variableModification);
                            }
                        }

                        // Check if can be a c-term mod
                        if (locInPeptide == peptideLength && CanBeCTerminalMod(variableModification, peptideLength) && !Protein.IsDecoy)
                        {
                            pepCTermVariableMods.Add(variableModification);
                        }
                    }
                }
            }

            int variable_modification_isoforms = 0;

            foreach (Dictionary <int, Modification> kvp in GetVariableModificationPatterns(twoBasedPossibleVariableAndLocalizeableModifications, maxModsForPeptide, peptideLength))
            {
                int numFixedMods = 0;
                foreach (var ok in GetFixedModsOneIsNterminus(peptideLength, allKnownFixedModifications))
                {
                    if (!kvp.ContainsKey(ok.Key))
                    {
                        numFixedMods++;
                        kvp.Add(ok.Key, ok.Value);
                    }
                }
                yield return(new PeptideWithSetModifications(Protein, digestionParams, OneBasedStartResidueInProtein, OneBasedEndResidueInProtein,
                                                             CleavageSpecificityForFdrCategory, PeptideDescription, MissedCleavages, kvp, numFixedMods));

                variable_modification_isoforms++;
                if (variable_modification_isoforms == maximumVariableModificationIsoforms)
                {
                    yield break;
                }
            }
        }