-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotein_split_backbone_sidechain.py
executable file
·37 lines (33 loc) · 1.18 KB
/
protein_split_backbone_sidechain.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
# Requires Python2.7
import sys
import subprocess
# This script highlights all possible backbone atoms and divides residues in protein into abckbone and sidechain groups via index
atominterest = ["H1 ", "H2 ", "H3 ", "HA ","O ", "OT1 ", "OT2 ", "HN ", "HA ", "CA ","C ","N "]
# Name of structure to be split
filename = str(sys.argv[1])
# Where files will be output to
fileout = str(sys.argv[2])
# First residue number
initialnumber = int(sys.argv[3])
count = 0
writeoutbb = ""
writeoutsc = ""
with open(filename) as f:
for line in f:
splitline = line.split()
if (splitline[0] == "ATOM"):
if initialnumber == int(splitline[5]):
if ((splitline[2]) + " ") in atominterest:
writeoutbb = writeoutbb + line
filetowrite = open(str(fileout) + str(splitline[3]) + str(splitline[5]) + "_backbone.pdb", 'w')
filetowrite.write(writeoutbb)
print line
elif ((splitline[2]) + " ") not in atominterest:
writeoutsc = writeoutsc + line
filetowrite = open(str(fileout) + str(splitline[3]) + str(splitline[5]) + "_sidechains.pdb", 'w')
filetowrite.write(writeoutsc)
print line
else:
writeoutsc = ""
writeoutbb = line
initialnumber = initialnumber+1