Skip to content

Commit

Permalink
Merge pull request #202 from Ecogenomics/python3_dev
Browse files Browse the repository at this point in the history
try/except clause for 3rd party software.
  • Loading branch information
pchaumeil authored Dec 5, 2019
2 parents 1a47549 + 72bdf37 commit 740c527
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 27 deletions.
2 changes: 2 additions & 0 deletions gtdbtk/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
1.0.1
- Bugfix for 3rd party software versions.
1.0.0
- Migrated to Python3.
- check_install now does an exhaustive check of the reference data.
Expand Down
13 changes: 8 additions & 5 deletions gtdbtk/external/fasttree.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ def __init__(self):

def get_version(self):
""" Get FastTree version. """
env = os.environ.copy()
args = ['FastTree']
proc = subprocess.Popen(args, stdout=subprocess.PIPE,
try:
env = os.environ.copy()
args = ['FastTree']
proc = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env, encoding='utf-8')
output, error = proc.communicate()
return error.split('\n')[0].split(' ')[4]
output, error = proc.communicate()
return error.split('\n')[0].split(' ')[4]
except:
return "(version unavailable)"

def run(self, output_tree, tree_log, fasttree_log, prot_model, no_support, no_gamma, msa_file, cpus=1):
"""Run FastTree.
Expand Down
19 changes: 12 additions & 7 deletions gtdbtk/external/hmm_aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,20 @@ def __init__(self,

def get_version(self):
""" get HMMER version."""
env = os.environ.copy()
proc = subprocess.Popen(['hmmalign', '-h'], stdout=subprocess.PIPE,
try:
env = os.environ.copy()
proc = subprocess.Popen(['hmmalign', '-h'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env, encoding='utf-8')

output, error = proc.communicate()
for line in output.split('\n'):
if line.startswith('# HMMER'):
version = line.split(';')[0].replace('# HMMER', '').strip()
return version
output, error = proc.communicate()
for line in output.split('\n'):
if line.startswith('# HMMER'):
version = line.split(';')[0].replace('# HMMER', '').strip()
return version
return "(version unavailable)"
except:
return "(version unavailable)"


def align_marker_set(self, db_genome_ids, marker_set_id):
"""Threaded alignment using hmmalign for a given set of genomes.
Expand Down
11 changes: 7 additions & 4 deletions gtdbtk/external/pplacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ def __init__(self):
self.version = self._get_version()

def _get_version(self):
env = os.environ.copy()
proc = subprocess.Popen(['pplacer', '--version'], stdout=subprocess.PIPE,
try:
env = os.environ.copy()
proc = subprocess.Popen(['pplacer', '--version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env, encoding='utf-8')

output, error = proc.communicate()
return output.strip()
output, error = proc.communicate()
return output.strip()
except:
return "(version unavailable)"

def run(self, cpus, model, ref_pkg, json_out, msa_file, pplacer_out,
mmap_file=None):
Expand Down
11 changes: 7 additions & 4 deletions gtdbtk/external/prodigal.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ def __init__(self,
self.version = self._get_version()

def _get_version(self):
env = os.environ.copy()
proc = subprocess.Popen(['prodigal', '-v'], stdout=subprocess.PIPE,
try:
env = os.environ.copy()
proc = subprocess.Popen(['prtrrodigal', '-v'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env, encoding='utf-8')

output, error = proc.communicate()
output, error = proc.communicate()

return error.split('\n')[1].split()[1].replace(':', '')
return error.split('\n')[1].split()[1].replace(':', '')
except:
return "(version unavailable)"

def _run_prodigal(self, genome_id, fasta_path):
"""Run Prodigal.
Expand Down
18 changes: 11 additions & 7 deletions gtdbtk/external/tigrfam_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@ def __init__(self,

def _get_version(self):
""" get HMMER version."""
env = os.environ.copy()
proc = subprocess.Popen(['hmmsearch', '-h'], stdout=subprocess.PIPE,
try:
env = os.environ.copy()
proc = subprocess.Popen(['hmmsearch', '-h'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env, encoding='utf-8')

output, error = proc.communicate()
for line in output.split('\n'):
if line.startswith('# HMMER'):
version = line.split(';')[0].replace('# HMMER', '').strip()
return version
output, error = proc.communicate()
for line in output.split('\n'):
if line.startswith('# HMMER'):
version = line.split(';')[0].replace('# HMMER', '').strip()
return version
return "(version unavailable)"
except:
return "(version unavailable)"

def _topHit(self, tigrfam_file):
"""Determine top hits to TIGRFAMs.
Expand Down

0 comments on commit 740c527

Please sign in to comment.