# HG changeset patch # User greg # Date 1670857334 0 # Node ID 9972e1e07347416ea3d40e62369d4ab71df390ec Uploaded diff -r 000000000000 -r 9972e1e07347 .shed.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.shed.yml Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,13 @@ +name: data_manager_pima_pv_downloader +owner: greg +description: Data manager to download the PIMA plasmids_and_vectors.fasta files for use by the PIMA pipeline tools. +homepage_url: https://github.com/appliedbinf/pima_md +long_description: | + PIMA (Plasmid, Integrations, Mutations, and Antibiotic) resistance annotation pipeline is a high-throughput + sequence analysis pipeline. PIMA is an end-to-end solution encompassing all the steps required to transform + raw ONT output into high-quality annotated assemblies. PIMA supports providing optional Illumina paired end + reads for polishing and error correcting assemblies. +remote_repository_url: https://github.com/gregvonkuster/galaxy_tools/tree/master/tools/data_managers/data_manager_pima_pv_downloader +type: unrestricted +categories: +- Data Managers diff -r 000000000000 -r 9972e1e07347 data_manager/pima_pv_downloader.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/pima_pv_downloader.py Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,60 @@ +import argparse +import datetime +import json +import os +import sys +from urllib.request import Request, urlopen + + +def url_download(url, workdir): + file_path = os.path.abspath(os.path.join(workdir, os.path.basename(url))) + src = None + dst = None + try: + req = Request(url) + src = urlopen(req) + with open(file_path, '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: + src.close() + return file_path + + +def download(url, out_file): + today = datetime.datetime.utcnow().strftime("%Y-%m-%d") + + with open(out_file) as fh: + params = json.load(fh) + + workdir = params['output_data'][0]['extra_files_path'] + os.makedirs(workdir) + file_path = url_download(url, workdir) + name = '%s_%s' % (today, os.path.basename(file_path)) + + data_manager_json = {"data_tables": {}} + data_manager_entry = {} + data_manager_entry['value'] = today + data_manager_entry['name'] = name + data_manager_entry['path'] = file_path + data_manager_json["data_tables"]["pima_pv"] = 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('--url', dest='url', help='URL to download plasmids_and_vectors.fasta file') +parser.add_argument('--out_file', dest='out_file', help='JSON output file') + +args = parser.parse_args() + +download(args.url, args.out_file) diff -r 000000000000 -r 9972e1e07347 data_manager/pima_pv_downloader.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/pima_pv_downloader.xml Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,30 @@ + + Download plasmids_and_vectors.fasta files + + python + + + + + + + + + + + + + + + + + + 10.1038/s41598-019-49700-1 + + diff -r 000000000000 -r 9972e1e07347 data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,19 @@ + + + + + + + + + ${path} + pima_pv/${value}/${name} + + ${GALAXY_DATA_MANAGER_DATA_PATH}/pima_pv/${value}/${name} + abspath + + + + + + diff -r 000000000000 -r 9972e1e07347 test-data/pima_pv.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/pima_pv.json Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,1 @@ +{"data_tables": {"pima_pv": {"name": diff -r 000000000000 -r 9972e1e07347 test-data/pima_pv.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/pima_pv.loc Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,12 @@ +# This is a sample file distributed with Galaxy that enables tools +# to use a selected PIMA plasmids_and_vectors.fasta file. The pima_pv.loc +# file has this format (longer white space characters are TAB characters): +# +# +# +# So, for example, if you have the plasmids_and_vectors.fasta files stored in +# /depot/data2/galaxy/pima_pv/, +# then the pima_pv.loc entry would look like this: +# +# 2022-10-18 PIMA plasmids_and_vectors.fasta /depot/data2/galaxy/pima_pv +2022-10-18 2022-10-18 plasmids_and_vectors.fasta ${__HERE__} diff -r 000000000000 -r 9972e1e07347 tool-data/pima_pv.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/pima_pv.loc.sample Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,3 @@ +## PIMA plasmids_and_vectors.fasta files +#Value Name Path +#2022-10-18 plasmids_and_vectors.fasta (2022-10-18) /depot/data2/galaxy/tool-data/pima_pv/2022-10-18 diff -r 000000000000 -r 9972e1e07347 tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,8 @@ + + + + value, name, path + +
+
+ diff -r 000000000000 -r 9972e1e07347 tool_data_table_conf.xml.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.test Mon Dec 12 15:02:14 2022 +0000 @@ -0,0 +1,7 @@ + + + + value, name, path + +
+