In [2]:
    
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
    
In [5]:
    
import MDAnalysis as mda
mda.__version__
    
    Out[5]:
In [13]:
    
TOPOLOGY = 'data/adk.psf'
u = mda.Universe(TOPOLOGY)
    
Universe extract all the information in the topology and make them available to you. For example you can see how many atoms are in the topology
In [14]:
    
u.atoms.n_atoms
    
    Out[14]:
Or the number of individual residues
In [15]:
    
u.residues.n_residues
    
    Out[15]:
We can also leverage numpy to see how many unique residue types there are. Residue names are stored in resnames.
In [22]:
    
np.unique(u.residues.resnames)
    
    Out[22]:
In [23]:
    
bb = u.atoms.select_atoms('backbone')
    
To check that only backbone atoms are selected we can look if we only have C, CA, N and O atoms
In [29]:
    
print('number of backbone atoms : {}'.format(bb.n_atoms))
print('unique atoms types : {}'.format(np.unique(bb.names)))
    
    
Or we want to only select the C$_{\alpha}$-atoms.
In [30]:
    
ca = u.atoms.select_atoms('protein and name CA')
    
In [31]:
    
print('number of Ca atoms : {}'.format(ca.n_atoms))
print('unique atoms types : {}'.format(np.unique(ca.names)))
    
    
The complete syntax and possible selection can be look up here
NOTE
It is very important to select C$_{\alpha}$-atoms with the string protein and name CA because Calcium ions also have the name CA.
In [32]:
    
TRAJECTORY = 'data/adk_dims.dcd'
u = mda.Universe(TOPOLOGY, TRAJECTORY)
    
now we can look how many frames the trajectory has
In [33]:
    
u.trajectory.n_frames
    
    Out[33]:
Iterating over a trajectory work pythonically.
In [34]:
    
for time_step in u.trajectory:
    print(time_step.time)