Skip to content

Commit

Permalink
add search-and-summarize usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcaporaso committed Aug 21, 2024
1 parent 0471a4a commit df8bd0c
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 2 deletions.
41 changes: 41 additions & 0 deletions q2_dwq2/_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------

import importlib.resources

import skbio

import qiime2
from q2_types.feature_data import DNAFASTAFormat


def seq1_factory():
Expand Down Expand Up @@ -46,3 +49,41 @@ def align_and_summarize_example_1(use):
use.UsageOutputNames(aligned_sequences='msa',
msa_summary='msa_summary'),
)


def _get_filepath_from_tests(path):
# this utility function may be transferred to the QIIME 2 framework
# track progress here: https://github.com/qiime2/qiime2/issues/792
return importlib.resources.files('q2_dwq2.tests') / path


def query1_factory():
fp = _get_filepath_from_tests('data/ss-query.fasta')
return qiime2.Artifact.import_data(
"FeatureData[Sequence]", fp, view_type=DNAFASTAFormat
)


def reference1_factory():
fp = _get_filepath_from_tests('data/ss-ref.fasta')
return qiime2.Artifact.import_data(
"FeatureData[Sequence]", fp, view_type=DNAFASTAFormat
)


def search_and_summarize_example_1(use):
query_seqs = use.init_artifact('query_seqs', query1_factory)
reference_seqs = use.init_artifact('reference_seqs', reference1_factory)
use.comment("This is an example of running this Pipeline serially.")
use.comment("The modification to run this in parallel depends on the "
"interface you're using (for example, using q2cli you would "
"append the --parallel flag).")

hits, hits_table, = use.action(
use.UsageAction(plugin_id='dwq2',
action_id='search_and_summarize'),
use.UsageInputs(query_seqs=query_seqs,
reference_seqs=reference_seqs,
split_size=1),
use.UsageOutputNames(hits='hits', hits_table='hits-table')
)
6 changes: 4 additions & 2 deletions q2_dwq2/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
from q2_dwq2._visualizers import (
summarize_alignment, tabulate_las_results)
from q2_dwq2._pipelines import align_and_summarize, search_and_summarize
from q2_dwq2._examples import nw_align_example_1, align_and_summarize_example_1
from q2_dwq2._examples import (nw_align_example_1,
align_and_summarize_example_1,
search_and_summarize_example_1)
from q2_dwq2 import (
SingleDNASequence, SingleRecordDNAFASTAFormat,
SingleRecordDNAFASTADirectoryFormat, LocalAlignmentSearchResults,
Expand Down Expand Up @@ -281,7 +283,7 @@
description=("Perform local alignment search of a query sequence against "
"reference sequences and report the results in a table."),
citations=[],
examples={}
examples={'Serial local alignment search': search_and_summarize_example_1}
)

importlib.import_module('q2_dwq2._transformers')
10 changes: 10 additions & 0 deletions q2_dwq2/tests/data/ss-query.fasta
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
>RS_GCF_018917925.1~NZ_JAHLPO010000048.1 d__Bacteria;p__Bacillota_A;c__Clostridia;o__Oscillospirales;f__Butyricicoccaceae;g__Pseudobutyricicoccus;s__Pseudobutyricicoccus sp003477405 [location=3441..4867] [ssu_len=1427] [contig_len=4886]
TGCTTAGTGGCGGACGGGTGAGTAACGCGTGAGGAACCTGCCTTTCAGTGGGGGATAACACATCGAAAGATGTGCTAATACCGCATAACATAGCGATGGGGCATCCCATTGCTATCAAAGATTTATTGCTGAAAGATGGCCTCGCGTCCAATTAGCTAGTTGGTGAGGTAACGGCCCACCAAGGCGACGATTGGTAGCCGGACTGAGAGGTTGAACGGCCACATTGGGACTGAGACACGGCCCAGACTCC
>RS_GCF_007667405.1~NZ_VDRA01000112.1 d__Bacteria;p__Bacillota;c__Bacilli;o__Staphylococcales;f__Staphylococcaceae;g__Staphylococcus;s__Staphylococcus pettenkoferi [location=1..1068] [ssu_len=1068] [contig_len=1108]
TGACGGTACCTAATCAGAAAGCCACGGCTAACTACGTGCCAGCAGCCGCGGTAATACGTAGGTGGCAAGCGTTATCCGGAATTATTGGGCGTAAAGCGCGCGTAGGCGGTTTCTTAAGTCTGATGTGAAAGCCCACGGCTCAACCGTGGAGGGTCATTGGAAACTGGGAAACTTGAGTGCAGGAGAGGAAAGTGGAATTCCATGTGTAGCGGTGAAATGCGCAGAGATATGGAGGAACACCAGTGGCGAA
>RS_GCF_019900785.2~NZ_CP081891.1 d__Bacteria;p__Pseudomonadota;c__Gammaproteobacteria;o__Enterobacterales;f__Enterobacteriaceae;g__Klebsiella;s__Klebsiella pneumoniae [location=458832..460368] [ssu_len=1537] [contig_len=5310315]
ATTGAAGAGTTTGATCATGGCTCAGATTGAACGCTGGCGGCAGGCCTAACACATGCAAGTCGAGCGGTAGCACAGAGAGCTTGCTCTCGGGTGACGAGCGGCGGACGGGTGAGTAATGTCTGGGAAACTGCCTGATGGAGGGGGATAACTACTGGAAACGGTAGCTAATACCGCATAACGTCGCAAGACCAAAGTGGGGGACCTTCGGGCCTCATGCCATCAGATGTGCCCAGATGGGATTAGCTAGTAG
>RS_GCF_000446645.2~NZ_AIBE01000115.1 d__Bacteria;p__Pseudomonadota;c__Gammaproteobacteria;o__Enterobacterales;f__Enterobacteriaceae;g__Escherichia;s__Escherichia coli [location=46..1583] [ssu_len=1538] [contig_len=1601]
TTGAAGAGTTTGATCATGGCTCAGATTGAACGCTGGCGGCAGGCCTAACACATGCAAGTCGAACGGTAACAGGAAGCAGCTTGCTGCTTTGCTGACGAGTGGCGGACGGGTGAGTAATGTCTGGGAAACTGCCTGATGGAGGGGGATAACTACTGGAAACGGTAGCTAATACCGCATAACGTCGCAAGACCAAAGAGGGGGACCTTCGGGCCTCTTGCCATCGGATGTGCCCAGATGGGATTAGCTAGTA
>RS_GCF_001589115.1~NZ_LBCU01000025.1 d__Bacteria;p__Bacillota;c__Bacilli;o__Lactobacillales;f__Streptococcaceae;g__Streptococcus;s__Streptococcus cristatus_K [location=3367..4910] [ssu_len=1544] [contig_len=5233]
AATGAGAGTTTGATCCTGGCTCAGGACGAACGCTGGCGGCGTGCCTAATACATGCAAGTAGAACGCTGAAGGGAGAGCTTGCTCTTCTGGATGAGTTGCGAACGGGTGAGTAACGCGTAGGTAACCTGCCTGGTAGCGGGGGATAACTATTGGAAACGATAGCTAATACCGCATAACATTGACTATTGCATGATAGTCAATTGAAAGGTGCAAATGCACCACTACCAGATGGACCTGCGTTGTATTAGCT
Loading

0 comments on commit df8bd0c

Please sign in to comment.