Skip to content

Commit

Permalink
Update peptides_proteins.rst
Browse files Browse the repository at this point in the history
restructured the documentation and checked for spacing, etc.
  • Loading branch information
Ayesha-Feroz authored Feb 23, 2024
1 parent 6a0aab2 commit 311a110
Showing 1 changed file with 69 additions and 45 deletions.
114 changes: 69 additions & 45 deletions docs/source/user_guide/peptides_proteins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 311a110

Please sign in to comment.