77import subprocess
88import sys
99import 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
1413def 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
0 commit comments