-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddcap.py
More file actions
executable file
·61 lines (58 loc) · 1.33 KB
/
Copy pathaddcap.py
File metadata and controls
executable file
·61 lines (58 loc) · 1.33 KB
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
#!/usr/bin/python
import sys,os
usage="""
Add Cap Using tLEaP.
Firstly addh
Then add cap NME and ACE to the C- and N- terminal of each peptide
Usage $0 in.pdb out.pdb
"""
if len(sys.argv)<3:
print usage
sys.exit()
infile,outfile=sys.argv[1:3]
leap1in='''
source leaprc.ff14SB
rec = loadpdb %s
savepdb rec addcap_tmp.pdb
quit
'''
ofp=open("addcap_tleap1.in","w")
ofp.write(leap1in%infile)
ofp.close()
os.system("tleap -f addcap_tleap1.in")
firstresi=True
lastter=True
cachedlines=""
oldindex=0
ofp=open("addcap_tmp2.pdb","w")
for line in open("addcap_tmp.pdb","r"):
if len(line)>30:index=int(line[22:26])
if index!=oldindex:
firstresi=lastter
oldindex=index
if firstresi:
if " H1 " not in line and " H2 " not in line and " H3 " not in line :
cachedlines=cachedlines+line
if not firstresi:
ofp.write(cachedlines)
cachedlines=""
if "OXT" in line:
ofp.write("%s N NME%s"%(line[:12],line[20:]))
elif "H3 " in line:
ofp.write("%s C ACE%s"%(line[:12],line[20:]))
elif not firstresi:
ofp.write(line)
else:
pass
lastter=("TER" in line)
ofp.close()
leap2in='''
source leaprc.ff14SB
rec = loadpdb addcap_tmp2.pdb
savepdb rec %s
quit
'''
ofp=open("addcap_leap2.in","w")
ofp.write(leap2in%outfile)
ofp.close()
os.system("tleap -f addcap_leap2.in")