|
1 | 1 | .. _overview-label: |
2 | 2 |
|
3 | 3 | ========================== |
4 | | - Overview over MDAnalysis |
| 4 | + Overview of MDAnalysis |
5 | 5 | ========================== |
6 | 6 |
|
7 | | -**MDAnalysis** is a Python package that provides classes to access |
8 | | -data in molecular dynamics trajectories. It is object oriented so it |
9 | | -treats atoms, groups of atoms, trajectories, etc as different |
10 | | -objects. Each object has a number of operations defined on itself |
11 | | -(also known as "methods") and also contains values describing the |
12 | | -object ("attributes"). For example, a |
13 | | -:class:`~MDAnalysis.core.groups.AtomGroup` object has a |
14 | | -:meth:`~MDAnalysis.core.groups.AtomGroup.center_of_mass` method that |
15 | | -returns the center of mass of the group of atoms. It also contains an |
16 | | -attribute called :attr:`~MDAnalysis.core.groups.AtomGroup.residues` |
17 | | -that lists all the residues that belong to the group. Using methods |
18 | | -such as :meth:`~MDAnalysis.core.groups.AtomGroup.select_atoms` |
19 | | -(which uses `CHARMM-style`_ atom :ref:`selection-commands-label`) one |
20 | | -can create new objects (in this case, another |
21 | | -:class:`~MDAnalysis.core.groups.AtomGroup`). |
| 7 | +MDAnalysis is a Python package for the analysis of molecular dynamics simulations. |
| 8 | +It provides an object-oriented interface to molecular structures and trajectories, |
| 9 | +with direct access to atomic coordinates as :class:`numpy.ndarray` objects for seamless |
| 10 | +integration with `NumPy`_ and `SciPy`_. |
22 | 11 |
|
23 | | -A typical usage pattern is to iterate through a trajectory and analyze |
24 | | -coordinates for every frame. In the following example the end-to-end distance |
25 | | -of a protein and the radius of gyration of the backbone atoms are calculated:: |
| 12 | +This page gives a high-level overview of the most important public classes and modules. |
| 13 | +For usage examples and tutorials, refer to the `User Guide`_. |
26 | 14 |
|
27 | | - import MDAnalysis as mda |
28 | | - from MDAnalysis.tests.datafiles import PSF,DCD # test trajectory |
29 | | - import numpy.linalg |
30 | | - u = mda.Universe(PSF,DCD) # always start with a Universe |
31 | | - nterm = u.select_atoms('segid 4AKE and name N')[0] # can access structure via segid (s4AKE) and atom name |
32 | | - cterm = u.select_atoms('segid 4AKE and name C')[-1] # ... takes the last atom named 'C' |
33 | | - bb = u.select_atoms('protein and backbone') # a selection (a AtomGroup) |
34 | | - for ts in u.trajectory: # iterate through all frames |
35 | | - r = cterm.position - nterm.position # end-to-end vector from atom positions |
36 | | - d = numpy.linalg.norm(r) # end-to-end distance |
37 | | - rgyr = bb.radius_of_gyration() # method of a AtomGroup; updates with each frame |
38 | | - print(f"frame = {ts.frame}: d = {d} Angstroem, Rgyr = {rgyr} Angstroem") |
| 15 | +.. _User Guide: https://userguide.mdanalysis.org/stable/index.html |
| 16 | +.. _NumPy: https://numpy.org/ |
| 17 | +.. _SciPy: https://scipy.org/ |
39 | 18 |
|
| 19 | +Key Classes |
| 20 | +=========== |
40 | 21 |
|
41 | | -.. _NumPy: https://numpy.org/ |
42 | | -.. _CHARMM: http://www.charmm.org/ |
43 | | -.. _LAMMPS: http://lammps.sandia.gov/ |
44 | | -.. _NAMD: http://www.ks.uiuc.edu/Research/namd/ |
45 | | -.. _Gromacs: http://www.gromacs.org/ |
| 22 | +The core of MDAnalysis revolves around the :class:`~MDAnalysis.core.universe.Universe` class, |
| 23 | +which serves as the central data structure that loads and connects topology and coordinate data. |
| 24 | +From a :class:`~MDAnalysis.core.universe.Universe`, users typically interact with :class:`~MDAnalysis.core.groups.AtomGroup` |
| 25 | +objects — flexible collections of atoms that support structural selections and analysis operations. These selections |
| 26 | +are created using `CHARMM-style`_ selection syntax via the :meth:`~MDAnalysis.core.groups.AtomGroup.select_atoms` method, |
| 27 | +allowing users to query atoms based on names, residue numbers, segments, and more. |
46 | 28 |
|
47 | | -.. _CHARMM-style: |
48 | | - http://www.charmm.org/documentation/c37b1/select.html |
| 29 | +Individual atoms are represented by the :class:`~MDAnalysis.core.groups.Atom` class, while residues and segments (or chains) are modeled using the |
| 30 | +:class:`~MDAnalysis.core.groups.Residue` and :class:`~MDAnalysis.core.groups.Segment` classes, respectively. Together, these |
| 31 | +classes form an intuitive, object-oriented hierarchy that makes it easy to navigate and analyze molecular systems. |
49 | 32 |
|
50 | | -.. TODO: more about philosophy etc... copy and paste from paper |
| 33 | +.. _CHARMM-style: http://www.charmm.org/documentation/c37b1/select.html |
51 | 34 |
|
52 | | -Using MDAnalysis in python |
53 | | -========================== |
54 | | - |
55 | | -If you've installed MDAnalysis in the standard python modules location, load |
56 | | -from within the interpreter:: |
57 | | - |
58 | | - from MDAnalysis import * |
59 | | - |
60 | | -or :: |
61 | | - |
62 | | - import MDAnalysis as mda |
63 | | - |
64 | | -The idea behind MDAnalysis is to get trajectory data into NumPy_ |
65 | | -:class:`numpy.ndarray` arrays, where it can then be easily manipulated using |
66 | | -all the power in NumPy_ and SciPy_. |
67 | | - |
68 | | -MDAnalysis works well both in scripts and in interactive use. The developers |
69 | | -very much recommend using MDAnalysis from within the IPython_ Python shell. It |
70 | | -allows one to interactively explore the objects (using TAB-completion and |
71 | | -online help), do analysis and immediately plot results. The examples in this manual |
72 | | -are typically run from an interactive :program:`ipython` session. |
73 | | - |
74 | | -Invariably, a MDAnalysis session starts with loading data into the |
75 | | -:class:`~MDAnalysis.core.universe.Universe` class (which can be accessed |
76 | | -as :class:`MDAnalysis.Universe`):: |
77 | | - |
78 | | - import MDAnalysis as mda |
79 | | - universe = mda.Universe(topology, trajectory) |
80 | | - |
81 | | -- The *topology* file lists the atoms and residues (and also their |
82 | | - connectivity). It can be a CHARMM/XPLOR/NAMD PSF file or a coordinate file |
83 | | - such as a Protein Databank Brookhaven PDB file, a CHARMM card coordinate file |
84 | | - (CRD), or a GROMOS/Gromacs GRO file. |
85 | | - |
86 | | -- The *trajectory* contains a list of coordinates in the order defined in the |
87 | | - *topology*. It can either be a single frame (PDB, CRD, and GRO are all read) |
88 | | - or a time series of coordinate frames such as a CHARMM/NAMD/LAMMPS DCD |
89 | | - binary file, a Gromacs XTC/TRR trajectory, or a XYZ trajectory (possibly |
90 | | - compressed with gzip or bzip2). |
91 | | - |
92 | | -For the remainder of this introduction we are using a short example trajectory |
93 | | -that is provided with MDAnalysis (as part of the `MDAnalysis test suite`_). The |
94 | | -trajectory is loaded with :: |
95 | | - |
96 | | - >>> from MDAnalysis import Universe |
97 | | - >>> from MDAnalysis.tests.datafiles import PSF,DCD |
98 | | - >>> u = Universe(PSF, DCD) |
99 | | - |
100 | | -(The ``>>>`` signs are the Python input prompt and are not to be typed; they |
101 | | -just make clear in the examples what is input and what is output.) |
102 | | - |
103 | | -The :class:`~MDAnalysis.core.universe.Universe` contains a number of important attributes, |
104 | | -the most important ones of which is |
105 | | -:attr:`~MDAnalysis.core.universe.Universe.atoms`:: |
106 | | - |
107 | | - >>> print(u.atoms) |
108 | | - <AtomGroup with 3341 atoms> |
109 | | - |
110 | | -:attr:`Universe.atoms` is a |
111 | | -:class:`~MDAnalysis.core.groups.AtomGroup` and can be thought of as |
112 | | -list consisting of :class:`~MDAnalysis.core.groups.Atom` |
113 | | -objects. The :class:`~MDAnalysis.core.groups.Atom` is the |
114 | | -elementary and fundamental object in MDAnalysis. |
115 | | - |
116 | | -The :attr:`MDAnalysis.Universe.trajectory` attribute gives access to the coordinates |
117 | | -over time:: |
118 | | - |
119 | | - >>> print(u.trajectory) |
120 | | - < DCDReader '/..../MDAnalysis/tests/data/adk_dims.dcd' with 98 frames of 3341 atoms (0 fixed) > |
121 | | - |
122 | | -Finally, the :meth:`MDAnalysis.Universe.select_atoms` method generates a new |
123 | | -:class:`~MDAnalysis.core.groups.AtomGroup` according to a selection criterion:: |
124 | | - |
125 | | - >>> calphas = u.select_atoms("name CA") |
126 | | - >>> print(calphas) |
127 | | - <AtomGroup with 214 atoms> |
128 | | - |
129 | | -as described in :ref:`selection-commands-label`. |
130 | | - |
131 | | -.. _SciPy: http://www.scipy.org/ |
132 | | -.. _IPython: https://ipython.org/ |
133 | | -.. _MDAnalysis test suite: https://github.com/MDAnalysis/mdanalysis/wiki/UnitTests |
134 | | - |
135 | | - |
136 | | -Examples |
137 | | -======== |
138 | | - |
139 | | -The easiest way to get started with MDAnalysis is to read this introduction and the chapters on :ref:`topology-label` and :ref:`selection-commands-label`, then explore the package interactively in IPython_ or another interactive Python interpreter. |
140 | | - |
141 | | -Included trajectories |
142 | | ---------------------- |
143 | | - |
144 | | -MDAnalysis comes with a number of real trajectories for testing. You |
145 | | -can also use them to explore the functionality and ensure that |
146 | | -everything is working properly:: |
147 | | - |
148 | | - import MDAnalysis as mda |
149 | | - from MDAnalysis.tests.datafiles import PSF,DCD, PDB,XTC |
150 | | - u_dims_adk = mda.Universe(PSF,DCD) |
151 | | - u_eq_adk = mda.Universe(PDB, XTC) |
152 | | - |
153 | | -The PSF and DCD file are a closed-form-to-open-form transition of |
154 | | -Adenylate Kinase (from [Beckstein2009]_) and the PDB+XTC file are ten |
155 | | -frames from a Gromacs simulation of AdK solvated in TIP4P water with |
156 | | -the OPLS/AA force field. |
157 | | - |
158 | | -.. [Beckstein2009] O. Beckstein, E.J. Denning, J.R. Perilla, and |
159 | | - T.B. Woolf. Zipping and Unzipping of Adenylate |
160 | | - Kinase: Atomistic Insights into the Ensemble of |
161 | | - Open <--> Closed Transitions. *J Mol Biol* **394** |
162 | | - (2009), 160--176, doi:`10.1016/j.jmb.2009.09.009`_ |
163 | | -
|
164 | | -.. _`10.1016/j.jmb.2009.09.009`: http://dx.doi.org/10.1016/j.jmb.2009.09.009 |
165 | | - |
166 | | -Code snippets |
167 | | -------------- |
168 | | - |
169 | | -The source code distribution comes with a directory `examples`_ that |
170 | | -contains a number of code snippets that show how to use certain |
171 | | -aspects of MDAnalysis. |
172 | | - |
173 | | -For instance, there is code that shows how to |
174 | | - |
175 | | -* fit a trajectory to a reference structure using the QCP |
176 | | - RMSD-alignment code in :mod:`MDAnalysis.core.qcprot` |
177 | | - (`rmsfit_qcp.py`_); |
178 | | - |
179 | | -* do a block-averaging error analysis (`blocks.py`_); |
180 | | - |
181 | | -* calculate a potential profile across a membrane (`potential_profile.py`_); |
182 | | - |
183 | | -* do a native contact analysis using :mod:`MDAnalysis.analysis.contacts` (`nativecontacts.py`_) |
184 | | - |
185 | | -* get the lipid composition of the individual leaflets of a bilayer |
186 | | - using :mod:`MDAnalysis.analysis.leaflet` (`membrane-leaflets.py`_); |
187 | | - |
188 | | -* define the multimeric states of a number of transmembrane peptides |
189 | | - via clustering (`multimers-analysis.py`_); |
190 | | - |
191 | | -* convert between trajectory formats (e.g. `dcd2xtc.py`_ or `amber2dcd.py`_) |
| 35 | +Core modules |
| 36 | +============ |
192 | 37 |
|
193 | | -* use MDAnalysis for simple model building (`make_MthK_tetramer.py`_); |
| 38 | +MDAnalysis is organized into several core modules that provide specialized functionality for |
| 39 | +handling and analyzing molecular dynamics data. The :mod:`MDAnalysis.core` module defines the |
| 40 | +essential data structures such as :class:`~MDAnalysis.core.universe.Universe`, :class:`~MDAnalysis.core.groups.AtomGroup`, |
| 41 | +and related objects. The :mod:`MDAnalysis.analysis` module contains a collection of analysis tools for tasks like RMSD calculation, |
| 42 | +diffusion analysis, contact maps, and more. The :mod:`MDAnalysis.selections` module implements the flexible selection language used |
| 43 | +to query atoms based on structural properties. Finally, :mod:`MDAnalysis.topology` manages topology parsing and representation, |
| 44 | +supporting a wide range of file formats for loading molecular structures. |
194 | 45 |
|
195 | | -and more. |
196 | 46 |
|
197 | | -.. Links to the stable git repository: |
198 | 47 |
|
199 | | -.. _examples: |
200 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/tree/master/examples/ |
201 | 48 |
|
202 | | -.. _`rmsfit_qcp.py`: |
203 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/rmsfit_qcp.py |
204 | | -.. _`blocks.py`: |
205 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/blocks.py |
206 | | -.. _`potential_profile.py`: |
207 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/potential_profile.py |
208 | | -.. _`nativecontacts.py`: |
209 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/nativecontacts.py |
210 | | -.. _`membrane-leaflets.py`: |
211 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/membrane-leaflets.py |
212 | | -.. _`multimers-analysis.py`: |
213 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/multimers-analysis.py |
214 | | -.. _`dcd2xtc.py`: |
215 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/dcd2xtc.py |
216 | | -.. _`amber2dcd.py`: |
217 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/amber2dcd.py |
218 | | -.. _`make_MthK_tetramer.py`: |
219 | | - https://github.com/MDAnalysis/MDAnalysisCookbook/blob/master/examples/make_MthK_tetramer.py |
0 commit comments