-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93a3098
commit 1e601c4
Showing
5 changed files
with
165 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# ---------------------------------------------------------------------------- | ||
# Copyright (c) 2024, Greg Caporaso. | ||
# | ||
# Distributed under the terms of the Modified BSD License. | ||
# | ||
# The full license is in the file LICENSE, distributed with this software. | ||
# ---------------------------------------------------------------------------- | ||
|
||
from ._methods import _nw_align_defaults | ||
|
||
|
||
def align_and_summarize( | ||
ctx, seq1, seq2, | ||
gap_open_penalty=_nw_align_defaults['gap_open_penalty'], | ||
gap_extend_penalty=_nw_align_defaults['gap_extend_penalty'], | ||
match_score=_nw_align_defaults['match_score'], | ||
mismatch_score=_nw_align_defaults['mismatch_score']): | ||
nw_align_action = ctx.get_action('dwq2', 'nw_align') | ||
summarize_alignment_action = ctx.get_action('dwq2', 'summarize_alignment') | ||
|
||
msa, = nw_align_action( | ||
seq1, seq2, gap_open_penalty=gap_open_penalty, | ||
gap_extend_penalty=gap_extend_penalty, | ||
match_score=match_score, mismatch_score=mismatch_score) | ||
msa_summary, = summarize_alignment_action(msa) | ||
|
||
return (msa, msa_summary) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# ---------------------------------------------------------------------------- | ||
# Copyright (c) 2024, Greg Caporaso. | ||
# | ||
# Distributed under the terms of the Modified BSD License. | ||
# | ||
# The full license is in the file LICENSE, distributed with this software. | ||
# ---------------------------------------------------------------------------- | ||
|
||
import skbio | ||
|
||
import qiime2 | ||
from qiime2.plugin.testing import TestPluginBase | ||
|
||
|
||
class AlignAndSummarizeTests(TestPluginBase): | ||
package = 'q2_dwq2.tests' | ||
|
||
def test_simple1(self): | ||
# access the pipeline as QIIME 2 sees it, | ||
# for correct assignment of `ctx` variable | ||
align_and_summarize_pipeline = \ | ||
self.plugin.pipelines['align_and_summarize'] | ||
|
||
sequence1 = skbio.DNA('AAAAAAAAGGTGGCCTTTTTTTT', | ||
metadata={'id': 's1', 'description': ''}) | ||
sequence2 = skbio.DNA('AAAAAAAAGGGGCCTTTTTTTT', | ||
metadata={'id': 's2', 'description': ''}) | ||
sequence1_art = qiime2.Artifact.import_data( | ||
"SingleDNASequence", sequence1, view_type=skbio.DNA) | ||
sequence2_art = qiime2.Artifact.import_data( | ||
"SingleDNASequence", sequence2, view_type=skbio.DNA) | ||
observed_msa, observed_viz = align_and_summarize_pipeline( | ||
sequence1_art, sequence2_art) | ||
|
||
aligned_sequence1 = skbio.DNA('AAAAAAAAGGTGGCCTTTTTTTT', | ||
metadata={'id': 's1', 'description': ''}) | ||
aligned_sequence2 = skbio.DNA('AAAAAAAAGG-GGCCTTTTTTTT', | ||
metadata={'id': 's2', 'description': ''}) | ||
expected_msa = skbio.TabularMSA([aligned_sequence1, aligned_sequence2]) | ||
|
||
# observed_msa output is a qiime2.Artifact, so view it as a | ||
# skbio.TabularMSA for comparison to expected_msa. | ||
self.assertEqual(observed_msa.view(skbio.TabularMSA), expected_msa) | ||
|
||
# observed_viz is a qiime2.Visualization. | ||
# access its index.html file for testing. | ||
index_fp = observed_viz.get_index_paths(relative=False)['html'] | ||
with open(index_fp, 'r') as fh: | ||
observed_index = fh.read() | ||
self.assertIn(str(aligned_sequence1), observed_index) | ||
self.assertIn(str(aligned_sequence2), observed_index) |