Skip to content

Commit d366921

Browse files
IAlibayRMeli
andauthored
Update for external mdahole2 mdakit (#4464)
* update for external mdahole2 mdakit * put deprecation notice at top of docs * update stuff * remove hole duecredit test entries * update changelog * Update package/MDAnalysis/analysis/hole2/__init__.py Co-authored-by: Rocco Meli <[email protected]> * address review comments --------- Co-authored-by: Rocco Meli <[email protected]>
1 parent 3c83b8f commit d366921

File tree

12 files changed

+40
-3174
lines changed

12 files changed

+40
-3174
lines changed

.github/actions/setup-deps/action.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ inputs:
3131
default: 'hypothesis'
3232
matplotlib:
3333
default: 'matplotlib-base'
34+
mdahole2:
35+
default: 'mdahole2-base'
3436
mda_xdrlib:
3537
default: 'mda-xdrlib'
3638
mmtf-python:
@@ -116,6 +118,7 @@ runs:
116118
${{ inputs.griddataformats }}
117119
${{ inputs.hypothesis }}
118120
${{ inputs.matplotlib }}
121+
${{ inputs.mdahole2 }}
119122
${{ inputs.mda_xdrlib }}
120123
${{ inputs.mmtf-python }}
121124
${{ inputs.numpy }}

maintainer/conda/environment.yml

+4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ dependencies:
2929
- tidynamics>=1.0.0
3030
- tqdm>=4.43.0
3131
- sphinxcontrib-bibtex
32+
- mdaencore
33+
- waterdynamics
3234
- pip:
35+
- mdahole2
36+
- pathsimanalysis
3337
- duecredit
3438
- parmed
3539
- sphinx-sitemap

package/CHANGELOG

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ Enhancements
3535
`n_initial_contacts` attribute, with documentation. (Issue #2604, PR #4415)
3636

3737
Changes
38+
* MDAnalysis.analysis.hole2 is now directly imported from the mdakit
39+
mdahole2. This module is deprecated and will be fully removed in
40+
MDAnalysis version 3.0 (PR #4464)
3841
* Testsuite packaging now uses a pyproject.toml file (PR #4463)
3942
* Improvement of setuptools packaging, including deduplication of
4043
dependency lists (PR #4424)

package/MDAnalysis/analysis/hole2/__init__.py

+10-276
Original file line numberDiff line numberDiff line change
@@ -34,280 +34,14 @@
3434
:footcite:p:`Smart1993,Smart1996` to analyse an ion channel pore or transporter
3535
pathway :footcite:p:`Stelzl2014`.
3636
37-
Using HOLE on a PDB file
38-
------------------------
39-
40-
Use the :func:``hole`` function to run `HOLE`_ on a single PDB file. For example,
41-
the code below runs the `HOLE`_ program installed at '~/hole2/exe/hole' ::
42-
43-
from MDAnalysis.tests.datafiles import PDB_HOLE
44-
from MDAnalysis.analysis import hole2
45-
profiles = hole2.hole(PDB_HOLE, executable='~/hole2/exe/hole')
46-
# to create a VMD surface of the pore
47-
hole2.create_vmd_surface(filename='hole.vmd')
48-
49-
``profiles`` is a dictionary of HOLE profiles, indexed by the frame number. If only
50-
a PDB file is passed to the function, there will only be one profile at frame 0.
51-
You can visualise the pore by loading your PDB file into VMD, and in
52-
Extensions > Tk Console, type::
53-
54-
source hole.vmd
55-
56-
You can also pass a DCD trajectory with the same atoms in the same order as
57-
your PDB file with the ``dcd`` keyword argument. In that case, ``profiles`` will
58-
contain multiple HOLE profiles, indexed by frame.
59-
60-
The HOLE program will create some output files:
61-
62-
* an output file (default name: hole.out)
63-
* an sphpdb file (default name: hole.sph)
64-
* a file of van der Waals' radii
65-
(if not specified with ``vdwradii_file``. Default name: simple2.rad)
66-
* a symlink of your PDB or DCD files (if the original name is too long)
67-
* the input text (if you specify ``infile``)
68-
69-
By default (`keep_files=True`), these files are kept. If you would like to
70-
delete the files after the function is wrong, set `keep_files=False`. Keep in
71-
mind that if you delete the sphpdb file, you cannot then create a VMD surface.
72-
73-
74-
Using HOLE on a trajectory
75-
--------------------------
76-
77-
You can also run HOLE on a trajectory through the :class:`HoleAnalysis` class.
78-
This behaves similarly to the ``hole`` function, although arguments such as ``cpoint``
79-
and ``cvect`` become runtime arguments for the :meth:`~HoleAnalysis.run` function.
80-
81-
The class can be set-up and run like a normal MDAnalysis analysis class::
82-
83-
import MDAnalysis as mda
84-
from MDAnalysis.tests.datafiles import MULTIPDB_HOLE
85-
from MDAnalysis.analysis import hole2
86-
87-
u = mda.Universe(MULTIPDB_HOLE)
88-
89-
ha = hole2.HoleAnalysis(u, executable='~/hole2/exe/hole') as h2:
90-
ha.run()
91-
ha.create_vmd_surface(filename='hole.vmd')
92-
93-
The VMD surface created by the class updates the pore for each frame of the trajectory.
94-
Use it as normal by loading your trajectory in VMD and sourcing the file in the Tk Console.
95-
96-
You can access the actual profiles generated in the ``results`` attribute::
97-
98-
print(ha.results.profiles)
99-
100-
Again, HOLE writes out files for each frame. If you would like to delete these files
101-
after the analysis, you can call :meth:`~HoleAnalysis.delete_temporary_files`::
102-
103-
ha.delete_temporary_files()
104-
105-
Alternatively, you can use HoleAnalysis as a context manager that deletes temporary
106-
files when you are finished with the context manager::
107-
108-
with hole2.HoleAnalysis(u, executable='~/hole2/exe/hole') as h2:
109-
h2.run()
110-
h2.create_vmd_surface()
111-
112-
113-
Using HOLE with VMD
114-
-------------------
115-
116-
The :program:`sos_triangle` program that is part of HOLE_ can write an input
117-
file for VMD_ to display a triangulated surface of the pore found by
118-
:program:`hole`. This functionality is available with the
119-
:meth:`HoleAnalysis.create_vmd_surface` method
120-
[#create_vmd_surface_function]_. For an input trajectory MDAnalysis writes a
121-
*trajectory* of pore surfaces that can be animated in VMD together with the
122-
frames from the trajectory.
123-
124-
125-
Analyzing a full trajectory
126-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
127-
128-
To analyze a full trajectory and write pore surfaces for all frames to file
129-
:file:`hole_surface.vmd`, use ::
130-
131-
import MDAnalysis as mda
132-
from MDAnalysis.analysis import hole2
133-
134-
# load example trajectory MULTIPDB_HOLE
135-
from MDAnalysis.tests.datafiles import MULTIPDB_HOLE
136-
137-
u = mda.Universe(MULTIPDB_HOLE)
138-
139-
with hole2.HoleAnalysis(u, executable='~/hole2/exe/hole') as h2:
140-
h2.run()
141-
h2.create_vmd_surface(filename="hole_surface.vmd")
142-
143-
In VMD, load your trajectory and then in the tcl console
144-
(e.g.. :menuselection:`Extensions --> Tk Console`) load the surface
145-
trajectory:
146-
147-
.. code-block:: tcl
148-
149-
source hole_surface.vmd
150-
151-
If you only want to *subsample the trajectory* and only show the surface at
152-
specific frames then you can either load the trajectory with the same
153-
subsampling into VMD or create a subsampled trajectory.
154-
155-
156-
Creating subsampled HOLE surface
157-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158-
159-
For example, if we want to start displaying at frame 1 (i.e., skip frame 0), stop at frame 7, and
160-
only show every other frame (step 2) then the HOLE analysis will be ::
161-
162-
with hole2.HoleAnalysis(u, executable='~/hole2/exe/hole') as h2:
163-
h2.run(start=1, stop=9, step=2)
164-
h2.create_vmd_surface(filename="hole_surface_subsampled.vmd")
165-
166-
The commands produce the file ``hole_surface_subsampled.vmd`` that can be loaded into VMD.
167-
168-
.. Note::
169-
170-
Python (and MDAnalysis) stop indices are *exclusive* so the parameters
171-
``start=1``, ``stop=9``, and ``step=2`` will analyze frames 1, 3, 5, 7.
172-
173-
.. _Loading-a-trajectory-into-VMD-with-subsampling:
174-
175-
Loading a trajectory into VMD with subsampling
176-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
177-
178-
Load your system into VMD. This can mean to load the topology file with
179-
:menuselection:`File --> New Molecule` and adding the trajectory with
180-
:menuselection:`File --> Load Data into Molecule` or just :menuselection:`File
181-
--> New Molecule`.
182-
183-
When loading the trajectory, subsample the frames by setting parametes in in
184-
the :guilabel:`Frames` section. Select *First: 1*, *Last: 7*, *Stride: 2*. Then
185-
:guilabel:`Load` everything.
186-
187-
.. Note::
188-
189-
VMD considers the stop/last frame to be *inclusive* so you need to typically
190-
choose one less than the ``stop`` value that you selected in MDAnalysis.
191-
192-
Then load the surface trajectory:
193-
194-
.. code-block:: tcl
195-
196-
source hole_surface_subsampled.vmd
197-
198-
You should see a different surface for each frame in the trajectory. [#vmd_extra_frame]_
199-
200-
201-
Creating a subsampled trajectory
202-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203-
204-
Instead of having VMD subsample the trajectory as described in
205-
:ref:`Loading-a-trajectory-into-VMD-with-subsampling` we can write a subsampled
206-
trajectory to a file. Although it requires more disk space, it can be
207-
convenient if we want to visualize the system repeatedly.
208-
209-
The example trajectory comes as a multi-PDB file so we need a suitable topology
210-
file. If you already have a topology file such as a PSF, TPR, or PRMTOP file
211-
then skip this step. We write frame 0 as a PDB :file:`frame0.pdb` (which we
212-
will use as the topology in VMD)::
213-
214-
u.atoms.write("frame0.pdb")
215-
216-
Then write the actual trajectory in a convenient format such as TRR (or
217-
DCD). Note that we apply the same slicing (``start=1``, ``stop=9``, ``step=2``)
218-
to the trajectory itself and then use it as the value for the ``frames``
219-
parameter of :meth:`AtomGroup.write<MDAnalysis.core.groups.AtomGroup.write>`
220-
method::
221-
222-
u.atoms.write("subsampled.trr", frames=u.trajectory[1:9:2])
223-
224-
This command creates the subsampled trajectory file :file:`subsampled.trr` in
225-
TRR format.
226-
227-
In VMD we load the topology and the trajectory and then load the surface. In
228-
our example we have a PDB file (:file:`frame0.pdb`) as topology so we need to
229-
remove the first frame [#vmd_extra_frame]_ (skip the "trim" step below if you
230-
are using a true topology file such as PSF, TPR, or PRMTOP). To keep this
231-
example compact, we are using the tcl command line interface in VMD_
232-
(:menuselection:`Extensions --> Tk Console`) for loading and trimming the
233-
trajectory; you can use the menu commands if you prefer.
234-
235-
.. code-block:: tcl
236-
237-
# load topology and subsampled trajectory
238-
mol load pdb frame0.pdb trr subsampled.trr
239-
240-
# trim first frame (frame0) -- SKIP if using PSF, TPR, PRMTOP
241-
animate delete beg 0 end 0
242-
243-
# load the HOLE surface trajectory
244-
source hole_surface_subsampled.vmd
245-
246-
You can now animate your molecule together with the surface and render it.
247-
248-
249-
.. _HOLE: http://www.holeprogram.org
250-
.. _VMD: https://www.ks.uiuc.edu/Research/vmd/
251-
252-
Functions and classes
253-
---------------------
254-
255-
.. autofunction:: hole
256-
257-
.. autoclass:: HoleAnalysis
258-
:members:
259-
260-
261-
.. rubric:: References
262-
263-
.. footbibliography::
264-
265-
.. rubric:: Footnotes
266-
267-
.. Footnotes
268-
269-
.. [#create_vmd_surface_function] If you use the :class:`hole` class to run
270-
:program:`hole` on a single PDB file then you can use
271-
:func:`MDAnalysis.analysis.hole2.utils.create_vmd_surface`
272-
function to manually run :program:`sph_process` and
273-
:program:`sos_triangle` on the output files andcr eate a surface
274-
file.
275-
276-
.. [#vmd_extra_frame] If you loaded your system in VMD_ from separate topology
277-
and trajectory files and the topology file contained coordinates
278-
(such as a PDB or GRO) file then your trajectory will have an
279-
extra initial frame containing the coordinates from your topology
280-
file. Delete the initial frame with :menuselection:`Molecule -->
281-
Delete Frames` by setting *First* to 0 and *Last* to 0 and
282-
selecting :guilabel:`Delete`.
283-
284-
.. [#HOLEDCD] PDB files are not the only files that :program:`hole` can
285-
read. In principle, it is also able to read CHARMM DCD
286-
trajectories and generate a hole profile for each frame. However,
287-
native support for DCD in :program:`hole` is patchy and not every
288-
DCD is recognized. In particular, At the moment, DCDs generated
289-
with MDAnalysis are not accepted by HOLE. To overcome this
290-
PDB / DCD limitation, use :class:`HoleAnalysis` which creates
291-
temporary PDB files for each frame of a
292-
:class:`~MDAnalysis.core.universe.Universe` or
293-
:class:`~MDAnalysis.core.universe.AtomGroup` and runs
294-
:func:``hole`` on each of them.
295-
29637
"""
297-
from ...due import due, Doi
298-
from .hole import hole, HoleAnalysis
299-
from .utils import create_vmd_surface
300-
301-
due.cite(Doi("10.1016/S0006-3495(93)81293-1"),
302-
description="HOLE program",
303-
path="MDAnalysis.analysis.hole2",
304-
cite_module=True)
305-
due.cite(Doi("10.1016/S0263-7855(97)00009-X"),
306-
description="HOLE program",
307-
path="MDAnalysis.analysis.hole2",
308-
cite_module=True)
309-
due.cite(Doi("10.1016/j.jmb.2013.10.024"),
310-
description="HOLE trajectory analysis with orderparameters",
311-
path="MDAnalysis.analysis.hole2",
312-
cite_module=True)
313-
del Doi
38+
import warnings
39+
from mdahole2.analysis.hole import hole, HoleAnalysis
40+
from mdahole2.analysis import utils, templates
41+
from mdahole2.analysis.utils import create_vmd_surface
42+
43+
wmsg = ("Deprecated in version 2.8.0\n"
44+
"MDAnalysis.analysis.hole2 is deprecated in favour of the "
45+
"MDAKit madahole2 (https://www.mdanalysis.org/mdahole2/) "
46+
"and will be removed in MDAnalysis version 3.0.0")
47+
warnings.warn(wmsg, category=DeprecationWarning)

0 commit comments

Comments
 (0)