Example #1
0
        private bool AddModificationsAndComputeMass(SearchResultsBaseClass searchResult, bool updateModOccurrenceCounts)
        {
            const bool ALLOW_DUPLICATE_MOD_ON_TERMINUS = true;

            bool success;

            try
            {
                // Assume success for now
                success = true;

                // If any modifications of type IsotopicMod are defined, add them to the Search Result Mods now
                searchResult.SearchResultAddIsotopicModifications(updateModOccurrenceCounts);

                // Parse .PeptideSequenceWithMods to determine the modified residues present
                if (!AddDynamicAndStaticResidueMods(searchResult, updateModOccurrenceCounts))
                {
                    success = false;
                }

                // Add the protein and peptide terminus static mods (if defined and if the peptide is at a protein terminus)
                // Since Sequest allows a terminal peptide residue to be modified twice, we'll allow that to happen,
                //  even though, biologically, that's typically not possible
                // However, there are instances where this is possible, e.g. methylation of D or E on the C-terminus
                //  (where two COOH groups are present)
                searchResult.SearchResultAddStaticTerminusMods(ALLOW_DUPLICATE_MOD_ON_TERMINUS, updateModOccurrenceCounts);

                // Compute the monoisotopic mass for this peptide
                searchResult.ComputeMonoisotopicMass();

                // Populate .PeptideModDescription
                searchResult.UpdateModDescription();
            }
            catch (Exception)
            {
                success = false;
            }

            return(success);
        }
Example #2
0
        private bool AddDynamicAndStaticResidueMods(
            SearchResultsBaseClass searchResult,
            bool updateModOccurrenceCounts)
        {
            // Step through .PeptideSequenceWithMods
            // For each residue, check if a static mod is defined that affects that residue
            // For each mod symbol, determine the modification and add to searchResult

            var mostRecentLetter    = '-';
            var residueLocInPeptide = 0;

            // Assume success for now
            var success = true;

            var sequenceWithMods = searchResult.PeptideSequenceWithMods;

            for (var index = 0; index <= sequenceWithMods.Length - 1; index++)
            {
                var character = sequenceWithMods[index];

                if (StringUtilities.IsLetterAtoZ(character))
                {
                    mostRecentLetter = character;
                    residueLocInPeptide++;

                    for (var modIndex = 0; modIndex <= mPeptideMods.ModificationCount - 1; modIndex++)
                    {
                        if (mPeptideMods.GetModificationTypeByIndex(modIndex) == ModificationDefinition.ResidueModificationType.StaticMod)
                        {
                            var modificationDefinition = mPeptideMods.GetModificationByIndex(modIndex);

                            if (modificationDefinition.TargetResiduesContain(character))
                            {
                                // Match found; add this modification
                                var residueTerminusState = searchResult.DetermineResidueTerminusState(residueLocInPeptide);

                                success = searchResult.SearchResultAddModification(
                                    modificationDefinition, character, residueLocInPeptide,
                                    residueTerminusState, updateModOccurrenceCounts);

                                if (!success)
                                {
                                    // Error adding this static mod
                                    SetErrorCode(PHRPErrorCode.UnspecifiedError);
                                    mErrorMessage = "Error calling searchResult.SearchResultAddModification for peptide '" + sequenceWithMods + "': " + searchResult.ErrorMessage;
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (StringUtilities.IsLetterAtoZ(mostRecentLetter))
                {
                    success = searchResult.SearchResultAddDynamicModification(character, mostRecentLetter, residueLocInPeptide, searchResult.DetermineResidueTerminusState(residueLocInPeptide), updateModOccurrenceCounts);

                    if (!success)
                    {
                        // Error adding this dynamic mod
                        SetErrorCode(PHRPErrorCode.UnspecifiedError);
                        mErrorMessage = "Error calling searchResult.SearchResultAddDynamicModification for peptide '" + sequenceWithMods + "': " + searchResult.ErrorMessage;
                        break;
                    }
                }
                else
                {
                    // We found a modification symbol but mostRecentLetter is not a letter
                    // Therefore, this modification symbol is at the beginning of the string; ignore the symbol
                }
            }

            return(success);
        }