kfuku52 / amalgkit

RNA-seq data amalgamation for a large-scale evolutionary transcriptomics
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

raise Exception if returncode is not zero. #19

Closed kfuku52 closed 3 years ago

kfuku52 commented 3 years ago

It would be nice for debugging if amalgkit throws an error when external tools do not exit correctly. Here is an example code. Could you insert similar assertions or raise Exception() in relevant places?

    run_iqtree = subprocess.run([g['iqtree_exe'], '-s', g['alignment_file'], '-te', g['rooted_tree_file'],
                                 '-m', g['iqtree_model'], '--seqtype', 'CODON'+str(g['genetic_code']),
                                 '--threads-max', str(g['threads']), '-T', 'AUTO', '--ancestral', '--rate', '--redo'],
                                stdout=sys.stdout, stderr=sys.stderr)
    assert (run_iqtree.returncode==0), "IQ-TREE did not finish safely: {}".format(run_iqtree.stdout.decode('utf8'))
Hego-CCTB commented 3 years ago

Makes sense, I'll look into it.

Hego-CCTB commented 3 years ago

For debugging, I'll use assert() for the time being.

For error handling in a final release, it might be preferable to use try/except constructs, according to opinions on stackoverflow.

Hego-CCTB commented 3 years ago

forgot to push this update. Rectified now.