-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchem_shift.py
More file actions
34 lines (28 loc) · 967 Bytes
/
chem_shift.py
File metadata and controls
34 lines (28 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Calculate backbone chemical shifts from a trajectory
# Arguments are the protein, the trajectory directory and the number of residues
import MDAnalysis as mda
import nmrgnn
import os
import sys
protein = sys.argv[1]
traj_dir = sys.argv[2]
n_res = int(sys.argv[3])
u = mda.Universe(
os.path.join("condensed_data", protein, f"{protein}.pdb"),
os.path.join(traj_dir, "protein", f"{protein}.dcd"),
)
prot = u.select_atoms("protein")
atoms_CA = u.select_atoms("name CA")
atoms_C = u.select_atoms(f"name C and resnum 1-{n_res-1}")
atoms_N = u.select_atoms(f"name N and resnum 2-{n_res}")
atoms_H = u.select_atoms(f"name H and resnum 2-{n_res}")
model = nmrgnn.load_model()
for ts in u.trajectory:
x = nmrgnn.universe2graph(prot)
peaks = model(x).numpy()
s = ""
for inds in [atoms_CA.ix, atoms_C.ix, atoms_N.ix, atoms_H.ix]:
for x in peaks[inds]:
s += f"{x:.4f} "
assert len(s.split()) == (n_res * 4 - 3)
print(s)