-
Notifications
You must be signed in to change notification settings - Fork 0
/
extractLastFrame.py
executable file
·46 lines (31 loc) · 984 Bytes
/
extractLastFrame.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
#! /usr/bin/python
import sys
import os
myFile = sys.argv[1]
myFO = "tmp.pdb"
myFrames = []
parsing = False
with open(myFile, "r") as f:
for line in f:
if "MODEL" in line:
myFrames.append(line[6:9].strip())
my_identifier = "MODEL %s" % myFrames[-1]
with open(myFO, "w") as fo:
with open(myFile, "r") as f:
for line in f:
if parsing:
fo.write(line)
parsing = True
elif my_identifier == line[:9].strip():
parsing = True
else:
parsing = False
cwd = os.getcwd()
myDir = cwd.split("/")[-1]
idx = myDir.find("_")
#cmd = "echo 0 | trjconv -f sampled.pos.pdb -s init.pdb -o tmp.pdb -dump %s"%(myFrames[-1])
#os.system(cmd)
#os.system("tail -n +4 tmp.pdb > tmp2.pdb")
os.system("sed -i.old '1s;^;CBLC >AB\\n;' tmp.pdb")
os.system("mv tmp.pdb ../my_structures_ctd/init%s.pdb" % myDir[idx:])
#os.system("rm tmp*")