Mercurial > repos > iuc > tn93_cluster
diff tn93_cluster.py @ 1:112d80c9ccca draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/tn93/ commit 98c0d716cbd1237ae735ce83e0153ee246abd5d8"
author | iuc |
---|---|
date | Wed, 20 Apr 2022 17:00:11 +0000 |
parents | af03f3398f03 |
children | eb6f0ec5b95e |
line wrap: on
line diff
--- a/tn93_cluster.py Fri Apr 23 03:04:15 2021 +0000 +++ b/tn93_cluster.py Wed Apr 20 17:00:11 2022 +0000 @@ -2,7 +2,6 @@ import json import os import shlex -import shutil import subprocess import sys @@ -41,27 +40,22 @@ def main(arguments): threshold = arguments.threshold step = threshold * 0.25 - shutil.copy(arguments.input, os.path.join(os.getcwd(), 'reference_msa.fa')) - shutil.copy(arguments.input, os.path.join(os.getcwd(), 'reference_msa.fa.bak')) with open(arguments.reference) as fh: for line in fh: if line[0] == '>': _ref_seq_name = line[1:].split(' ')[0].strip() break - while True and threshold <= 1: - command = 'tn93-cluster -o clusters.json -t %g -a %s -c %s -m json -l %d -g %f reference_msa.fa' % (threshold, arguments.ambigs, arguments.cluster_type, arguments.overlap, arguments.fraction) + while threshold <= 1: + command = 'tn93-cluster -o clusters.json -t %g -a %s -c %s -m json -l %d -g %f %s' % (threshold, arguments.ambigs, arguments.cluster_type, arguments.overlap, arguments.fraction, arguments.input) return_code = run_command(command) if return_code != 0: return return_code - input_stamp, cluster_count = cluster_to_fasta('clusters.json', 'reference_msa.fa.bak', _ref_seq_name) - if cluster_count <= arguments.cluster_count or threshold == 1: + input_stamp, cluster_count = cluster_to_fasta('clusters.json', 'clusters.fa', _ref_seq_name) + if cluster_count <= arguments.cluster_count: break else: threshold += step print('Found %d clusters at threshold %f' % (cluster_count, threshold)) - shutil.copy('reference_msa.fa.bak', arguments.compressed) - shutil.copy('clusters.json', arguments.output) - os.remove('reference_msa.fa.bak') return 0