-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbat_read_align_file.py
More file actions
40 lines (34 loc) · 1015 Bytes
/
bat_read_align_file.py
File metadata and controls
40 lines (34 loc) · 1015 Bytes
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
# Module that reads output alignment file from DALI
# for BAT
#
#
# Joe Bemister
#
# 07/30/2015
#
#
# modified:
#
#
#
import sys
def read(sFilename):
'''Opens a DALI alignment file and returns an alignment dictionary for the query
as well as a pdb code for the target and the query protein.'''
try:
objFile = open(sFilename, 'r')
except IOError:
print("\n\n ERROR: could not open {}\n\n".format(sFilename))
sys.exit()
d_query_align = {}
for line in objFile:
if 'Position 1' in line:
target = line[-5:-1]
elif 'Position 2' in line:
query = line[-5:-1]
elif '<=>' in line:
index1, index2 = line.find('<=>'), line.rfind('<=>')
for i in range(int(line[index1 - 11: index1 - 7]), int(line[index1 - 5: index1 - 1]) + 1):
d_query_align[i] = i + int(line[index2 + 8: index2 + 12]) - int(line[index1 - 11: index1 - 7])
objFile.close()
return d_query_align, target, query