Skip to content

Commit 450b0b6

Browse files
Merge pull request #6 from gavinmdouglas/Prep_for_conda
updated to be compatible with qiime2 2019-0.1
2 parents f9a130b + 0387578 commit 450b0b6

File tree

4 files changed

+64
-89
lines changed

4 files changed

+64
-89
lines changed

q2_picrust2/_custom_tree_pipeline.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def custom_tree_pipeline(table: biom.Table,
1212
threads: int = 1,
1313
hsp_method: str = "mp",
1414
max_nsti: float = 2.0) -> (biom.Table,
15-
biom.Table,
1615
biom.Table,
1716
biom.Table):
1817

@@ -34,50 +33,59 @@ def custom_tree_pipeline(table: biom.Table,
3433

3534
# Run hidden-state prediction step (on 16S, EC, and KO tables
3635
# separately.
37-
hsp_out_16S = path.join(picrust2_out, "16S_predicted")
38-
system_call_check("hsp.py -i 16S -t " + newick_infile + " -p 1 -n "
39-
"-o " + hsp_out_16S + " -m " + hsp_method)
40-
41-
hsp_out_EC = path.join(picrust2_out, "EC_predicted")
42-
system_call_check("hsp.py -i EC -t " + newick_infile + " -p " +
43-
str(threads) + " -o " + hsp_out_EC + " -m " +
44-
hsp_method)
45-
46-
hsp_out_KO = path.join(picrust2_out, "KO_predicted")
47-
system_call_check("hsp.py -i KO -t " + newick_infile + " -p " +
48-
str(threads) + " -o " + hsp_out_KO + " -m " +
49-
hsp_method)
36+
hsp_out_16S = path.join(picrust2_out, "16S_predicted.tsv")
37+
system_call_check("hsp.py -i 16S " +
38+
" -t " + newick_infile +
39+
" -p 1 " +
40+
" -n " +
41+
"-o " + hsp_out_16S +
42+
" -m " + hsp_method)
43+
44+
hsp_out_EC = path.join(picrust2_out, "EC_predicted.tsv")
45+
system_call_check("hsp.py -i EC " +
46+
" -t " + newick_infile +
47+
" -p " + str(threads) +
48+
" -o " + hsp_out_EC +
49+
" -m " + hsp_method)
50+
51+
hsp_out_KO = path.join(picrust2_out, "KO_predicted.tsv")
52+
system_call_check("hsp.py -i KO " +
53+
" -t " + newick_infile +
54+
" -p " + str(threads) +
55+
" -o " + hsp_out_KO +
56+
" -m " + hsp_method)
5057

5158
# Run metagenome pipeline step.
5259
EC_metagenome_out = path.join(picrust2_out, "EC_metagenome_out")
53-
system_call_check("metagenome_pipeline.py -i " + biom_infile + " -m " +
54-
hsp_out_16S + ".tsv -f " + hsp_out_EC + ".tsv -p " +
55-
str(threads) + " -o " + EC_metagenome_out +
60+
system_call_check("metagenome_pipeline.py -i " + biom_infile +
61+
" -m " + hsp_out_16S +
62+
" -f " + hsp_out_EC +
63+
" -o " + EC_metagenome_out +
5664
" --max_nsti " + str(max_nsti))
5765

5866
KO_metagenome_out = path.join(picrust2_out, "KO_metagenome_out")
59-
system_call_check("metagenome_pipeline.py -i " + biom_infile + " -m " +
60-
hsp_out_16S + ".tsv -f " + hsp_out_KO + ".tsv -p " +
61-
str(threads) + " -o " + KO_metagenome_out +
67+
system_call_check("metagenome_pipeline.py -i " + biom_infile +
68+
" -m " + hsp_out_16S +
69+
" -f " + hsp_out_KO +
70+
" -o " + KO_metagenome_out +
6271
" --max_nsti " + str(max_nsti))
6372

6473
# Run pathway inference step.
6574
pathways_out = path.join(picrust2_out, "pathways_out")
6675

6776
EC_out = path.join(EC_metagenome_out, "pred_metagenome_unstrat.tsv")
6877

69-
system_call_check("run_minpath.py -i " + EC_out + " -o " +
70-
pathways_out + " -p " + str(threads))
78+
system_call_check("pathway_pipeline.py -i " + EC_out +
79+
" -o " + pathways_out +
80+
" -p " + str(threads))
7181

7282
# Read in output unstratified metagenome tables and return as BIOM
7383
# objects.
7484
KO_out = path.join(KO_metagenome_out, "pred_metagenome_unstrat.tsv")
7585
pathabun_out = path.join(pathways_out, "path_abun_unstrat.tsv")
76-
pathcov_out = path.join(pathways_out, "path_cov_unstrat.tsv")
7786

7887
ko_biom = biom.load_table(KO_out)
7988
ec_biom = biom.load_table(EC_out)
8089
pathabun_biom = biom.load_table(pathabun_out)
81-
pathcov_biom = biom.load_table(pathcov_out)
8290

83-
return ko_biom, ec_biom, pathabun_biom, pathcov_biom
91+
return ko_biom, ec_biom, pathabun_biom

q2_picrust2/_full_pipeline.py

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,27 @@
77
import subprocess
88
import sys
99
import picrust2.pipeline
10-
from picrust2.default import (default_fasta, default_tree, default_hmm,
11-
default_tables, default_map, default_regroup_map,
12-
default_pathway_map)
10+
from picrust2.default import (default_ref_dir, default_tables, default_map,
11+
default_regroup_map, default_pathway_map)
1312

1413
def full_pipeline(table: biom.Table,
15-
seq : pd.Series,
14+
seq: pd.Series,
1615
threads: int = 1,
1716
hsp_method: str = "mp",
18-
max_nsti: float = 2.0) -> (biom.Table,
19-
biom.Table,
20-
biom.Table,
21-
biom.Table):
17+
max_nsti: float = 2.0) -> (biom.Table,
18+
biom.Table,
19+
biom.Table):
2220

23-
# Check whether EPA-NG and GAPPA are installed. Exit with explanation if
24-
# not.
25-
missing_prog = []
26-
try:
27-
subprocess.check_call(['epa-ng', '--help'])
28-
except OSError:
29-
missing_prog.append("epa-ng")
30-
31-
try:
32-
subprocess.check_call(['gappa', '--help'])
33-
except OSError:
34-
missing_prog.append("gappa")
35-
36-
if len(missing_prog) > 0:
37-
sys.exit("Missing the following tools from your $PATH variable: " +
38-
" and ".join(missing_prog) + ". Note that this QIIME2 " +
39-
"command is for running the default PICRUSt2 pipeline, " +
40-
"which includes steps for running sequence placement with " +
41-
"EPA-NG. If you do not want to install the missing programs " +
42-
"you can run sequence placement with q2-fragment-insertion " +
43-
"and input this tree to the \"qiime picrust2 " +
44-
"custom_tree_pipeline\" command")
45-
46-
# Need to write out BIOM table and fasta to be used in pipeline.
21+
# Write out BIOM table and FASTA to be used in pipeline.
4722
with TemporaryDirectory() as temp_dir:
48-
49-
# Write out biom table:
23+
24+
# Write out BIOM table:
5025
biom_infile = path.join(temp_dir, "intable.biom")
5126
with biom.util.biom_open(biom_infile, 'w') as out_biom:
52-
table.to_hdf5(h5grp=out_biom, generated_by="PICRUSt2 QIIME2 Plugin")
27+
table.to_hdf5(h5grp=out_biom,
28+
generated_by="PICRUSt2 QIIME2 Plugin")
5329

54-
# Write out Pandas series as fasta:
30+
# Write out Pandas series as FASTA:
5531
seq_outfile = path.join(temp_dir, "seqs.fna")
5632

5733
with open(seq_outfile, "w") as outfile_fh:
@@ -65,9 +41,7 @@ def full_pipeline(table: biom.Table,
6541
input_table=biom_infile,
6642
output_folder=picrust2_out,
6743
threads=threads,
68-
ref_msa=default_fasta,
69-
tree=default_tree,
70-
hmm=default_hmm,
44+
ref_dir=default_ref_dir,
7145
in_traits="EC,KO",
7246
custom_trait_tables=None,
7347
marker_gene_table=default_tables["16S"],
@@ -76,23 +50,22 @@ def full_pipeline(table: biom.Table,
7650
regroup_map=default_regroup_map,
7751
no_regroup=False,
7852
stratified=False,
79-
alignment_tool="hmmalign",
8053
max_nsti=max_nsti,
8154
min_reads=1,
8255
min_samples=1,
8356
hsp_method=hsp_method,
84-
calculate_NSTI=True,
85-
confidence=False,
86-
seed=198,
57+
skip_nsti=False,
8758
no_gap_fill=False,
59+
skip_minpath=False,
60+
coverage=False,
8861
per_sequence_contrib=False,
89-
no_descrip=True,
90-
verbose=False)
62+
verbose=True)
9163

92-
# Convert the returned unstratified tables to biom tables.
93-
ko_biom = biom.load_table(func_outputs["KO"])
94-
ec_biom = biom.load_table(func_outputs["EC"])
64+
# Convert the returned unstratified tables to BIOM tables.
65+
# Note that the 0-index in the func table returned objects corresponds
66+
# to the path to the unstratified table.
67+
ko_biom = biom.load_table(func_outputs["KO"][0])
68+
ec_biom = biom.load_table(func_outputs["EC"][0])
9569
pathabun_biom = biom.load_table(pathway_outputs["unstrat_abun"])
96-
pathcov_biom = biom.load_table(pathway_outputs["unstrat_cov"])
9770

98-
return ko_biom, ec_biom, pathabun_biom, pathcov_biom
71+
return ko_biom, ec_biom, pathabun_biom

q2_picrust2/plugin_setup.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
plugin = Plugin(
1515
name='picrust2',
16-
version="0.0.0",
16+
version="0.0.3",
1717
website='https://github.com/gavinmdouglas/q2-picrust2',
1818
package='q2_picrust2',
1919
description=('This QIIME 2 plugin wraps the default 16S PICRUSt2 pipeline to run '
@@ -32,12 +32,9 @@
3232
'hsp_method': Str % Choices(HSP_METHODS),
3333
'max_nsti': Float % Range(0.0, None)},
3434

35-
outputs=[
36-
('ko_metagenome', FeatureTable[Frequency]),
37-
('ec_metagenome', FeatureTable[Frequency]),
38-
('pathway_abundance', FeatureTable[Frequency]),
39-
('pathway_coverage', FeatureTable[Frequency])
40-
],
35+
outputs=[('ko_metagenome', FeatureTable[Frequency]),
36+
('ec_metagenome', FeatureTable[Frequency]),
37+
('pathway_abundance', FeatureTable[Frequency])],
4138

4239
input_descriptions={
4340
'table': ('The feature table containing sequence abundances per sample.'),
@@ -53,8 +50,7 @@
5350

5451
output_descriptions={'ko_metagenome': 'Predicted metagenome for KEGG orthologs',
5552
'ec_metagenome': 'Predicted metagenome for E.C. numbers',
56-
'pathway_abundance': 'Predicted MetaCyc pathway abundances',
57-
'pathway_coverage': 'Predicted MetaCyc pathway coverages'},
53+
'pathway_abundance': 'Predicted MetaCyc pathway abundances'},
5854

5955
name='Default 16S PICRUSt2 Pipeline',
6056

@@ -77,8 +73,7 @@
7773
outputs=[
7874
('ko_metagenome', FeatureTable[Frequency]),
7975
('ec_metagenome', FeatureTable[Frequency]),
80-
('pathway_abundance', FeatureTable[Frequency]),
81-
('pathway_coverage', FeatureTable[Frequency])
76+
('pathway_abundance', FeatureTable[Frequency])
8277
],
8378

8479
input_descriptions={
@@ -94,8 +89,7 @@
9489

9590
output_descriptions={'ko_metagenome': 'Predicted metagenome for KEGG orthologs',
9691
'ec_metagenome': 'Predicted metagenome for E.C. numbers',
97-
'pathway_abundance': 'Predicted MetaCyc pathway abundances',
98-
'pathway_coverage': 'Predicted MetaCyc pathway coverages'},
92+
'pathway_abundance': 'Predicted MetaCyc pathway abundances'},
9993

10094
name='16S PICRUSt2 pipeline with custom tree',
10195

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="q2-picrust2",
5-
version="0.0.2",
5+
version="0.0.3",
66
packages=find_packages(),
77
package_data={'q2_picrust2': ['citations.bib']},
88
author="Gavin Douglas",

0 commit comments

Comments
 (0)