-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmda_rgyr_fix.py
54 lines (38 loc) · 1.39 KB
/
mda_rgyr_fix.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! Calculate Radius of Gyration (Rgyr).
#! _author : Ropón-Palacios G.
#! _date : Feb 27, 2022.
#! _e-mail : [email protected]
import optparse
import subprocess
import MDAnalysis as mda
import numpy as np
import pandas as pd
disclaimer="""<MDAnalysis Rgyr Tool>"""
parser = optparse.OptionParser(description=disclaimer)
#! INPUTS options
parser.add_option("--coord", help="coord [GRO, PSF, PARM7]", type=str)
parser.add_option("--traj", help="traj [XTC, DCD, NETCDF or DRT]", type=str)
parser.add_option("--sel", help="syntaxis-based in MDAnalysis [\"protein and name CA\"]", type=str,action='store')
#! OUTPUT options
parser.add_option("--ofile", help="type output name [rgyr_prot_nameCA.dat]", type=str)
options, args = parser.parse_args()
#! Load trajectory
universe = mda.Universe(options.coord, options.traj)
#! Define routine
def rgyr(traj, seltext1, ofile):
rgyr = []
time = []
u1 = traj
sel = u1.select_atoms(seltext1)
for ts in u1.trajectory:
time.appen(u1.trajectory.time/1000)
rgyr.append(sel.radius_of_gyration())
#larray = np.array((time,rgyr))
df = pd.DataFrame({"time":time, "rgyr":rgyr})
df.to_csv(ofile, index=False, sep="\t")
print("file Rgyr write to : ", ofile)
#! Call routine
selAtoms = options.sel
ofile = options.ofile
rgyr(universe, selAtoms, ofile)
print ("Rgyr calculations finished!!!")