The paper on MDAnalysis was published as
The HTML version of the paper has so many indentation errors in the code example to make it almost completely useless for learning MDAnalysis. The PDF version is mostly correct although the final formatted version ended up with a few line breaks that are illegal in the Python syntax. The free PubmedCentral version PMCID PMC3144279, however, contains perfectly formatted Python code.
Corrected code is listed here and can also be found in the examples that are part of the MDAnalysis package. We are sorry for the inconvenience but assure you that we tried our best to impart the importance of spaces in Python code on the typesetter.
We are also collecting any further errata (which correct errors or omissions in both the PDF and the HTML version). If you find further problems then please let us know by emailing one of the authors or filing an issue in the MDAnalysis Issue Tracker.
universe.selectAtoms("byres (resname SOL and around 3.5 protein)").write("solvation-shell.pdb")
The PDF version also contains a crucial indentation error.
def blocked(universe, nblocks, analyze):
size = universe.trajectory.numframes/nblocks
blocks = []
for block in xrange(nblocks):
a = []
for ts in u.trajectory[block*size:(block+1)*size]:
a.append(analyze(universe))
blocks.append(numpy.average(a))
blockaverage = numpy.average(blocks)
blockstd = numpy.std(blocks)
return nblocks, size, blockaverage, blockstd
See examples/blocks.py for a working example.
def rgyr(universe):
return universe.selectAtoms("protein").radiusOfGyration()
MDAnalysis.collection.addTimeseries(\
Timeseries.Dihedral(atomselection))
data = universe.trajectory.correl(\
MDAnalysis.collection, skip=10)
The normalisation of the radial distribution function of water is not correct in the simplified example in the paper; use examples/radial_distribution_function.py from the distribution:
# Normalize RDF
radii = 0.5 * (edges[1:] + edges[:-1])
vol = (4./3.)*numpy.pi*(numpy.power(edges[1:], 3)-numpy.power(edges[:-1], 3))
# get water density
import MDAnalysis.core.units
density = MDAnalysis.core.units.convert(1.0, 'water', 'Angstrom^{-3}')
norm = density * (n - 1) / 2 * numframes
# normalize the RDF
rdf /= norm * vol
CHARMM has a way to calculate 3D densities using the COORdinates ANALysis … IHIS facility. The table states incorrectly that CHARMM can not presently carry out this kind of calculations.