Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4e05473
testing picrust functionality
kbpi314 Jun 10, 2025
a61277e
removed duplicate extract tsv
kbpi314 Jun 11, 2025
16aee6c
added comma and dependency
kbpi314 Jun 11, 2025
b03a29d
simplified output
kbpi314 Jun 11, 2025
9283bdf
simplified output
kbpi314 Jun 11, 2025
5a2b13d
fixed quotes around pc2
kbpi314 Jun 11, 2025
76a99af
fixed syntax bash
kbpi314 Jun 11, 2025
f35756f
fixed var syntax
kbpi314 Jun 11, 2025
e87160d
fixed var syntax
kbpi314 Jun 11, 2025
06f04ae
fixed var syntax
kbpi314 Jun 11, 2025
4bd4912
added whitespace
kbpi314 Jun 11, 2025
9d05743
added directory()
kbpi314 Jun 11, 2025
2f5cd1d
added directory()
kbpi314 Jun 11, 2025
425de4c
adding tsv to biom to qza rules
kbpi314 Jun 11, 2025
50ec200
commented out circular rules
kbpi314 Jun 11, 2025
505811e
added comment hashtag
kbpi314 Jun 13, 2025
b01d635
added export line
kbpi314 Jun 13, 2025
d0b85cb
fixed import and spacing
kbpi314 Jun 13, 2025
3c818b2
pytest version
adamcantor22 Jun 13, 2025
476180c
added directory for pc2
kbpi314 Jun 13, 2025
86b65d9
remove ancombc runs from core pipeline
adamcantor22 Jun 13, 2025
419c076
added stratified option
kbpi314 Jun 16, 2025
dd81041
Merge branch 'Enhancement-KB' of https://github.com/clemente-lab/mmed…
kbpi314 Jun 16, 2025
d19dec3
Merge branch 'Enhancement-ImprovedSnakemakeFunctionality' into Enhanc…
adamcantor22 Feb 9, 2026
27cce6a
PR modifications
adamcantor22 Feb 9, 2026
b8006d7
add picrust pipeline to workflows
adamcantor22 Feb 9, 2026
4cea632
typo
adamcantor22 Feb 9, 2026
f9ca99d
add basic test for new workflow
adamcantor22 Feb 9, 2026
722a690
remove curly braces from test version
adamcantor22 Feb 9, 2026
6349f7d
add mapping file for picrust test
adamcantor22 Feb 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mmeds/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@
"plot_max_rows",
"match_string"
]
},
"picrust2": {
"parameters": [
"tables" # this is going to always be 'asv_table.qza' and 'rep_seqs_table.qza' TODO: default parameters?
],
"optional_parameters": []
}
}

Expand Down
35 changes: 35 additions & 0 deletions mmeds/snakemake/rules/file_manipulation.smk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,41 @@ rule extract_feature_table_tsv:
"extract_feature_table.sh "
"{input} "
"{output} "
"tsv "
"tables/tmp_unzip_{wildcards.table}"

rule extract_feature_table_biom:
""" Remove feature table biom file from qza archive """
input:
"tables/{table}.qza"
output:
"tables/{table}.biom"
wildcard_constraints:
table = "[^/]+"
conda:
"mmeds_test"
shell:
"extract_feature_table.sh "
"{input} "
"{output} "
"biom "
"tables/tmp_unzip_{wildcards.table}"

rule extract_feature_table_fasta:
""" Remove underlying fasta data from qza archive """
input:
"tables/{table}.qza"
output:
"tables/{table}.fasta"
wildcard_constraints:
table = "[^/]+"
conda:
"mmeds_test"
shell:
"extract_feature_table.sh "
"{input} "
"{output} "
"fasta "
"tables/tmp_unzip_{wildcards.table}"

rule extract_feature_table_tsv_class:
Expand Down
15 changes: 15 additions & 0 deletions mmeds/snakemake/rules/functional_annotation.smk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rule picrust2_core:
""" Generate picrust2 tables for input feature table """
input:
rep_seqs = "tables/rep_seqs_table.fasta",
biom_feature_table = "tables/asv_table.biom"
output:
directory("picrust2_out")
conda:
"picrust2"
shell:
"picrust2_pipeline.py "
"-s {input.rep_seqs} "
"-i {input.biom_feature_table} "
"-o {output} "
"--stratified"
11 changes: 11 additions & 0 deletions mmeds/snakemake/workflows/picrust2.Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
configfile: "config_file.yaml"
report: "report.rst"

include: "{snakemake_dir}/common.smk"
include: "{snakemake_dir}/file_manipulation.smk"
include: "{snakemake_dir}/table_filtering.smk"
include: "{snakemake_dir}/functional_annotation.smk"

rule results:
input:
directory("picrust2_out")
8 changes: 6 additions & 2 deletions mmeds/tests/unit/test_snakemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from mmeds.util import setup_environment
from mmeds.logging import Logger


class SnakemakeTests(TestCase):
""" Test running snakemake analyses """
@classmethod
Expand Down Expand Up @@ -36,13 +37,11 @@ def run_snakemake(self, path):
run(f"rm -f {dag}; rm -f {rulegraph}; rm -f {snakefile}", shell=True)
return 0


def test_a_core_pipeline_taxonomic(self):
""" Test snakemake standard pipeline analysis """
result = self.run_snakemake(Path(fig.TEST_SNAKEMAKE_DIR) / "core_pipeline_taxonomic")
self.assertEquals(result, 0)


def test_b_lefse(self):
""" Test snakemake lefse analysis """
result = self.run_snakemake(Path(fig.TEST_SNAKEMAKE_DIR) / "lefse")
Expand All @@ -53,3 +52,8 @@ def test_c_lefse_failure(self):
""" Test analysis with undefined snakemake method """
result = self.run_snakemake(Path(fig.TEST_SNAKEMAKE_DIR) / "lefse_failure")
self.assertEquals(result, 0)

def test_d_picrust2(self):
""" Test snakemake picrust2 analysis """
result = self.run_snakemake(Path(fig.TEST_SNAKEMAKE_DIR) / "picrust2")
self.assertEquals(result, 0)
21 changes: 17 additions & 4 deletions scripts/extract_feature_table.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@

in_file=$1
out_file=$2
tmp_dir_name="${3:-tmp_unzip}"
file_type="${3:-tsv}" # tsv, biom, or fasta
tmp_dir_name="${4:-tmp_unzip}"
unzip -joq $in_file -d $tmp_dir_name
biom convert --to-tsv -i $tmp_dir_name/feature-table.biom -o $out_file
sed -i '1d;2s/^#//' $out_file
rm -rf $tmp_dir_name

if [[ "$file_type" == "tsv" ]]; then
biom convert --to-tsv -i $tmp_dir_name/feature-table.biom -o $out_file
sed -i '1d;2s/^#//' $out_file
rm -rf $tmp_dir_name
elif [[ "$file_type" == "biom" ]]; then
cp $tmp_dir_name/feature-table.biom $out_file
rm -rf $tmp_dir_name
elif [[ "$file_type" == "fasta" ]]; then
cp $tmp_dir_name/dna-sequences.fasta $out_file
rm -rf $tmp_dir_name
else
echo "Invalid file_type argument"
fi

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def run(self):
'pygments==2.8.1',
'pymysql==1.0.2',
'pytest-cov==2.11.1',
'pytest==8.3.5',
'pytest-pudb==0.7.0',
'pytest==8.3.5',
'pytidylib==0.3.2',
Expand Down
11 changes: 11 additions & 0 deletions test_files/test_snakemake/picrust2/picrust2.Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
configfile: "test_picrust2_config.yaml"
report: "report.rst"

include: "snakemake_dir/common.smk"
include: "snakemake_dir/file_manipulation.smk"
include: "snakemake_dir/table_filtering.smk"
include: "snakemake_dir/functional_annotation.smk"

rule results:
input:
directory("picrust2_out")
Binary file not shown.
2,734 changes: 2,734 additions & 0 deletions test_files/test_snakemake/picrust2/tables/qiime_mapping_file.tsv

Large diffs are not rendered by default.

Binary file not shown.
4 changes: 4 additions & 0 deletions test_files/test_snakemake/picrust2/test_picrust2_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tables:
- asv_table
- rep_seqs_table

Loading