Skip to content

Commit

Permalink
Fix traceback not being rendered even with --traceback flag
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Jun 24, 2020
1 parent 57adcad commit 33a0151
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions orthoani/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ def _hits(
args = shlex.split(str(cmd))
proc = subprocess.run(args, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

hits = collections.defaultdict(list)
hits = {}
for record in NCBIXML.parse(io.BytesIO(proc.stdout)):
if record.alignments:
nid = length = decimal.Decimal(0)
for hsp in record.alignments[0].hsps:
if hsp.align_length >= 0.35 * blocksize:
nid += hsp.identities
length += hsp.align_length
if length != 0:
if length > 0:
hits[record.query, record.alignments[0].hit_def] = nid / length
return hits

Expand Down
15 changes: 8 additions & 7 deletions orthoani/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def argument_parser():
def main(argv=None):
parser = argument_parser()
args = parser.parse_args(argv)
better_exceptions.hook()

try:
query = parse(args.query, "fasta")
Expand All @@ -70,9 +69,11 @@ def main(argv=None):
return -signal.SIGINT

except Exception as e:
print(e, file=sys.stderr)
try:
if args.traceback:
raise
finally:
return getattr(e, "errno", 1)
if args.traceback:
print(
better_exceptions.format_exception(type(e), e, e.__traceback__),
file=sys.stderr
)
else:
print(e, file=sys.stderr)
return getattr(e, "errno", 1)

0 comments on commit 33a0151

Please sign in to comment.