Next changeset 1:87febc68b45b (2021-05-19) |
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_humann_database_downloader commit 077b8f34e081e6c427acb0fde0fbb97d1b241e0b" |
added:
data_manager/data_manager_humann_download.py data_manager/data_manager_humann_download.xml data_manager_conf.xml test-data/humann_nucleotide_database.loc test-data/humann_protein_database.loc test-data/humann_utility_mapping.loc tool-data/humann_nucleotide_database.loc.sample tool-data/humann_protein_database.loc.sample tool-data/humann_utility_mapping.loc.sample tool_data_table_conf.xml.sample tool_data_table_conf.xml.test |
b |
diff -r 000000000000 -r 60eb2512c5a0 data_manager/data_manager_humann_download.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/data_manager_humann_download.py Wed May 12 08:58:50 2021 +0000 |
[ |
b'@@ -0,0 +1,212 @@\n+#!/usr/bin/env python\n+#\n+# Data manager for reference data for the \'humann\' Galaxy tools\n+import argparse\n+import json\n+import subprocess\n+from datetime import date\n+from pathlib import Path\n+\n+HUMANN_REFERENCE_DATA = {\n+ "chocophlan": {\n+ "full": "Full ChocoPhlAn for HUManN",\n+ "DEMO": "Demo ChocoPhlAn for HUManN"\n+ },\n+ "uniref": {\n+ "uniref50_diamond": "Full UniRef50 for HUManN",\n+ "uniref50_ec_filtered_diamond": "EC-filtered UniRef50 for HUManN",\n+ "uniref90_diamond": "Full UniRef90 for HUManN",\n+ "uniref90_ec_filtered_diamond": "EC-filtered UniRef90 for HUManN",\n+ "DEMO_diamond": "Demo UniRef for HUManN"\n+ },\n+ "utility_mapping": {\n+ "full": {\n+ "map_uniref50_uniref90": "Mapping (full) for UniRef50 from UniRef90",\n+ "map_ko_uniref90": "Mapping (full) for KEGG Orthogroups (KOs) from UniRef90",\n+ "map_eggnog_name": "Mapping (full) between EggNOG (including COGs) ids and names",\n+ "map_uniref90_name": "Mapping (full) between UniRef90 ids and names",\n+ "map_go_uniref90": "Mapping (full) for Gene Ontology (GO) from UniRef90",\n+ "uniref90-tol-lca": "Mapping (full) for LCA for UniRef90",\n+ "uniref50-tol-lca": "Mapping (full) for LCA for UniRef50",\n+ "map_eggnog_uniref50": "Mapping (full) for EggNOG (including COGs) from UniRef50",\n+ "map_pfam_uniref90": "Mapping (full) for Pfam domains from UniRef90",\n+ "map_go_uniref50": "Mapping (full) for Gene Ontology (GO) from UniRef50",\n+ "map_ko_name": "Mapping (full) between KEGG Orthogroups (KOs) ids and names",\n+ "map_level4ec_uniref90": "Mapping (full) for Level-4 enzyme commission (EC) categories from UniRef90",\n+ "map_go_name": "Mapping (full) between Gene Ontology (GO) ids and names",\n+ "map_ko_uniref50": "Mapping (full) for KEGG Orthogroups (KOs) from UniRef50",\n+ "map_level4ec_uniref50": "Mapping (full) for Level-4 enzyme commission (EC) categories from UniRef90",\n+ "map_pfam_uniref50": "Mapping (full) for Pfam domains from UniRef50",\n+ "map_eggnog_uniref90": "Mapping (full) for EggNOG (including COGs) from UniRef90",\n+ "map_uniref50_name": "Mapping (full) between UniRef50 ids and names",\n+ "map_ec_name": "Mapping (full) between Level-4 enzyme commission (EC) categories ids and names",\n+ "map_pfam_name": "Mapping (full) between Pfam domains ids and names"\n+ }\n+ }\n+}\n+\n+\n+# Utility functions for interacting with Galaxy JSON\n+def read_input_json(json_fp):\n+ """Read the JSON supplied from the data manager tool\n+ Returns a tuple (param_dict,extra_files_path)\n+ \'param_dict\' is an arbitrary dictionary of parameters\n+ input into the tool; \'extra_files_path\' is the path\n+ to a directory where output files must be put for the\n+ receiving data manager to pick them up.\n+ NB the directory pointed to by \'extra_files_path\'\n+ doesn\'t exist initially, it is the job of the script\n+ to create it if necessary.\n+ """\n+ with open(json_fp) as fh:\n+ params = json.load(fh)\n+ return (params[\'param_dict\'],\n+ Path(params[\'output_data\'][0][\'extra_files_path\']))\n+\n+\n+# Utility functions for creating data table dictionaries\n+#\n+# Example usage:\n+# >>> d = create_data_tables_dict()\n+# >>> add_data_table(d,\'my_data\')\n+# >>> add_data_table_entry(dict(dbkey=\'hg19\',value=\'human\'))\n+# >>> add_data_table_entry(dict(dbkey=\'mm9\',value=\'mouse\'))\n+# >>> print(json.dumps(d))\n+def create_data_tables_dict():\n+ """Return a dictionary for storing data table information\n+\n+ Returns a dictionary that can be used with \'add_data_table\'\n+ and \'add_data_table_entry\' to store information about a\n+ data table. It can be converted to JSON to be sent back to\n+ the data manager.\n+\n+ """\n+ d = {\n+ \'data_tables\': {}\n+ }\n+ return d\n+\n+\n'..b' """Add an entry to a data table\n+\n+ Appends an entry to the data table \'table\'. \'entry\'\n+ should be a dictionary where the keys are the names of\n+ columns in the data table.\n+\n+ Raises an exception if the named data table doesn\'t\n+ exist.\n+\n+ """\n+ try:\n+ d[\'data_tables\'][table].append(entry)\n+ except KeyError:\n+ raise Exception("add_data_table_entry: no table \'%s\'" % table)\n+\n+\n+def download_humann_db(data_tables, table_name, database, build, version, target_dp):\n+ """Download HUMAnN database\n+\n+ Creates references to the specified file(s) on the Galaxy\n+ server in the appropriate data table (determined from the\n+ file extension).\n+\n+ The \'data_tables\' dictionary should have been created using\n+ the \'create_data_tables_dict\' and \'add_data_table\' functions.\n+\n+ Arguments:\n+ data_tables: a dictionary containing the data table info\n+ table_name: name of the table\n+ database: database to download (chocophlan or uniref)\n+ build: build of the database to download\n+ version: tool version\n+ target_dp: directory to put copy or link to the data file\n+ """\n+ db_target_dp = target_dp / Path(database)\n+ db_dp = db_target_dp / Path(database)\n+ build_target_dp = db_target_dp / Path(build)\n+ # launch tool to get db\n+ cmd = "humann_databases --download %s %s %s --update-config no" % (\n+ database,\n+ build,\n+ db_target_dp)\n+ subprocess.check_call(cmd, shell=True)\n+ # move db\n+ db_dp.rename(build_target_dp)\n+ # add details to data table\n+ if database != "utility_mapping":\n+ add_data_table_entry(\n+ data_tables,\n+ table_name,\n+ dict(\n+ value="%s-%s-%s-%s" % (database, build, version, date.today().strftime("%d%m%Y")),\n+ name=HUMANN_REFERENCE_DATA[database][build],\n+ dbkey=version,\n+ path=str(build_target_dp)))\n+ elif args.database == "utility_mapping":\n+ for x in build_target_dp.iterdir():\n+ name = str(x.stem).split(\'.\')[0]\n+ add_data_table_entry(\n+ data_tables,\n+ table_name,\n+ dict(\n+ value="%s-%s-%s-%s-%s" % (database, build, name, version, date.today().strftime("%d%m%Y")),\n+ name=HUMANN_REFERENCE_DATA["utility_mapping"][build][name],\n+ dbkey=version,\n+ path=str(x)))\n+\n+\n+if __name__ == "__main__":\n+ print("Starting...")\n+\n+ # Read command line\n+ parser = argparse.ArgumentParser(description=\'Download HUMAnN database\')\n+ parser.add_argument(\'--database\', help="Database name")\n+ parser.add_argument(\'--build\', help="Build of the database")\n+ parser.add_argument(\'--version\', help="HUMAnN version")\n+ parser.add_argument(\'--json\', help="Path to JSON file")\n+ args = parser.parse_args()\n+ print("args : %s" % args)\n+\n+ # Read the input JSON\n+ json_fp = Path(args.json)\n+ params, target_dp = read_input_json(json_fp)\n+\n+ # Make the target directory\n+ print("Making %s" % target_dp)\n+ target_dp.mkdir(parents=True, exist_ok=True)\n+\n+ # Set up data tables dictionary\n+ data_tables = create_data_tables_dict()\n+ if args.database == "chocophlan":\n+ table_name = \'humann_nucleotide_database\'\n+ elif args.database == "uniref":\n+ table_name = \'humann_protein_database\'\n+ elif args.database == "utility_mapping":\n+ table_name = \'humann_utility_mapping\'\n+ add_data_table(data_tables, table_name)\n+\n+ # Fetch data from specified data sources\n+ print("Download and build database")\n+ download_humann_db(\n+ data_tables,\n+ table_name,\n+ args.database,\n+ args.build,\n+ args.version,\n+ target_dp)\n+\n+ # Write output JSON\n+ print("Outputting JSON")\n+ with open(json_fp, \'w\') as fh:\n+ json.dump(data_tables, fh, sort_keys=True)\n+ print("Done.")\n' |
b |
diff -r 000000000000 -r 60eb2512c5a0 data_manager/data_manager_humann_download.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/data_manager_humann_download.xml Wed May 12 08:58:50 2021 +0000 |
[ |
@@ -0,0 +1,120 @@ +<tool id="data_manager_humann_download" name="HUMAnN download" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" tool_type="manage_data" profile="20.01"> + <description>Download HUMAnN database</description> + <macros> + <token name="@TOOL_VERSION@">3.0.0</token> + <token name="@VERSION_SUFFIX@">0</token> + </macros> + <requirements> + <requirement type="package" version="@TOOL_VERSION@">humann</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ +python '$__tool_directory__/data_manager_humann_download.py' + --database '$db.database' + --build '$db.build' + --json '$out_file' + --version '@TOOL_VERSION@' + ]]></command> + <inputs> + <conditional name="db"> + <param name="database" type="select" label="Type of database to download"> + <option value="chocophlan" selected="true">Nucleotide database</option> + <option value="uniref">Protein database</option> + <option value="utility_mapping">Mapping files</option> + </param> + <when value="chocophlan"> + <param name="build" type="select" label="Build for nucleotide database"> + <option value="full" selected="true">Full</option> + <option value="DEMO">Demo</option> + </param> + </when> + <when value="uniref"> + <param name="build" type="select" label="Build for protein database"> + <option value="uniref50_diamond">Full UniRef50</option> + <option value="uniref50_ec_filtered_diamond">EC-filtered UniRef50</option> + <option value="uniref90_diamond" selected="true">Full UniRef90</option> + <option value="uniref90_ec_filtered_diamond">EC-filtered UniRef90</option> + <option value="DEMO_diamond">Demo</option> + </param> + </when> + <when value="utility_mapping"> + <param name="build" type="select" label="Build for mapping files"> + <option value="full" selected="true">Full</option> + </param> + </when> + </conditional> + </inputs> + <outputs> + <data name="out_file" format="data_manager_json" label="${tool.name}" /> + </outputs> + <tests> + <test expect_num_outputs="1"> + <conditional name="db"> + <param name="database" value="chocophlan"/> + <param name="build" value="DEMO"/> + </conditional> + <output name="out_file"> + <assert_contents> + <has_text text="humann_nucleotide_database"/> + <has_text text="Demo ChocoPhlAn for HUManN"/> + <has_text text="chocophlan/DEMO"/> + <has_text text="chocophlan-DEMO-"/> + </assert_contents> + </output> + </test> + <test expect_num_outputs="1"> + <conditional name="db"> + <param name="database" value="uniref"/> + <param name="build" value="DEMO_diamond"/> + </conditional> + <output name="out_file"> + <assert_contents> + <has_text text="DEMO_diamond"/> + <has_text text="Demo UniRef for HUManN"/> + <has_text text="uniref/DEMO_diamond"/> + <has_text text="uniref-DEMO_diamond-"/> + </assert_contents> + </output> + </test> + <test expect_num_outputs="1"> + <conditional name="db"> + <param name="database" value="utility_mapping"/> + <param name="build" value="full"/> + </conditional> + <output name="out_file"> + <assert_contents> + <has_text text="utility_mapping"/> + <has_text text="Mapping (full)"/> + <has_text text="utility_mapping/full"/> + <has_text text="map_uniref50_uniref90"/> + <has_text text="map_ko_uniref90"/> + <has_text text="map_eggnog_name"/> + <has_text text="map_uniref90_name"/> + <has_text text="map_go_uniref90"/> + <has_text text="uniref90-tol-lca"/> + <has_text text="uniref50-tol-lca"/> + <has_text text="map_eggnog_uniref50"/> + <has_text text="map_pfam_uniref90"/> + <has_text text="map_go_uniref50"/> + <has_text text="map_ko_name"/> + <has_text text="map_level4ec_uniref90"/> + <has_text text="map_go_name"/> + <has_text text="map_ko_uniref50"/> + <has_text text="map_level4ec_uniref50"/> + <has_text text="map_pfam_uniref50"/> + <has_text text="map_eggnog_uniref90"/> + <has_text text="map_uniref50_name"/> + <has_text text="map_ec_name"/> + <has_text text="map_pfam_name"/> + </assert_contents> + </output> + </test> + </tests> + <help> +This tool downloads the HUMAnN databases. + +Read more about the tool at http://huttenhower.sph.harvard.edu/humann . + </help> + <citations> + <citation type="doi">10.1371/journal.pcbi.1003153</citation> + </citations> +</tool> |
b |
diff -r 000000000000 -r 60eb2512c5a0 data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,47 @@ +<data_managers> + <data_manager tool_file="data_manager/data_manager_humann_download.xml" id="data_manager_humann_download" > + <data_table name="humann_nucleotide_database"> <!-- Defines a Data Table to be modified. --> + <output> <!-- Handle the output of the Data Manager Tool --> + <column name="value" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="name" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="dbkey" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="path" output_ref="out_file" > + <move type="directory"> + <source>${path}</source> + <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">humann/data/nucleotide_database/${value}</target> + </move> + <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/humann/data/nucleotide_database/${value}</value_translation> + </column> + </output> + </data_table> + <data_table name="humann_protein_database"> <!-- Defines a Data Table to be modified. --> + <output> <!-- Handle the output of the Data Manager Tool --> + <column name="value" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="name" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="dbkey" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="path" output_ref="out_file" > + <move type="directory"> + <source>${path}</source> + <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">humann/data/protein_database/${value}</target> + </move> + <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/humann/data/protein_database/${value}</value_translation> + </column> + </output> + </data_table> + <data_table name="humann_utility_mapping"> <!-- Defines a Data Table to be modified. --> + <output> <!-- Handle the output of the Data Manager Tool --> + <column name="value" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="name" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="dbkey" /> <!-- columns that are going to be specified by the Data Manager Tool --> + <column name="path" output_ref="out_file" > + <move type="file" relativize_symlinks="False"> + <source>${path}</source> + <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">humann/data/utility_mapping/${value}</target> + </move> + <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/humann/data/utility_mapping/${value}</value_translation> + </column> + </output> + </data_table> + </data_manager> +</data_managers> + |
b |
diff -r 000000000000 -r 60eb2512c5a0 test-data/humann_nucleotide_database.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/humann_nucleotide_database.loc Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,4 @@ +#This is a sample file distributed with Galaxy that enables tools +#to use a directory of metagenomics files. +#file has this format (white space characters are TAB characters) +#db-build-version-date db-name build /path/to/data \ No newline at end of file |
b |
diff -r 000000000000 -r 60eb2512c5a0 test-data/humann_protein_database.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/humann_protein_database.loc Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,4 @@ +#This is a sample file distributed with Galaxy that enables tools +#to use a directory of metagenomics files. +#file has this format (white space characters are TAB characters) +#db-build-version-date db-name build /path/to/data \ No newline at end of file |
b |
diff -r 000000000000 -r 60eb2512c5a0 test-data/humann_utility_mapping.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/humann_utility_mapping.loc Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,4 @@ +#This is a sample file distributed with Galaxy that enables tools +#to use a directory of metagenomics files. +#file has this format (white space characters are TAB characters) +#db-build-version-date db-name build /path/to/data \ No newline at end of file |
b |
diff -r 000000000000 -r 60eb2512c5a0 tool-data/humann_nucleotide_database.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/humann_nucleotide_database.loc.sample Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,4 @@ +#This is a sample file distributed with Galaxy that enables tools +#to use a directory of metagenomics files. +#file has this format (white space characters are TAB characters) +#db-build-version-date db-name build /path/to/data \ No newline at end of file |
b |
diff -r 000000000000 -r 60eb2512c5a0 tool-data/humann_protein_database.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/humann_protein_database.loc.sample Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,4 @@ +#This is a sample file distributed with Galaxy that enables tools +#to use a directory of metagenomics files. +#file has this format (white space characters are TAB characters) +#db-build-version-date db-name build /path/to/data \ No newline at end of file |
b |
diff -r 000000000000 -r 60eb2512c5a0 tool-data/humann_utility_mapping.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/humann_utility_mapping.loc.sample Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,4 @@ +#This is a sample file distributed with Galaxy that enables tools +#to use a directory of metagenomics files. +#file has this format (white space characters are TAB characters) +#db-build-version-date db-name build /path/to/data \ No newline at end of file |
b |
diff -r 000000000000 -r 60eb2512c5a0 tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,14 @@ +<tables> + <table name="humann_nucleotide_database" comment_char="#"> + <columns>value, name, dbkey, path</columns> + <file path="tool-data/humann_nucleotide_database.loc" /> + </table> + <table name="humann_protein_database" comment_char="#"> + <columns>value, name, dbkey, path</columns> + <file path="tool-data/humann_protein_database.loc" /> + </table> + <table name="humann_utility_mapping" comment_char="#"> + <columns>value, name, dbkey, path</columns> + <file path="tool-data/humann_utility_mapping.loc" /> + </table> +</tables> |
b |
diff -r 000000000000 -r 60eb2512c5a0 tool_data_table_conf.xml.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.test Wed May 12 08:58:50 2021 +0000 |
b |
@@ -0,0 +1,14 @@ +<tables> + <table name="humann_nucleotide_database" comment_char="#"> + <columns>value, name, dbkey, path</columns> + <file path="${__HERE__}/test-data/humann_nucleotide_database.loc" /> + </table> + <table name="humann_protein_database" comment_char="#"> + <columns>value, name, dbkey, path</columns> + <file path="${__HERE__}/test-data/humann_protein_database.loc" /> + </table> + <table name="humann_utility_mapping" comment_char="#"> + <columns>value, name, dbkey, path</columns> + <file path="${__HERE__}/test-data/humann_utility_mapping.loc" /> + </table> +</tables> \ No newline at end of file |