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')
Ejemplo n.º 2
0
    def test_ramachandran(self, universe, rama_ref_array):
        rama = Ramachandran(universe.select_atoms("protein")).run()

        assert_almost_equal(rama.angles,
                            rama_ref_array,
                            5,
                            err_msg="error: dihedral angles should "
                            "match test values")
Ejemplo n.º 3
0
    def test_ramachandran_single_frame(self, universe, rama_ref_array):
        rama = Ramachandran(universe.select_atoms("protein")).run(start=5,
                                                                  stop=6)

        assert_almost_equal(rama.angles[0],
                            rama_ref_array[5],
                            5,
                            err_msg="error: dihedral angles should "
                            "match test values")
Ejemplo n.º 4
0
    def test_ramachandran_residue_selections(self, universe):
        rama = Ramachandran(universe.select_atoms("resname GLY")).run()
        test_rama = np.load(GLYRamaArray)

        assert_almost_equal(rama.angles,
                            test_rama,
                            5,
                            err_msg="error: dihedral angles should "
                            "match test values")
Ejemplo n.º 5
0
def angle_to_list(u):
    from MDAnalysis.analysis.dihedrals import Ramachandran
    r = u.select_atoms("resid 2")
    R = Ramachandran(r).run()

    phi = []
    psi = []

    for line in list(R.angles):
        phi.append(line.tolist()[0][0])
        psi.append(line.tolist()[0][1])

    return phi, psi
Ejemplo n.º 6
0
def ramachandran(u):
    Ramachandran(u.select_atoms("protein")).run()
Ejemplo n.º 7
0
import pdb
import numpy as np
import MDAnalysis as mda
u = mda.Universe('prot.psf', 'out.xtc')

# selection of atomgroups
ags = [res.phi_selection() for res in u.residues[4:9]]

from MDAnalysis.analysis.dihedrals import Dihedral
from MDAnalysis.analysis.dihedrals import Ramachandran
#R = Dihedral(ags).run()
r = u.select_atoms("resid 5-10")
R = Ramachandran(r).run()

#R = Dihedral(ags).run()

np.save('out2.npy', R.angles)

#R.save()

#import matplotlib.pyplot as plt

#fig, ax = plt.subplots(figsize=plt.figaspect(1))

#R.plot(ax=ax, color='k', marker='s')
#pdb.set_trace()
Ejemplo n.º 8
0
def ramachandran(u: mda.Universe, label: str, output_filepath: str):

    sel = u.select_atoms(STANDARD_SELECTION)
    R = Ramachandran(sel).run()
    mdplots.plot_ramachandran(R, label, output_filepath)
Ejemplo n.º 9
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()


Ejemplo n.º 10
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()
Ejemplo n.º 11
0
 def test_plot(self, universe):
     ax = Ramachandran(
         universe.select_atoms("resid 5-10")).run().plot(ref=True)
     assert isinstance(ax, matplotlib.axes.Axes), \
         "Ramachandran.plot() did not return and Axes instance"
Ejemplo n.º 12
0
 def test_None_removal(self):
     with pytest.warns(UserWarning):
         u = mda.Universe(PDB_rama)
         rama = Ramachandran(u.select_atoms("protein").residues[1:-1])
Ejemplo n.º 13
0
 def test_protein_ends(self, universe):
     with pytest.warns(UserWarning):
         rama = Ramachandran(universe.select_atoms("protein")).run()
Ejemplo n.º 14
0
 def test_outside_protein_length(self, universe):
     with pytest.raises(ValueError):
         rama = Ramachandran(universe.select_atoms("resid 220")).run()