def plot(ax, systems): for system, path in systems.items(): for rank, flexname, protname in list_poses(system, path): print(flexname, protname) flex = mda.Universe(flexname) prot = mda.Universe(protname) sel = select_flexres(flex, prot) J = Janin(sel).run() J.plot(ax=ax, color=colors[rank], ref=False)
def test_janin_single_frame(self, universe, janin_ref_array): janin = Janin(universe.select_atoms("protein")).run(start=5, stop=6) assert_almost_equal(janin.angles[0], janin_ref_array[5], 3, err_msg="error: dihedral angles should " "match test values")
def test_janin_residue_selections(self, universe): janin = Janin(universe.select_atoms("resname LYS")).run() test_janin = np.load(LYSJaninArray) assert_almost_equal(janin.angles, test_janin, 3, err_msg="error: dihedral angles should " "match test values")
def test_janin(self, universe, janin_ref_array): janin = Janin(universe.select_atoms("protein")).run() # Test precision lowered to account for platform differences with osx assert_almost_equal(janin.angles, janin_ref_array, 3, err_msg="error: dihedral angles should " "match test values")
def mda_janin_with_CSTV(u, selection): """ Takes in a MDAnalysis universe and a selection of that universe that contains one or several aminoacids sharing resid and resname. It calculates the regular Janin angles but if it is a CSTV it gives out only chi1 if it is a GAP it returns none. Parameters ---------- u: MDAnalysis universe. selection: selection of the universe containing one or several aminoacids sharing resid and resname. Returns ------- output_angles: numpy array of angles, shape[n_frames, n_dihedrals, n_subunits] """ import numpy as np from MDAnalysis import Universe from MDAnalysis.analysis.dihedrals import Janin substitute = { "CYS": "SG", "SER": "OG", "THR": "CG2", "VAL": "CG1", } resname = np.unique(selection.resnames) resid = np.unique(selection.resids) assert resname.shape[0] != 1 or resid.shape[0] == 1, "more than one resid" assert isinstance(u, Universe), "u should be a MDAnlaysis universe." if resname[0] in ["CYS", "SER", "THR", "VAL"]: my_list = [] for res in selection.residues: my_list0 = [] for ts in u.trajectory: chi1 = res.chi1_selection( cg_name=substitute[resname[0]]).dihedral.value() my_list0.append(chi1) my_list.append(my_list0) output_angles = np.array(my_list) output_angles = output_angles.reshape( [output_angles.shape[0], output_angles.shape[1], 1]) output_angles = output_angles + 180.0 else: try: output_angles = Janin(selection).run().angles except: output_angles = None return output_angles
def test_plot(self, universe): ax = Janin(universe.select_atoms("resid 5-10")).run().plot(ref=True) assert isinstance(ax, matplotlib.axes.Axes), \ "Ramachandran.plot() did not return and Axes instance"
def test_atom_selection(self): with pytest.raises(ValueError): u = mda.Universe(PDB_janin) janin = Janin( u.select_atoms("protein and not resname ALA CYS GLY " "PRO SER THR VAL"))
def test_remove_residues(self, universe): with pytest.warns(UserWarning): janin = Janin(universe.select_atoms("protein")).run()
def test_outside_protein_length(self, universe): with pytest.raises(ValueError): janin = Janin(universe.select_atoms("resid 220")).run()