diff --git a/q2_vsearch/_examples.py b/q2_vsearch/_examples.py new file mode 100644 index 0000000..182a869 --- /dev/null +++ b/q2_vsearch/_examples.py @@ -0,0 +1,40 @@ +# ---------------------------------------------------------------------------- +# Copyright (c) 2016-2023, QIIME 2 development team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file LICENSE, distributed with this software. +# ---------------------------------------------------------------------------- + +from qiime2.plugins import ArtifactAPIUsage + +rep_seqs_url = \ + ('https://s3-us-west-2.amazonaws.com/qiime2-data/2024.2/' + 'tutorials/chimera/atacama-rep-seqs.qza') + +table_url = \ + ('https://s3-us-west-2.amazonaws.com/qiime2-data/2024.2/' + 'tutorials/chimera/atacama-table.qza') + +use = ArtifactAPIUsage() + + +def cluster_features_de_novo(use): + rep_seqs = use.init_artifact_from_url('seqs1', rep_seqs_url) + table = use.init_artifact_from_url('table1', table_url) + + perc_identity = 0.97 + strand = 'plus' + threads = 1 + + clustered_table, clustered_sequences = use.action( + use.UsageAction('vsearch', 'cluster_features_de_novo'), + use.UsageInputs(sequences=rep_seqs, table=table, + perc_identity=perc_identity, strand=strand, + threads=threads), + use.UsageOutputNames(clustered_table='clustered_table', + clustered_sequences='clustered_sequences') + ) + + clustered_table.assert_output_type('FeatureTable[Frequency]') + clustered_sequences.assert_output_type('FeatureData[Sequence]') diff --git a/q2_vsearch/plugin_setup.py b/q2_vsearch/plugin_setup.py index 1380e06..2680044 100644 --- a/q2_vsearch/plugin_setup.py +++ b/q2_vsearch/plugin_setup.py @@ -14,6 +14,7 @@ import q2_vsearch._merge_pairs import q2_vsearch._chimera import q2_vsearch._stats +from q2_vsearch._examples import cluster_features_de_novo from q2_vsearch._type import UchimeStats from q2_vsearch._format import UchimeStatsFmt, UchimeStatsDirFmt @@ -92,7 +93,9 @@ 'were clustered in that sample. Feature identifiers and ' 'sequences will be inherited from the centroid feature ' 'of each cluster. See the vsearch documentation for details ' - 'on how sequence clustering is performed.') + 'on how sequence clustering is performed.'), + examples={'cluster_features_de_novo': + cluster_features_de_novo} ) plugin.methods.register_function( diff --git a/q2_vsearch/tests/test_examples.py b/q2_vsearch/tests/test_examples.py new file mode 100644 index 0000000..6b947e5 --- /dev/null +++ b/q2_vsearch/tests/test_examples.py @@ -0,0 +1,16 @@ +# ---------------------------------------------------------------------------- +# Copyright (c) 2016-2023, QIIME 2 development team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file LICENSE, distributed with this software. +# ---------------------------------------------------------------------------- + +from qiime2.plugin.testing import TestPluginBase + + +class TestUsageExample(TestPluginBase): + package = 'q2_vsearch.tests' + + def test_usage_cluster_features_de_novo(self): + self.execute_examples()