Skip to content

Commit

Permalink
MAINT: add threads/jobs primitives (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherman2 committed Feb 13, 2024
1 parent f4a4883 commit a0e44f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion q2_alignment/_mafft.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _mafft(sequences_fp, alignment_fp, n_threads, parttree, addfragments):
# mafft's signal for utilizing all cores is -1. We want to our users
# to enter auto for using all cores. This is to prevent any confusion and
# to keep the UX consisent.
if n_threads == 'auto':
if n_threads == 0:
n_threads = -1

# `--inputorder` must be turned on because we need the input and output in
Expand Down
6 changes: 3 additions & 3 deletions q2_alignment/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# ----------------------------------------------------------------------------

from qiime2.plugin import (
Plugin, Float, Int, Bool, Range, Citations, Str, Choices)
Plugin, Float, Bool, Range, Citations, Threads)
from q2_types.feature_data import FeatureData, Sequence, AlignedSequence

import q2_alignment
Expand All @@ -26,7 +26,7 @@
plugin.methods.register_function(
function=q2_alignment.mafft,
inputs={'sequences': FeatureData[Sequence]},
parameters={'n_threads': Int % Range(1, None) | Str % Choices(['auto']),
parameters={'n_threads': Threads,
'parttree': Bool},
outputs=[('alignment', FeatureData[AlignedSequence])],
input_descriptions={'sequences': 'The sequences to be aligned.'},
Expand All @@ -45,7 +45,7 @@
function=q2_alignment.mafft_add,
inputs={'alignment': FeatureData[AlignedSequence],
'sequences': FeatureData[Sequence]},
parameters={'n_threads': Int % Range(1, None) | Str % Choices(['auto']),
parameters={'n_threads': Threads,
'parttree': Bool,
'addfragments': Bool},
outputs=[('expanded_alignment', FeatureData[AlignedSequence])],
Expand Down
2 changes: 1 addition & 1 deletion q2_alignment/tests/test_mafft.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_multithreaded_mafft(self):
input_sequences, exp = self._prepare_sequence_data()

with redirected_stdio(stderr=os.devnull):
result = mafft(input_sequences, n_threads='auto')
result = mafft(input_sequences, n_threads=0)
obs = skbio.io.read(str(result), into=skbio.TabularMSA,
constructor=skbio.DNA)
self.assertEqual(obs, exp)
Expand Down

0 comments on commit a0e44f7

Please sign in to comment.