<commit_before>.. em_analysis:

Parsing Cryo-EM Electron Density Map
==================================================================

Lets start with essential import statements:

.. ipython:: python

   from prody import *
   import numpy as np
   import matplotlib


Parse Density Map
-----------------------------------------------------------------

The first step is to parse a .map file, which contains information
about a density map as the electron density at points on a grid.
This file format is a binary format also known as CCP4 or MRC2015. 

.. ipython:: python

   emd = parseEMD('emd_1960.map', cutoff=1.2, n_nodes=8000, num_iter=30)
   emd

This function returns an atom group from the electron density
map. The cutoff parameter discards any electron density lower than
the given number, n_nodes is the parameter that describes the
total number of beads that initialize the system. The method to
build coordinates is also called the "Topology Representing
Network" algorithm, which is an iterative algorithm and num_iter 
is therefore a required parameter for this algorithm. 
The resultant structure is given in the following figure. 

Note: Depending on your hardware, this may take a while - around
30 minutes. To skip this step, you can load the structure file
directly in PDB format (emd_1960.pdb).

.. figure:: ../../_static/figures/8000nodes_with_map.png
   :scale: 80%

Elastic Network Model Analysis
-----------------------------------------------------------------

The 144x144x144 density grid is converted into an :class:`.AtomGroup`
class and elastic network model analysis can be applied to the 
constructed structure as usual. 

anm = ANM('TRiC EMDMAP ANM Analysis')
anm.buildHessian(emd)
anm.calcModes(n_modes=5)
writeNMD('tric_anm_3_modes_8000nodes.nmd', anm[:3], emd)

<commit_msg>fix to cryoem tutorial to show ANM code as code<commit_after>.. em_analysis:

Parsing Cryo-EM Electron Density Map
==================================================================

Lets start with essential import statements:

.. ipython:: python

   from prody import *
   import numpy as np
   import matplotlib


Parse Density Map
-----------------------------------------------------------------

The first step is to parse a .map file, which contains information
about a density map as the electron density at points on a grid.
This file format is a binary format also known as CCP4 or MRC2015. 

.. ipython:: python

   emd = parseEMD('emd_1960.map', cutoff=1.2, n_nodes=8000, num_iter=30)
   emd

This function returns an atom group from the electron density
map. The cutoff parameter discards any electron density lower than
the given number, n_nodes is the parameter that describes the
total number of beads that initialize the system. The method to
build coordinates is also called the "Topology Representing
Network" algorithm, which is an iterative algorithm and num_iter 
is therefore a required parameter for this algorithm. 
The resultant structure is given in the following figure. 

Note: Depending on your hardware, this may take a while - around
30 minutes. To skip this step, you can load the structure file
directly in PDB format (emd_1960.pdb).

.. figure:: ../../_static/figures/8000nodes_with_map.png
   :scale: 80%

Elastic Network Model Analysis
-----------------------------------------------------------------

The 144x144x144 density grid is converted into an :class:`.AtomGroup`
class and elastic network model analysis can be applied to the 
constructed structure as usual. 

.. ipython:: python
   :verbatim:
   
   anm = ANM('TRiC EMDMAP ANM Analysis')
   anm.buildHessian(emd)
   anm.calcModes(n_modes=5)
   writeNMD('tric_anm_3_modes_8000nodes.nmd', anm[:3], emd)


{'fraction_non_alphanumeric': 0.15806451612903225, 'fraction_numerical': 0.024193548387096774, 'mean_word_length': 3.1207087486157254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '240118', 'n_tokens_mistral': 1071, 'n_tokens_neox': 968, 'n_words': 448}