# HG changeset patch # User iuc # Date 1670527609 0 # Node ID 629464b96c2e47bbd0230c362dc560c21502911c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_gtdbtk_database_installer commit 69da0d34ea6e72c0427ec2d3e882c86cbb90833f diff -r 000000000000 -r 629464b96c2e data_manager/gtdbtk_database_installer.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/gtdbtk_database_installer.py Thu Dec 08 19:26:49 2022 +0000 @@ -0,0 +1,84 @@ +#!/usr/bin/env python + +import argparse +import json +import os +import shutil +import sys +import tarfile +from urllib.parse import urlparse +from urllib.request import Request +from urllib.request import urlopen + + +def url_download(url, target_directory): + url_parts = urlparse(url) + tarball = os.path.abspath(os.path.join(target_directory, os.path.basename(url_parts.path))) + src = None + dst = None + try: + req = Request(url) + src = urlopen(req) + with open(tarball, 'wb') as dst: + while True: + chunk = src.read(2**10) + if chunk: + dst.write(chunk) + else: + break + except Exception as e: + sys.exit(str(e)) + finally: + if src is not None: + src.close() + if tarfile.is_tarfile(tarball): + fh = tarfile.open(tarball, 'r:*') + else: + return tarball + fh.extractall(target_directory) + fh.close() + os.remove(tarball) + # The tarball extraction will create a directory named + # something like release202 in the target_directory, so + # we need to move the items in that directory to the + # target directory. + subdir = next(os.walk(target_directory))[1][0] + subdir_path = os.path.join(target_directory, subdir) + items = os.listdir(subdir_path) + for item in items: + item_path = os.path.join(subdir_path, item) + shutil.move(item_path, target_directory) + os.rmdir(subdir_path) + return target_directory + + +def download(database_id, database_name, url, out_file): + + with open(out_file) as fh: + params = json.load(fh) + + target_directory = params['output_data'][0]['extra_files_path'] + os.makedirs(target_directory) + file_path = url_download(url, target_directory) + + data_manager_json = {"data_tables": {}} + data_manager_entry = {} + data_manager_entry['value'] = database_id + data_manager_entry['name'] = database_name + data_manager_entry['path'] = file_path + data_manager_json["data_tables"]["gtdbtk_database"] = data_manager_entry + + with open(out_file, 'w') as fh: + json.dump(data_manager_json, fh, sort_keys=True) + + +parser = argparse.ArgumentParser() + +parser.add_argument('--database_name', dest='database_name', help='GTDB-Tk database display name') +parser.add_argument('--database_id', dest='database_id', help='Unique GTDB-Tk database id') +parser.add_argument('--url', dest='url', help='URL to download GTDB-Tk databse version') +parser.add_argument('--out_file', dest='out_file', help='JSON output file') + +args = parser.parse_args() + +download(args.database_id, args.database_name, args.url, args.out_file) diff -r 000000000000 -r 629464b96c2e data_manager/gtdbtk_database_installer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/gtdbtk_database_installer.xml Thu Dec 08 19:26:49 2022 +0000 @@ -0,0 +1,48 @@ + + + + 202 + 0 + 20.09 + + + python + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + doi.org/10.1038/s41587-020-0501-8 + dx.doi.org/10.1038/nbt.4229 + + diff -r 000000000000 -r 629464b96c2e data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Thu Dec 08 19:26:49 2022 +0000 @@ -0,0 +1,17 @@ + + + + + + + + + gtdbtk_database/${value} + + ${GALAXY_DATA_MANAGER_DATA_PATH}/gtdbtk_database/${value} + abspath + + + + + diff -r 000000000000 -r 629464b96c2e test-data/gtdbtk_database.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/gtdbtk_database.loc Thu Dec 08 19:26:49 2022 +0000 @@ -0,0 +1,26 @@ +# This is a sample file distributed with Galaxy that enables tools +# to use a directory of GTDB-Tk databases. The gtdbtk_databases.loc +# file has this format (longer white space characters are TAB characters): +# +# +# +# So, for example, if you have the gtdbtk 202 stored in +# /depot/data2/galaxy/gtdbtk/202/, +# then the gtdbtk_databases.loc entry would look like this: +# +# release202 gtdbtk database release 202 /depot/data2/galaxy/gtdbtk/release202 +# +# and your /depot/data2/galaxy/gtdbtk/release202 directory +# would contain GTDB-Tk database files for release 202, sommething like this: +# +#drwxr-sr-x 3 gvk G-824019 4096 Apr 20 2021 fastani/ +#-rw-r--r-- 1 gvk G-824019 4810764 Apr 22 2021 manifest.tsv +#drwxr-sr-x 4 gvk G-824019 4096 Apr 21 2021 markers/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 masks/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 metadata/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 21 2021 mrca_red/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 msa/ +#drwxr-sr-x 4 gvk G-824019 4096 Apr 21 2021 pplacer/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 radii/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 taxonomy/ +release202 GTDB-Tk database release 202 /depot/data2/galaxy/tool-data/gtdbtk_database/release202 diff -r 000000000000 -r 629464b96c2e tool-data/gtdbtk_database.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/gtdbtk_database.loc.sample Thu Dec 08 19:26:49 2022 +0000 @@ -0,0 +1,25 @@ +# This is a sample file distributed with Galaxy that enables tools +# to use a directory of GTDB-Tk databases. The gtdbtk_databases.loc +# file has this format (longer white space characters are TAB characters): +# +# +# +# So, for example, if you have the gtdbtk 202 stored in +# /depot/data2/galaxy/gtdbtk/202/, +# then the gtdbtk_databases.loc entry would look like this: +# +# release202 gtdbtk database release 202 /depot/data2/galaxy/gtdbtk/release202 +# +# and your /depot/data2/galaxy/gtdbtk/release202 directory +# would contain GTDB-Tk database files for release 202, sommething like this: +# +#drwxr-sr-x 3 gvk G-824019 4096 Apr 20 2021 fastani/ +#-rw-r--r-- 1 gvk G-824019 4810764 Apr 22 2021 manifest.tsv +#drwxr-sr-x 4 gvk G-824019 4096 Apr 21 2021 markers/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 masks/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 metadata/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 21 2021 mrca_red/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 msa/ +#drwxr-sr-x 4 gvk G-824019 4096 Apr 21 2021 pplacer/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 radii/ +#drwxr-sr-x 2 gvk G-824019 4096 Apr 20 2021 taxonomy/ diff -r 000000000000 -r 629464b96c2e tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Thu Dec 08 19:26:49 2022 +0000 @@ -0,0 +1,7 @@ + + + + value, name, path + +
+
diff -r 000000000000 -r 629464b96c2e tool_data_table_conf.xml.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.test Thu Dec 08 19:26:49 2022 +0000 @@ -0,0 +1,7 @@ + + + + value, name, path + +
+