Module writenmd
This module defines input and output functions for NMD format.
.. _nmd-format:
NMD Format
-------------------------------------------------------------------------------
Description
^^^^^^^^^^^
NMD files (extension :file:`.nmd`) are plain text files that contain at
least normal mode and system coordinate data.
NMD files can be visualized using :ref:`nmwiz`. ProDy functions
:func:`.writeNMD` and :func:`.parseNMD` can be used to read and write NMD
files.
Data fields
^^^^^^^^^^^
Data fields in bold face are required. All data arrays and lists must be in a
single line and items must be separated by one or more space characters.
**coordinates**: system coordinates as a list of decimal numbers
Coordinate array is the most important line in an NMD file. All mode array
lengths must match the length of the coordinate array. Also, number of atoms
in the system is deduced from the length of the coordinate array.
::
coordinates 27.552 4.354 23.629 24.179 4.807 21.907 ...
**mode**: normal mode array as a list of decimal numbers
Optionally, mode index and a scaling factor may be provided
in the same line as a mode array. Both of these must precede the mode array.
Providing a scaling factor enables relative scaling of the mode arrows and
the amplitude of the fluctuations in animations. For NMA, scaling factors
may be chosen to be the square-root of the inverse-eigenvalue associated
with the mode. Analogously, for PCA data, scaling factor would be the
square-root of the eigenvalue.
If a mode line contains numbers preceding the mode array, they are evaluated
based on their type. If an integer is encountered, it is considered the mode
index. If a decimal number is encountered, it is considered the scaling
factor. Scaling factor may be the square-root of the inverse eigenvalue
if data is from an elastic network model, or the square-root of the
eigenvalue if data is from an essential dynamics (or principal component)
analysis.
For example, all of the following lines are valid. The first line contains
mode index and scaling factor. Second and third lines contain mode index or
scaling factor. Last line contains only the mode array.
::
mode 1 2.37 0.039 0.009 0.058 0.038 -0.011 0.052 ...
mode 1 0.039 0.009 0.058 0.038 -0.011 0.052 ...
mode 2.37 0.039 0.009 0.058 0.038 -0.011 0.052 ...
mode 0.039 0.009 0.058 0.038 -0.011 0.052 0.043 ...
*name*: name of the model
The length of all following data fields must be equal to the number of atoms in
the system. NMWiz uses such data when writing a temporary PDB files for
loading coordinate data into VMD.
*atomnames*: list of atom names
If not provided, all atom names are set to "CA".
*resnames*: list of residue names
If not provided, all residue names are set to "GLY".
*chainids*: list of chain identifiers
If not provided, all chain identifiers are set to "A".
*resids*: list of residue numbers
If not provided, residue numbers are started from 1 and incremented by one
for each atom.
*bfactors*: list of experimental beta-factors
If not provided, all beta-factors are set to zero.
Beta-factors can be used to color the protein representation.
NMD files may contain additional lines. Only lines that start with one of the
above field names are evaluated by NMWiz.
Autoload Trick
^^^^^^^^^^^^^^
By adding a special line in an NMD file, file content can be automatically
loaded into VMD at startup. The first line calls a NMWiz function to load the
file itself (:file:`xyzeros.nmd`).
::
nmwiz_load xyzeros.nmd
coordinates 0 0 0 0 0 0 ...
mode 0.039 0.009 0.058 0.038 -0.011 0.052 ...
mode -0.045 -0.096 -0.009 -0.040 -0.076 -0.010 ...
mode 0.007 -0.044 0.080 0.015 -0.037 0.062 ...
In this case, VMD must be started from the command line by typing
:program:`vmd -e xyzeros.nmd`.
|
gzip_open(filename,
*args,
**kwargs) |
|
|
|
openFile(filename,
*args,
**kwargs)
Open *filename* for reading, writing, or appending. |
|
|
|
backupFile(filename,
backup=None,
backup_ext='.BAK',
**kwargs)
Rename *filename* with *backup_ext* appended to its name for backup
purposes, if *backup* is **True** or if automatic backups is turned
on using :func:`.confProDy`. |
|
|
|
addext(filename,
extension)
Return *filename*, with *extension* if it does not have one. |
|
|
|
|
|
setup_atom(mode_number,
atom,
vector) |
|
|
|
writeNMDmae(filename,
modes,
solute_st,
selected_st)
return *filename* of a maestro structure file which includes modes
information. |
|
|
|
writeNMD(filename,
modes,
struct)
Return *filename* that contains *modes* and *structure* data in NMD
format described in :ref:`nmd-format`. |
|
|
|
ZERO = 1e-6
|
|
OPEN = {'.gz': gzip_open, '.zip': zipfile.ZipFile,}
|
openFile(filename,
*args,
**kwargs)
|
|
Open *filename* for reading, writing, or appending. First argument in
*args* is treated as the mode. Opening :file:`.gz` and :file:`.zip` files
for reading and writing is handled automatically.
:arg backup: backup existing file using :func:`.backupFile` when opening
in append or write modes, default is obtained from package settings
:type backup: bool
:arg backup_ext: extension for backup file, default is :file:`.BAK`
:type backup_ext: str
|
backupFile(filename,
backup=None,
backup_ext='.BAK',
**kwargs)
|
|
Rename *filename* with *backup_ext* appended to its name for backup
purposes, if *backup* is **True** or if automatic backups is turned on
using :func:`.confProDy`. Default extension :file:`.BAK` is used when
one is not set using :func:`.confProDy`. If *filename* does not exist,
no action will be taken and *filename* will be returned. If file is
successfully renamed, new filename will be returned.
|
writeNMD(filename,
modes,
struct)
|
|
Return *filename* that contains *modes* and *structure* data in NMD
format described in :ref:`nmd-format`. :file:`.nmd` extension is
appended to filename, if it does not have an extension.
.. note:
#. This function skips modes with zero eigenvalues.
#. If a :class:`.Vector` instance is given, it will be normalized
before it is written. It's length before normalization will be
written as the scaling factor of the vector.
|