From 311a110f4630da6e2b9713ac9cc3408b15422a82 Mon Sep 17 00:00:00 2001 From: Ayesha-Feroz <94114994+Ayesha-Feroz@users.noreply.github.com> Date: Fri, 23 Feb 2024 15:36:40 +0100 Subject: [PATCH] Update peptides_proteins.rst restructured the documentation and checked for spacing, etc. --- docs/source/user_guide/peptides_proteins.rst | 114 +++++++++++-------- 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/docs/source/user_guide/peptides_proteins.rst b/docs/source/user_guide/peptides_proteins.rst index d1ee14908..748f34b96 100644 --- a/docs/source/user_guide/peptides_proteins.rst +++ b/docs/source/user_guide/peptides_proteins.rst @@ -331,56 +331,80 @@ an influence on :py:meth:`~.AASequence.getMonoWeight` and :py:meth:`~.AASequence Applying Fixed or Variable Modifications to Sequences ***************************************************** -In this tutorial, we will cover a step-by-step guide on how to use the pyopenms library to generate modified peptides from a given amino acid sequence. +In this tutorial, we will cover a step-by-step guide on how to use the `pyopenms` library to generate modified peptides from a given amino acid sequence. .. code-block:: python - :linenos: - import pyopenms as poms - -# Create an amino acid sequence using the fromString() method of the AASequence class. -# In this example, we will use the amino acid sequence "TESTMTECSTMTESTR" -sequence = poms.AASequence.fromString("TESTMTECSTMTESTR") - -# We use the names "Oxidation (M)" and "Carbamidomethyl (C)" for the variable and fixed modifications, respectively. -variable_mod_names = [b"Oxidation (M)"] -fixed_mod_names = [b"Carbamidomethyl (C)"] - -# We then use the getModifications() method of the ModifiedPeptideGenerator class to get the modifications for these names. -variable_modifications = poms.ModifiedPeptideGenerator.getModifications(variable_mod_names) -fixed_modifications = poms.ModifiedPeptideGenerator.getModifications(fixed_mod_names) - -# Apply the fixed modifications to the amino acid sequence -poms.ModifiedPeptideGenerator.applyFixedModifications(fixed_modifications, sequence) - -# Define the maximum number of variable modifications allowed -max_variable_mods = 1 - -# Generate the modified peptides -peptides_with_variable_modifications = [] -keep_unmodified_in_result = False -poms.ModifiedPeptideGenerator.applyVariableModifications(variable_modifications, sequence, max_variable_mods, - peptides_with_variable_modifications, - keep_unmodified_in_result) - -# Print the modified peptides generated using Fixed modifications and their mono-isotopic mass. -print("Fixed:", sequence.toString()) -print("Mono-isotopic mass:", sequence.getMonoWeight()) - -# Print the modified peptides generated using variable modifications and their mono-isotopic mass. -for peptide in peptides_with_variable_modifications: - print("Variable:", peptide.toString()) - print("Mono-isotopic mass:", peptide.getMonoWeight()) - + + import pyopenms as poms + +Create an amino acid sequence using the `fromString()` method of the `AASequence` class. In this example, we will use the amino acid sequence "TESTMTECSTMTESTR". + +.. code-block:: python + + sequence = poms.AASequence.fromString("TESTMTECSTMTESTR") + +We use the names "Oxidation (M)" and "Carbamidomethyl (C)" for the variable and fixed modifications, respectively. + +.. code-block:: python + + variable_mod_names = [b"Oxidation (M)"] + fixed_mod_names = [b"Carbamidomethyl (C)"] + +We then use the `getModifications()` method of the `ModifiedPeptideGenerator` class to get the modifications for these names. + +.. code-block:: python + + variable_modifications = poms.ModifiedPeptideGenerator.getModifications(variable_mod_names) + fixed_modifications = poms.ModifiedPeptideGenerator.getModifications(fixed_mod_names) + +Apply the fixed modifications to the amino acid sequence. + +.. code-block:: python + + poms.ModifiedPeptideGenerator.applyFixedModifications(fixed_modifications, sequence) + +Define the maximum number of variable modifications allowed. + +.. code-block:: python + + max_variable_mods = 1 + +Generate the modified peptides. + +.. code-block:: python + + peptides_with_variable_modifications = [] + keep_unmodified_in_result = False + poms.ModifiedPeptideGenerator.applyVariableModifications(variable_modifications, sequence, max_variable_mods, + peptides_with_variable_modifications, + keep_unmodified_in_result) + +Print the modified peptides generated using Fixed modifications and their mono-isotopic mass. + +.. code-block:: python + + print("Fixed:", sequence.toString()) + print("Mono-isotopic mass:", sequence.getMonoWeight()) + +Print the modified peptides generated using variable modifications and their mono-isotopic mass. + +.. code-block:: python + + for peptide in peptides_with_variable_modifications: + print("Variable:", peptide.toString()) + print("Mono-isotopic mass:", peptide.getMonoWeight()) + The above code outputs: -.. code-block:: output +.. code-block:: python + + Fixed: TESTMTEC(Carbamidomethyl)STMTESTR + Mono-isotopic mass: 1850.7332409542007 + Variable: TESTMTEC(Carbamidomethyl)STM(Oxidation)TESTR + Mono-isotopic mass: 1866.7281559542005 + Variable: TESTM(Oxidation)TEC(Carbamidomethyl)STMTESTR + Mono-isotopic mass: 1866.7281559542005 - Fixed: TESTMTEC(Carbamidomethyl)STMTESTR - Mono-isotopic mass: 1850.7332409542007 - Variable: TESTMTEC(Carbamidomethyl)STM(Oxidation)TESTR - Mono-isotopic mass: 1866.7281559542005 - Variable: TESTM(Oxidation)TEC(Carbamidomethyl)STMTESTR - Mono-isotopic mass: 1866.7281559542005 Proteins and :term:`FASTA` Files