Skip to content

Commit

Permalink
rename param to addfragments
Browse files Browse the repository at this point in the history
  • Loading branch information
misialq committed Nov 2, 2020
1 parent 5c12aeb commit 10b293d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions q2_alignment/_mafft.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run_command(cmd, output_fp, verbose=True):
subprocess.run(cmd, stdout=output_f, check=True)


def _mafft(sequences_fp, alignment_fp, n_threads, parttree, fragments):
def _mafft(sequences_fp, alignment_fp, n_threads, parttree, addfragments):
# Save original sequence IDs since long ids (~250 chars) can be truncated
# by mafft. We'll replace the IDs in the aligned sequences file output by
# mafft with the originals.
Expand Down Expand Up @@ -92,7 +92,7 @@ def _mafft(sequences_fp, alignment_fp, n_threads, parttree, fragments):
cmd += ['--parttree']

if alignment_fp is not None:
add_flag = '--addfragments' if fragments else '--add'
add_flag = '--addfragments' if addfragments else '--add'
cmd += [add_flag, sequences_fp, alignment_fp]
else:
cmd += [sequences_fp]
Expand Down Expand Up @@ -132,7 +132,8 @@ def mafft_add(alignment: AlignedDNAFASTAFormat,
sequences: DNAFASTAFormat,
n_threads: int = 1,
parttree: bool = False,
fragments: bool = False) -> AlignedDNAFASTAFormat:
addfragments: bool = False) -> AlignedDNAFASTAFormat:
alignment_fp = str(alignment)
sequences_fp = str(sequences)
return _mafft(sequences_fp, alignment_fp, n_threads, parttree, fragments)
return _mafft(
sequences_fp, alignment_fp, n_threads, parttree, addfragments)
7 changes: 4 additions & 3 deletions q2_alignment/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
'sequences': FeatureData[Sequence]},
parameters={'n_threads': Int % Range(1, None) | Str % Choices(['auto']),
'parttree': Bool,
'fragments': Bool},
'addfragments': Bool},
outputs=[('expanded_alignment', FeatureData[AlignedSequence])],
input_descriptions={'alignment': 'The alignment to which '
'sequences should be added.',
Expand All @@ -57,8 +57,9 @@
'all available cores)',
'parttree': 'This flag is required if the number of sequences being '
'aligned are larger than 1000000. Disabled by default',
'fragments': 'This flag indicates that alignment optimized for '
'addition of fragmentary sequences should be used.'},
'addfragments': 'Optimize for the addition of short sequence '
'fragments (for example, primer or amplicon '
'sequences).'},
output_descriptions={
'expanded_alignment': 'Alignment containing the provided aligned and '
'unaligned sequences.'},
Expand Down
4 changes: 2 additions & 2 deletions q2_alignment/tests/test_mafft.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_mafft_add_fragments(self):
alignment, sequences, exp = self._prepare_sequence_data()

with redirected_stdio(stderr=os.devnull):
result = mafft_add(alignment, sequences, fragments=True)
result = mafft_add(alignment, sequences, addfragments=True)
obs = skbio.io.read(str(result), into=skbio.TabularMSA,
constructor=skbio.DNA)
self.assertEqual(obs, exp)
Expand All @@ -133,7 +133,7 @@ def test_mafft_add_flags(self):
["mafft", "--preservecase", "--inputorder", "--thread",
"1", "--add", ANY, ANY], ANY)

_ = mafft_add(alignment, sequences, fragments=True)
_ = mafft_add(alignment, sequences, addfragments=True)
patched_run_cmd.assert_called_with(
["mafft", "--preservecase", "--inputorder", "--thread",
"1", "--addfragments", ANY, ANY], ANY)
Expand Down

0 comments on commit 10b293d

Please sign in to comment.