-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbp2crd.py
executable file
·65 lines (54 loc) · 2.3 KB
/
bp2crd.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
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python3
import sys
import adios2
scale_factor = 10
def trajectories_bp_to_crd(bp_file_name, crd_file_name):
with adios2.open(bp_file_name, "r") as fh:
with open(crd_file_name, "w") as w:
w.write("AMBER trajectory file\n")
for fstep in fh:
step = fstep.current_step()
print("processing step: {}".format(step))
coords_solute = fstep.read("solute/coords")
coords_solvent = fstep.read("solvent/coords")
out_string = list();
for atom_number in range(0, coords_solute.shape[0]):
out_string.append(coords_solute[atom_number][0] * scale_factor)
out_string.append(coords_solute[atom_number][1] * scale_factor)
out_string.append(coords_solute[atom_number][2] * scale_factor)
last = len(out_string) - len(out_string) % 10
for pos in range(0, last, 10):
w.write(
"{:6.3} {:6.3} {:6.3} {:6.3} {:6.3} {:6.3} {:6.3} {:6.3} {:6.3} {:6.3}\n".format(
out_string[pos],
out_string[
pos + 1],
out_string[
pos + 2],
out_string[
pos + 3],
out_string[
pos + 4],
out_string[
pos + 5],
out_string[
pos + 6],
out_string[
pos + 7],
out_string[
pos + 8],
out_string[
pos + 9]))
for pos in range(last, len(out_string)):
w.write("%6.3f " % out_string[pos])
w.write("\n")
return
def print_usage():
print("usage: bp2crd name_of_bp_file name_of_crd_file")
if __name__ == '__main__':
if len(sys.argv) != 3:
print_usage()
sys.exit(1)
bp_file_name = sys.argv[1]
crd_file_name = sys.argv[2]
trajectories_bp_to_crd(bp_file_name, crd_file_name)