def ramachandran_plot(atomgroup,
                      selection,
                      outputfile1,
                      outputfile2,
                      image_format='png'):
    # plot standard mdanalysis and seaborn 2D with kde
    R = Ramachandran(atomgroup).run()
    fig, ax = plt.subplots(figsize=plt.figaspect(1))
    R.plot(ax=ax, color='k', marker='.', ref=True)

    a = R.angles.reshape(np.prod(R.angles.shape[:2]), 2)
    # open hdf file
    with h5py.File(args.o_data1, 'a') as f:
        setname = "%s" % (selection)
        f["/" + setname + "/ramachandran/phi"] = a[:, 0]
        f["/" + setname + "/ramachandran/psi"] = a[:, 1]
    plt.tight_layout()
    # svg is better but sticking with png for now
    plt.savefig(outputfile1, format=image_format)

    sns.reset_defaults()
    importlib.reload(plt)
    importlib.reload(sns)
    with sns.axes_style("white"):
        h = sns.jointplot(x=a[:, 0], y=a[:, 1], kind="kde", space=0)
        h.set_axis_labels(r'$\phi$ (deg)', r'$\psi$ (deg)')
        h.ax_joint.set_xlim(-180, 180)
        h.ax_joint.set_ylim(-180, 180)
        h.ax_joint.xaxis.set_major_locator(ticker.MultipleLocator(60))
        h.ax_joint.yaxis.set_major_locator(ticker.MultipleLocator(60))
        plt.savefig(outputfile2, format=image_format, bbox_inches='tight')
示例#2
0
import matplotlib.pyplot as plt
import MDAnalysis as mda
from MDAnalysis.analysis.dihedrals import Ramachandran

u = mda.Universe("pro.gro", "test.xtc")
r = u.select_atoms("protein")
R = Ramachandran(r).run()
fig, ax = plt.subplots()
R.plot(ax=ax, color='k', marker='s', ref=True)
plt.show()


示例#3
0
# UCSF Biophysics Bootcamp
# Ramachandran Project Assistance
# August 27, 2020
"""
This is an alternate method for generating Ramachandran plots
that uses the MDAnalysis package to calculate dihedral angles.
"""

# Import useful modules
import sys, re, math
import numpy as np
import matplotlib.pyplot as plt
import MDAnalysis as mda
from MDAnalysis.analysis.dihedrals import Ramachandran

## 1. Read in PDB file
read_3emn = mda.Universe("/home/yessica/VDAC_project/bin/pdbs/3emn_noalt.pdb")

## 2. For every residue, extract the desired atoms with the corresponding Names
pol_atoms = read_3emn.select_atoms("protein")

## 4. Calculate the phi and psi angles
angles = Ramachandran(pol_atoms).run()

## 5. Make a scatter plot of phi and  psi values
fig, ax = plt.subplots(figsize=plt.figaspect(1))
angles.plot(ax=ax, color='k')
plt.show()