-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAngle_add_HACO.py
executable file
·133 lines (96 loc) · 5.31 KB
/
Angle_add_HACO.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/python
import os, sys
#Total commandline is "python Angle_add_HACO_02292016.py 3XXXH_cablam3CA_angle.txt 3XXX__dssp_1lineHeader.txt 3XXXH_onedot_1.0rad_All_02292016.txt PDBNAME"
# sys.argv is ["python Angle_add_HACO_02292016.py", "cablam_file", "dssp_file", "Probe_file", "PDBNAME"]
# sys.argv[1:] is ["cablam_file", "dssp_file", "Probe_file" ## [1:] is a string slicing notation adding everything that follows the command itself.
args = sys.argv[1:]
#sys.argv is a [] list of everything written on the commandline
#sys.argv[0] is the command itself (in this case "python Angle_add_HACO_02292016.py)
# so sys.argv[1:] is a list of everything after the initial command;
# PDB files can be run individually this way by adding the PDB file name as sysargv[1:]
if len(args) == 0: #no file submitted, print help text
print >> sys.stderr, """
This script accepts a probe-generated text file as input.
That file must start with the header line which contains "name:pat:type:srcAtom: ...""
"""
sys.exit() # Test worked; printed the above when NO file was entered.
#print >> printing location, thing to print
# an alternate printing syntax useful for going places other than sys.stdout
# The trailing comma after 'sys.stderr,' is necessary.
cablam_3CAangles_filename = args[0] ## see line 7 above: the cablam file will be the FIRST [0] argument following the command
cablamFile = open(cablam_3CAangles_filename) ## cablamFile will open the file named in the FIRST argument shown on the command line
CablamData = ["ResID", "MuIn", "MuOut", "VirtDihed", "CA3angle"] ## These are the 5 comma-delimited segments of cablam text output
cablamDict = {}
for line in cablamFile:
if line.startswith(",pdb:model:chain"):
continue
adjustlength = line.split(",") ## cablam output is strictly comma-delimited and can't be set up in a space-oriented format at this stage.
ResID = adjustlength[0]
CA3angle = adjustlength[4].strip()
key = ResID[4:10] ## had to put precise spaces to match dssp format exactly
##cablamDict[key] = round(float(CA3angle), 3)
if CA3angle == "NULL":
cablamDict[key] = CA3angle #This is entering "NULL" into the dictionary value set.
else:
cablamDict[key] = "%.1f" % float(CA3angle) ## Have to use the dictionary locator, not the variable name
## print ResID + " " + CA3angle
## cablamFile.close() ## Tests ok to here.
##keys = DsspDict.keys()
##keys.sort()
##for key in keys:
## print key, DsspDict[key] ## This tested perfectly: each ResNumber + ChainID is a key, and each SecStruct is a DsspDict key.
##import sys
##sys.exit()
dssp_file_name = args[1]
dssp_file = open(dssp_file_name)
DsspData = ['H','G','I','E','B','S','T']
DsspDict = {}
#Results = {'H':[],'G':[],'I':[],'E':[],'B':[],'S':[],'T':[]}
#this dictionary will hold the ResNumIDs pulled from the dssp file
# it is keyed by the dssp letter codes
for line in dssp_file:
ChainID = line[11:12]
ResNumber = line[6:10]
ResName = line[13:15]
SecStruct = line[16:17]
key = ChainID + ResNumber + " "
DsspDict[key] = SecStruct ##adds this to dict: {key:SecStruct}
##print key + " " + cablamDict[key] + " " + line[16:17]
probe_file_name = args[2]
probefile = open(probe_file_name)
ProbeData = ["PDBID", "contact", "SrcChainID", "SrcResNum", "SrcResName", "SrcAtom", "TgtChainID", "TgtResNum", "TgtResName", "TgtAtom", "GapWidth" ]
ProbeDict = {}
#Results = {'H':[],'G':[],'I':[],'E':[],'B':[],'S':[],'T':[]}
#this dictionary will hold the ResNumIDs pulled from the dssp file
# it is keyed by the dssp letter codes
for line in probefile:
if line.startswith("name"):
continue
adjustlength = line.split(":")
SrcResNum = line[11:15]
SrcChainID = line[10:11]
SrcResName = line[16:19]
SrcAtom = line[20:25]
TgtResNum = line[28:32]
TgtChainID = line[27:28]
TgtResName = line[33:36]
TgtAtom = line[37:41]
GapWidth = adjustlength[6]
Srckey = SrcChainID + SrcResNum + " "
Tgtkey = TgtChainID + TgtResNum + " "
ProbeDict[Srckey] = GapWidth ##adds this to dict: {key:SecStruct} \
## print ProbeDict[key]
if Srckey not in cablamDict:
continue
if Tgtkey not in cablamDict:
continue
##keys = DsspDict.keys()
##keys.sort()
##for key in keys:
## print key, DsspDict[key]
pdbname = args[3]
print pdbname + "," + Srckey + "," + SrcResName + "," + SrcAtom + "," + cablamDict[Srckey] + "," + DsspDict[Srckey] + "," + TgtChainID + "," + TgtResNum + "," + TgtResName + "," + TgtAtom + "," + cablamDict[Tgtkey] + "," + DsspDict[Tgtkey] + "," + ProbeDict[Srckey]
probefile.close()
dssp_file.close()
cablamFile.close()
## START HERE - figure out how to add back in the DSSP designations and add Cablam 3CA angle for Tgt residues . Mark on excel sheets all crease residues and all beta-barrel dots residues.