-
Notifications
You must be signed in to change notification settings - Fork 823
Closed
Labels
Component-Coreremove-2.0deprecated in 1.0 and to be removed in 2.0deprecated in 1.0 and to be removed in 2.0usability
Milestone
Description
When creating a selection, e.g., backbone = u.select_atoms('backbone') and then looking at all the dihedral angles of that selection, MDAnalysis also returns dihedrals between atoms pairs that should not be presented.
Initial code
import numpy as np
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PSF, DCD
u = mda.Universe(PSF, DCD)
backbone = u.select_atoms('backbone')
backbone
<AtomGroup with 855 atoms>Expected behaviour
Only list dihedral angles between atoms in the selection (here: backbone). Total number of dihedrals: 425.
# Extract indiced of dihedral angles phi and psi
dihedral_indices = np.zeros([2 * (len(backbone.residues) - 1)], dtype=np.int)
j = 0
for i, dih in enumerate(backbone.dihedrals):
if dih.atoms[0].name == 'C' and dih.atoms[-1].name == 'C' or dih.atoms[0].name == 'N' and dih.atoms[-1].name == 'N':
dihedral_indices[j] = i
j += 1
for dih in backbone.dihedrals[dihedral_indices]:
print dih.atoms
<AtomGroup [<Atom 1: N of type 56 of resname MET, resid 1 and segid 4AKE>, <Atom 5: CA of type 22 of resname MET, resid 1 and segid 4AKE>, <Atom 18: C of type 20 of resname MET, resid 1 and segid 4AKE>, <Atom 20: N of type 54 of resname ARG, resid 2 and segid 4AKE>]>
<AtomGroup [<Atom 18: C of type 20 of resname MET, resid 1 and segid 4AKE>, <Atom 20: N of type 54 of resname ARG, resid 2 and segid 4AKE>, <Atom 22: CA of type 22 of resname ARG, resid 2 and segid 4AKE>, <Atom 42: C of type 20 of resname ARG, resid 2 and segid 4AKE>]>
<AtomGroup [<Atom 20: N of type 54 of resname ARG, resid 2 and segid 4AKE>, <Atom 22: CA of type 22 of resname ARG, resid 2 and segid 4AKE>, <Atom 42: C of type 20 of resname ARG, resid 2 and segid 4AKE>, <Atom 44: N of type 54 of resname ILE, resid 3 and segid 4AKE>]>
[... truncated ...]
<AtomGroup [<Atom 3332: C of type 20 of resname LEU, resid 213 and segid 4AKE>, <Atom 3334: N of type 54 of resname GLY, resid 214 and segid 4AKE>, <Atom 3336: CA of type 23 of resname GLY, resid 214 and segid 4AKE>, <Atom 3339: C of type 32 of resname GLY, resid 214 and segid 4AKE>]>Actual behaviour
Lists all existing dihedrals that start/end in the selection. Total number of dihedrals: 5845.
backbone.dihedrals
<TopologyGroup containing 5846 dihedrals>
for dih in backbone.dihedrals:
print dih.atoms
<AtomGroup [<Atom 1: N of type 56 of resname MET, resid 1 and segid 4AKE>, <Atom 5: CA of type 22 of resname MET, resid 1 and segid 4AKE>, <Atom 7: CB of type 23 of resname MET, resid 1 and segid 4AKE>, <Atom 8: HB1 of type 3 of resname MET, resid 1 and segid 4AKE>]>
<AtomGroup [<Atom 1: N of type 56 of resname MET, resid 1 and segid 4AKE>, <Atom 5: CA of type 22 of resname MET, resid 1 and segid 4AKE>, <Atom 7: CB of type 23 of resname MET, resid 1 and segid 4AKE>, <Atom 9: HB2 of type 3 of resname MET, resid 1 and segid 4AKE>]>
<AtomGroup [<Atom 1: N of type 56 of resname MET, resid 1 and segid 4AKE>, <Atom 5: CA of type 22 of resname MET, resid 1 and segid 4AKE>, <Atom 7: CB of type 23 of resname MET, resid 1 and segid 4AKE>, <Atom 10: CG of type 23 of resname MET, resid 1 and segid 4AKE>]>
[... truncated ...]
<AtomGroup [<Atom 3338: HA2 of type 6 of resname GLY, resid 214 and segid 4AKE>, <Atom 3336: CA of type 23 of resname GLY, resid 214 and segid 4AKE>, <Atom 3339: C of type 32 of resname GLY, resid 214 and segid 4AKE>, <Atom 3341: OT2 of type 72 of resname GLY, resid 214 and segid 4AKE>]>Currently version of MDAnalysis:
Both 0.15 and current 0.16-dev
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Component-Coreremove-2.0deprecated in 1.0 and to be removed in 2.0deprecated in 1.0 and to be removed in 2.0usability