Dihedral angle calculation

92 views
Skip to first unread message

Pawan Kumar (Project Sci.-I) - SOAB

unread,
Oct 26, 2023, 5:26:44 AM10/26/23
to MDnalysis-devel
Hello everyone,
I am Pawan Kumar, trying to generate dihedral angle graph of glycosidic backbone. So, i try using MDAnalysis tool, but the script able to find only phi and psi angle for amino acids. Hence, showing no phi and psi bond within glucose backbone.
I am sharing the script i am trying for the query.

Please help me with the query.
Thanks and Regards.
Pawan Kumar

Code:
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import GRO, XTC
from MDAnalysis.analysis import dihedrals
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
u = mda.Universe("md_50.gro", "md_100.xtc")
glucose = u.select_atoms('resname AGLC')
print('There are {} residues in the amylose chain'.format(len(glucose.residues)))
for res in u.residues[1:26]:
    phi = res.phi_selection()
    if phi is None:
        names = None
    else:
        names = phi.names
    print('{}: {} '.format(res.resname, names))

Oliver Beckstein

unread,
Oct 26, 2023, 10:59:43 AM10/26/23
to mdnalysis-devel

On Oct 26, 2023, at 05:26, Pawan Kumar (Project Sci.-I) - SOAB <pa...@pau.edu> wrote:

Hello everyone,
I am Pawan Kumar, trying to generate dihedral angle graph of glycosidic backbone. So, i try using MDAnalysis tool, but the script able to find only phi and psi angle for amino acids.

We only have psi/phi for proteins because the residue/atom naming is fairly standard. We don’t support any other special dihedrals in other polymers.

You will have to write your own code to

1. first find the correct atoms forming the dihedrals
2. use calc_dihedrals() to compute the values

Have a look at recent workshop materials:

None of these materials show you exactly what you’ll be doing but it’s a start.


Hence, showing no phi and psi bond within glucose backbone.
I am sharing the script i am trying for the query.

What are the atom names that form the dihedral? If they are A-B-C-D and you want the torsion around B-C, make selections for these groups

A = glucose.select_atoms(“name A”)
B = glucose.select_atoms(“name B”)
C = glucose.select_atoms(“name C”)
D = glucose.select_atoms(“name D”)

These are all atomgroups. The above only works correctly if the dihedral is INSIDE each residue. If it bridges residues you have to shift atoms around. Effectively, element i of each atomgroup has to form a dihedral: A[i] - B[i] - C[i] - D[i]. It’s up to you to line them up correctly.

Calculate all dihedrals

from MDAnalysis.lib.distances import calc_dihedrals 

results = []
times = []
for ts in u.trajectory:
dihedrals = calc_dihedrals(A, B, C, D, box=u.dimensions)
results.append(dihedrals)
times.append(ts.time)
results = np.array(results)
times = np.array(times)

plt.plot(times, results.T)    # should plot timeseries of all dihedrals

I didn’t try out the code above so it probably won’t exactly work that way. However, it should get you started and give you an idea where to look. Ultimately, you have to write your own code because there’s nothing in MDAnalysis specific for carbohydrates.

You can also use DihedralAnalysis https://docs.mdanalysis.org/stable/documentation_pages/analysis/dihedrals.html once you have your atom names.


Best,
Oliver


Please help me with the query.
Thanks and Regards.
Pawan Kumar

Code:
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import GRO, XTC
from MDAnalysis.analysis import dihedrals
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
u = mda.Universe("md_50.gro", "md_100.xtc")
glucose = u.select_atoms('resname AGLC')
print('There are {} residues in the amylose chain'.format(len(glucose.residues)))
for res in u.residues[1:26]:
    phi = res.phi_selection()
    if phi is None:
        names = None
    else:
        names = phi.names
    print('{}: {} '.format(res.resname, names))


--
Oliver Beckstein (he/his/him)

email: orbe...@mdanalysis.org
twitter: @orbeckst
GitHub: @orbeckst

MDAnalysis – a NumFOCUS fiscally sponsored project

Reply all
Reply to author
Forward
0 new messages