From f2fbd3ef0df32d0a69727c8838a9cb18e45f2e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Wed, 16 Oct 2019 21:26:51 +0200 Subject: [PATCH] Document parsing PDB with MDAnalysis --- doc/sphinx/io.rst | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/doc/sphinx/io.rst b/doc/sphinx/io.rst index 9706b8d2455..daced001ace 100644 --- a/doc/sphinx/io.rst +++ b/doc/sphinx/io.rst @@ -397,3 +397,39 @@ using MDAnalysis. A simple example is the following: W.write_next_timestep(u.trajectory.ts) # append it to the trajectory For other examples, see :file:`/samples/MDAnalysisIntegration.py` + +.. _Reading various formats using MDAnalysis: + +Reading various formats using MDAnalysis +---------------------------------------- + +MDAnalysis can read various formats, including MD topologies and trajectories. +To read a PDB file containing a single frame:: + + import MDAnalysis + import numpy as np + import espressomd + from espressomd.interactions import HarmonicBond + + # parse protein structure + universe = MDAnalysis.Universe("protein.pdb") + # extract only the C-alpha atoms of chain A + chainA = universe.select_atoms("name CA and segid A") + # use the unit cell as box + box_l = np.ceil(universe.dimensions[0:3]) + # setup system + system = espressomd.System(box_l=box_l) + system.time_step = 0.001 + system.cell_system.skin = 0.4 + # configure sphere size sigma and create a harmonic bond + system.non_bonded_inter[0, 0].lennard_jones.set_params( + epsilon=1, sigma=1.5, cutoff=2, shift="auto") + system.bonded_inter[0] = HarmonicBond(k=0.5, r_0=1.5) + # create particles and add bonds between them + system.part.add(pos=np.array(chainA.positions, dtype=float)) + for i in range(0, len(chainA) - 1): + system.part[i].add_bond((system.bonded_inter[0], system.part[i + 1].id)) + # visualize protein in 3D + from espressomd import visualization + visualizer = visualization.openGLLive(system, bond_type_radius=[0.2]) + visualizer.run(0)