Skip to content
Snippets Groups Projects
Commit 38a4f735 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

port of hhblits binding to Python 3

parent c40bc799
No related branches found
No related tags found
No related merge requests found
...@@ -193,7 +193,8 @@ def ParseHHblitsOutput(output): ...@@ -193,7 +193,8 @@ def ParseHHblitsOutput(output):
return header return header
def _ParseTableOfContents(lines): def _ParseTableOfContents(lines):
assert lines.next().startswith(' No Hit') line = next(lines)
assert line.startswith(' No Hit')
hits = [] hits = []
while True: while True:
line = next(lines) line = next(lines)
...@@ -236,7 +237,8 @@ def ParseHHblitsOutput(output): ...@@ -236,7 +237,8 @@ def ParseHHblitsOutput(output):
query_id, hits[entry_index][0].hit_id, query_id, hits[entry_index][0].hit_id,
query_str, templ_str, *hits[entry_index][1]) query_str, templ_str, *hits[entry_index][1])
entry_index = int(line[3:].strip())-1 entry_index = int(line[3:].strip())-1
hits[entry_index][0].hit_id = lines.next()[1:].strip() line = next(lines)
hits[entry_index][0].hit_id = line[1:].strip()
query_str = '' query_str = ''
templ_str = '' templ_str = ''
# skip the next line. It doesn't contain information we # skip the next line. It doesn't contain information we
...@@ -566,7 +568,8 @@ class HHblits: ...@@ -566,7 +568,8 @@ class HHblits:
(self.hhblits_bin, self.filename, a3m_file, full_nrdb, (self.hhblits_bin, self.filename, a3m_file, full_nrdb,
opt_cmd) opt_cmd)
job = subprocess.Popen(hhblits_cmd, shell=True, cwd=self.working_dir, job = subprocess.Popen(hhblits_cmd, shell=True, cwd=self.working_dir,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True)
sout, _ = job.communicate() sout, _ = job.communicate()
lines = sout.splitlines() lines = sout.splitlines()
for line in lines: for line in lines:
...@@ -586,7 +589,7 @@ class HHblits: ...@@ -586,7 +589,7 @@ class HHblits:
os.environ['PATH'])}) os.environ['PATH'])})
job = subprocess.Popen(addss_cmd, shell=True, cwd=self.working_dir, job = subprocess.Popen(addss_cmd, shell=True, cwd=self.working_dir,
env=env, stdout=subprocess.PIPE, env=env, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE, universal_newlines=True)
sout, serr = job.communicate() sout, serr = job.communicate()
lines = sout.splitlines() lines = sout.splitlines()
for line in lines: for line in lines:
...@@ -623,7 +626,7 @@ class HHblits: ...@@ -623,7 +626,7 @@ class HHblits:
ost.LogVerbose('converting %s to %s' % (a3m_file, hhm_file)) ost.LogVerbose('converting %s to %s' % (a3m_file, hhm_file))
os.putenv('HHLIB', self.hhlib_dir) os.putenv('HHLIB', self.hhlib_dir)
if subprocess.call('%s -i %s -o %s' % (hhmake, a3m_file, hhm_file), if subprocess.call('%s -i %s -o %s' % (hhmake, a3m_file, hhm_file),
shell=True): shell=True, universal_newlines=True):
raise IOError('could not convert a3m to hhm file') raise IOError('could not convert a3m to hhm file')
return hhm_file return hhm_file
...@@ -665,10 +668,9 @@ class HHblits: ...@@ -665,10 +668,9 @@ class HHblits:
job = subprocess.Popen(cs_cmd, shell=True, cwd=self.working_dir, job = subprocess.Popen(cs_cmd, shell=True, cwd=self.working_dir,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sout, _ = job.communicate() sout, _ = job.communicate()
lines = sout.splitlines() if b'Wrote abstract state sequence to' in sout:
for line in lines: return cs_file
if 'Wrote abstract state sequence to' in line:
return cs_file
ost.LogWarning('Creating column state sequence file (%s) failed' % \ ost.LogWarning('Creating column state sequence file (%s) failed' % \
cs_file) cs_file)
...@@ -734,7 +736,8 @@ class HHblits: ...@@ -734,7 +736,8 @@ class HHblits:
ost.LogInfo('searching %s' % database) ost.LogInfo('searching %s' % database)
ost.LogVerbose(search_cmd) ost.LogVerbose(search_cmd)
job = subprocess.Popen(search_cmd, shell=True, cwd=self.working_dir, job = subprocess.Popen(search_cmd, shell=True, cwd=self.working_dir,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True)
sout, serr = job.communicate() sout, serr = job.communicate()
if job.returncode != 0: if job.returncode != 0:
lines = sout.splitlines() lines = sout.splitlines()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment