From 489e00073c0a7b4acddc83af25dddd0a7a0ee2b9 Mon Sep 17 00:00:00 2001 From: litwinowicz Date: Wed, 14 Sep 2022 10:33:51 +0200 Subject: [PATCH] Fixed stand-alone version of multiple-seq-alignment --- deblur/workflow.py | 7 +++++-- scripts/deblur | 6 ++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/deblur/workflow.py b/deblur/workflow.py index 30e20d6..e6a863c 100644 --- a/deblur/workflow.py +++ b/deblur/workflow.py @@ -492,7 +492,7 @@ def op(x): return x in aligned_seq_ids return output_fp, okseqs, [blast_output_filename] -def multiple_sequence_alignment(seqs_fp, threads=1): +def multiple_sequence_alignment(seqs_fp, threads=1, output_fp=None): """Perform multiple sequence alignment on FASTA file using MAFFT. Parameters @@ -517,7 +517,10 @@ def multiple_sequence_alignment(seqs_fp, threads=1): if stat(seqs_fp).st_size == 0: logger.warning('msa failed. file %s has no reads' % seqs_fp) return None - msa_fp = seqs_fp + '.msa' + if output_fp is None: + msa_fp = seqs_fp + '.msa' + else: + msa_fp = output_fp params = ['mafft', '--quiet', '--preservecase', '--parttree', '--auto', '--thread', str(threads), seqs_fp] sout, serr, res = _system_call(params, stdoutfilename=msa_fp) diff --git a/scripts/deblur b/scripts/deblur index dcb2c25..95a4437 100755 --- a/scripts/deblur +++ b/scripts/deblur @@ -325,10 +325,8 @@ def multiple_seq_alignment(seqs_fp, output_fp, threads_per_sample, """Multiple sequence alignment""" start_log(level=log_level * 10, filename=log_file) alignment = multiple_sequence_alignment(seqs_fp, - threads=threads_per_sample) - - with open(output_fp, 'w') as f: - f.write(alignment.to_fasta()) + threads=threads_per_sample, + output_fp=output_fp) # DE NOVO CHIMERA REMOVAL COMMAND