diff --git a/rescript/plugin_setup.py b/rescript/plugin_setup.py index 8eae397..17ea965 100644 --- a/rescript/plugin_setup.py +++ b/rescript/plugin_setup.py @@ -1056,15 +1056,16 @@ 'primer_fwd': Str, 'primer_rev': Str, 'position_start': Int % Range(1, None), - 'position_end': Int % Range(1, None) + 'position_end': Int % Range(1, None), + 'n_threads': Int % Range(1, None), }, outputs=[('trimmed_sequences', FeatureData[AlignedSequence]), ], input_descriptions={'aligned_sequences': 'Aligned DNA sequences.', }, parameter_descriptions={ 'primer_fwd': 'Forward primer used to find the start position ' - 'for alignment trimming.', + 'for alignment trimming. Provide as 5\'-3\'.', 'primer_rev': 'Reverse primer used to find the end position ' - 'for alignment trimming.', + 'for alignment trimming. Provide as 5\'-3\'.', 'position_start': 'Position within the alignment where the trimming ' 'will begin. If not provided, alignment will not' 'be trimmed at the beginning. If forward primer is' @@ -1072,7 +1073,10 @@ 'position_end': 'Position within the alignment where the trimming ' 'will end. If not provided, alignment will not be ' 'trimmed at the end. If reverse primer is specified ' - 'this parameter will be ignored.' + 'this parameter will be ignored.', + 'n_threads': 'Number of threads to use for primer-based trimming, ' + 'otherwise ignored. (Use `auto` to automatically use ' + 'all available cores)' }, output_descriptions={ 'trimmed_sequences': 'Trimmed sequence alignment.', }, diff --git a/rescript/trim_alignment.py b/rescript/trim_alignment.py index 297be24..da9f1de 100644 --- a/rescript/trim_alignment.py +++ b/rescript/trim_alignment.py @@ -190,11 +190,13 @@ def _trim_alignment(expand_alignment_action, primer_fwd=None, primer_rev=None, position_start=None, - position_end=None) -> AlignedDNAFASTAFormat: + position_end=None, + n_threads=1) -> AlignedDNAFASTAFormat: """ Trim alignment based on primer alignment or explicitly specified positions. When at least one primer sequence is given, primer-based - trimming will be performed, otherwise position-based trimming is done. + trimming will be performed via the `addfragments` option of mafft, + otherwise position-based trimming is done. Arguments: expand_alignment_action: qiime action for multiple seq. alignment @@ -222,7 +224,8 @@ def _trim_alignment(expand_alignment_action, alignment_with_primers, = expand_alignment_action( alignment=aligned_sequences, sequences=primers, - addfragments=True) + addfragments=True, + n_threads=n_threads) # find trim positions based on primer positions within alignment trim_positions = _locate_primer_positions(alignment_with_primers) @@ -244,7 +247,8 @@ def trim_alignment(ctx, primer_fwd=None, primer_rev=None, position_start=None, - position_end=None): + position_end=None, + n_threads=1): """ Trim an existing alignment based on provided primers or specific, pre-defined positions. Primers take precedence over the positions, @@ -263,6 +267,7 @@ def trim_alignment(ctx, primer_fwd, primer_rev, position_start, - position_end) + position_end, + n_threads=n_threads) return qiime2.Artifact.import_data('FeatureData[AlignedSequence]', result)