From f3e25713bb24ff8d2792f53153052722f729e2e5 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Sat, 7 Mar 2015 11:45:37 -0700 Subject: [PATCH] TST: the two tests that can be run pass now. The OTU table had an undefined pH for one of the samples, which is invalid for the hdf5 formatter, issue biocore/biom-format#609 --- .../otu_table_for_custom_trait_table.biom | 2 +- scripts/predict_metagenomes.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/picrust_test_data/predict_metagenomes/otu_table_for_custom_trait_table.biom b/picrust_test_data/predict_metagenomes/otu_table_for_custom_trait_table.biom index 5ff0521..edc07f1 100644 --- a/picrust_test_data/predict_metagenomes/otu_table_for_custom_trait_table.biom +++ b/picrust_test_data/predict_metagenomes/otu_table_for_custom_trait_table.biom @@ -1 +1 @@ -{"rows": [{"id": "A", "metadata": null}, {"id": "B", "metadata": null}, {"id": "C", "metadata": null}], "format": "Biological Observation Matrix v0.9", "data": [[0, 0, 1.0], [0, 1, 2.0], [0, 2, 3.0], [0, 3, 5.0], [1, 0, 5.0], [1, 1, 1.0], [1, 3, 2.0], [2, 2, 1.0], [2, 3, 4.0]], "columns": [{"id": "Sample1", "metadata": {"pH":7.0}}, {"id": "Sample2", "metadata": {"pH":8.0}}, {"id": "Sample3", "metadata": {"pH":7.0}}, {"id": "Sample4", "metadata": null}],"generated_by": "QIIME 1.4.0-dev, svn revision 2753", "matrix_type": "sparse", "shape": [3, 4], "format_url": "http://www.qiime.org/svn_documentation/documentation/biom_format.html", "date": "2012-02-22T20:50:05.024661", "type": "OTU table", "id": null, "matrix_element_type": "float"} +{"id": "None","format": "Biological Observation Matrix 1.0.0","format_url": "http://biom-format.org","matrix_type": "sparse","generated_by": "picrust","date": "2015-03-07T11:40:42.151151","type": "OTU table","matrix_element_type": "float","shape": [3, 4],"data": [[0,0,1.0],[0,1,2.0],[0,2,3.0],[0,3,5.0],[1,0,5.0],[1,1,1.0],[1,3,2.0],[2,2,1.0],[2,3,4.0]],"rows": [{"id": "A", "metadata": null},{"id": "B", "metadata": null},{"id": "C", "metadata": null}],"columns": [{"id": "Sample1", "metadata": {"pH": 7.0}},{"id": "Sample2", "metadata": {"pH": 8.0}},{"id": "Sample3", "metadata": {"pH": 7.0}},{"id": "Sample4", "metadata": {"pH": NaN}}]} \ No newline at end of file diff --git a/scripts/predict_metagenomes.py b/scripts/predict_metagenomes.py index 2b11054..21b6781 100755 --- a/scripts/predict_metagenomes.py +++ b/scripts/predict_metagenomes.py @@ -26,15 +26,16 @@ script_info = {} script_info['brief_description'] = "This script produces the actual metagenome functional predictions for a given OTU table." script_info['script_description'] = "" -script_info['script_usage'] = [("","Predict KO abundances for a given OTU table picked against the newest version of GreenGenes.",\ - "%prog -i normalized_otus.biom -o predicted_metagenomes.biom"), +script_info['script_usage'] = [ + ("","Predict KO abundances for a given OTU table picked against the newest version of GreenGenes.", "%prog -i normalized_otus.biom -o predicted_metagenomes.biom"), ("","Change output format to plain tab-delimited:","%prog -f -i normalized_otus.biom -o predicted_metagenomes.txt"), ("","Predict COG abundances for a given OTU table.","%prog -i normalized_otus.biom -t cog -o cog_predicted_metagenomes.biom"),\ ("","Predict RFAM abundances for a given OTU table.","%prog -i normalized_otus.biom -t rfam -o rfam_predicted_metagenomes.biom"),\ ("","Output confidence intervals for each prediction.","%prog -i normalized_otus.biom -o predicted_metagenomes.biom --with_confidence"),\ ("","Predict metagenomes using a custom trait table in tab-delimited format.","%prog -i otu_table_for_custom_trait_table.biom -c custom_trait_table.tab -o output_metagenome_from_custom_trait_table.biom"),\ ("","Predict metagenomes,variances,and 95% confidence intervals for each gene category using a custom trait table in tab-delimited format.","%prog -i otu_table_for_custom_trait_table.biom --input_variance_table custom_trait_table_variances.tab -c custom_trait_table.tab -o output_metagenome_from_custom_trait_table.biom --with_confidence"),\ - ("","Change the version of GG used to pick OTUs","%prog -i normalized_otus.biom -g 18may2012 -o predicted_metagenomes.biom")] + ("","Change the version of GG used to pick OTUs","%prog -i normalized_otus.biom -g 18may2012 -o predicted_metagenomes.biom") + ] script_info['output_description']= "Output is a table of function counts (e.g. KEGG KOs) by sample ids." script_info['required_options'] = [ make_option('-i','--input_otu_table',type='existing_filepath',help='the input otu table in biom format'), @@ -150,7 +151,7 @@ def main(): print "Loading OTU table: ",opts.input_otu_table otu_table = load_table(opts.input_otu_table) - ids_to_load = otu_table.ids(axis='observation') + ids_to_load = otu_table.ids(axis='observation').tolist() if opts.verbose: print "Done loading OTU table containing %i samples and %i OTUs." \