Skip to content
Snippets Groups Projects
Commit e5998ab4 authored by Gerardo Tauriello's avatar Gerardo Tauriello
Browse files

SCHWED-3472: skip dssp lines in hhr files and better document parsing.

parent df390f16
No related branches found
No related tags found
No related merge requests found
...@@ -215,6 +215,12 @@ def ParseHHblitsOutput(output): ...@@ -215,6 +215,12 @@ def ParseHHblitsOutput(output):
return seq.CreateAlignment(s1, s2) return seq.CreateAlignment(s1, s2)
try: try:
while True: while True:
# Lines which we are interested in:
# - "Done!" -> end of list
# - "No ..." -> next item in list
# - "T <hit_id> <start> <data> <end>"
# - "Q <query_id> <start> <data> <end>"
# -> rest is to be skipped
line = lines.next() line = lines.next()
if len(line.strip()) == 0: if len(line.strip()) == 0:
continue continue
...@@ -238,19 +244,30 @@ def ParseHHblitsOutput(output): ...@@ -238,19 +244,30 @@ def ParseHHblitsOutput(output):
lines.next() lines.next()
continue continue
assert entry_index != None assert entry_index != None
# Skip all "T ..." and "Q ..." lines besides the one we want
if line[1:].startswith(' Consensus'): if line[1:].startswith(' Consensus'):
continue continue
if line[1:].startswith(' ss_pred'): if line[1:].startswith(' ss_pred'):
continue continue
if line[1:].startswith(' ss_conf'): if line[1:].startswith(' ss_conf'):
continue continue
if line[1:].startswith(' ss_dssp'):
continue
if line.startswith('T '): if line.startswith('T '):
end_pos = line.find(' ', 22) end_pos = line.find(' ', 22)
assert end_pos != -1 # this can fail if we didn't skip all other "T ..." lines
if end_pos == -1:
error_str = "Unparsable line '%s' for entry No %d" \
% (line.strip(), entry_index + 1)
raise AssertionError(error_str)
templ_str += line[22:end_pos] templ_str += line[22:end_pos]
if line.startswith('Q '): if line.startswith('Q '):
end_pos = line.find(' ', 22) end_pos = line.find(' ', 22)
assert end_pos != -1 # this can fail if we didn't skip all other "Q ..." lines
if end_pos == -1:
error_str = "Unparsable line '%s' for entry No %d" \
% (line.strip(), entry_index + 1)
raise AssertionError(error_str)
query_str += line[22:end_pos] query_str += line[22:end_pos]
except StopIteration: except StopIteration:
if len(query_str) > 0: if len(query_str) > 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment