# HG changeset patch # User greg # Date 1581098545 18000 # Node ID 84a356e0950a6e23c1a5d767f987356911562f25 Uploaded diff -r 000000000000 -r 84a356e0950a .shed.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.shed.yml Fri Feb 07 13:02:25 2020 -0500 @@ -0,0 +1,10 @@ +name: data_manager_vsnp_excel +owner: greg +description: Data manager to download vSNP analysis Excel file +homepage_url: https://github.com/USDA-VS/vSNP +long_description: | + vSNP generates annotated SNP tables, this data manager installs the vSNP Excel file. +remote_repository_url: "https://github.com/gregvonkuster/galaxy_tools/tree/master/tools/data_managers/vsnp_excel" +type: unrestricted +categories: +- Data Managers diff -r 000000000000 -r 84a356e0950a data_manager/vsnp_excel_fetcher.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/vsnp_excel_fetcher.py Fri Feb 07 13:02:25 2020 -0500 @@ -0,0 +1,64 @@ +import argparse +import json +import os +try: + # For Python 3.0 and later + from urllib.request import Request, urlopen +except ImportError: + # Fall back to Python 2 imports + from urllib2 import Request, urlopen + + +def url_download(url, target_directory): + file_path = os.path.abspath(os.path.join(target_directory, 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 + finally: + if src: + src.close() + return file_path + + +def download(dbkey, display_name, url, out_file): + + with open(out_file) as fh: + params = json.loads(fh.read()) + + work_directory = params['output_data'][0]['extra_files_path'] + target_directory = os.path.abspath(os.path.join(work_directory, "vsnp", dbkey)) + os.mkdir(target_directory) + file_path = url_download(url, target_directory) + entry_name = "%s" % os.path.basename(file_path) + + data_manager_json = {"data_tables": {}} + data_manager_entry = {} + data_manager_entry['value'] = dbkey + data_manager_entry['name'] = entry_name + data_manager_entry['path'] = file_path + data_manager_entry['description'] = "Excel file for %s" % display_name + data_manager_json["data_tables"]["vsnp_excel"] = data_manager_entry + + with open(out_file, 'w') as fh: + fh.write(json.dumps(data_manager_json, sort_keys=True)) + + +parser = argparse.ArgumentParser() + +parser.add_argument('--dbkey', dest='dbkey', help='Genome reference dbkey') +parser.add_argument('--display_name', dest='display_name', help='Reference display name') +parser.add_argument('--url', dest='url', help='URL to download Excel file') +parser.add_argument('--out_file', dest='out_file', help='JSON output file') + +args = parser.parse_args() + +download(args.dbkey, args.display_name, args.url, args.out_file) diff -r 000000000000 -r 84a356e0950a data_manager/vsnp_excel_fetcher.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/vsnp_excel_fetcher.xml Fri Feb 07 13:02:25 2020 -0500 @@ -0,0 +1,132 @@ + + + Download reference databases + + python + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 84a356e0950a data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Fri Feb 07 13:02:25 2020 -0500 @@ -0,0 +1,19 @@ + + + + + + + + + + ${path} + vsnp/${value}/excel + + ${GALAXY_DATA_MANAGER_DATA_PATH}/vsnp/${value}/excel + abspath + + + + + diff -r 000000000000 -r 84a356e0950a tool-data/vsnp_excel.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/vsnp_excel.loc.sample Fri Feb 07 13:02:25 2020 -0500 @@ -0,0 +1,4 @@ +## vSNP Excel files +#Value Name Path Description +#AF2122 Mbovis_define_filter.xlsx vsnp/AF2122/Mbovis_define_filter.xlsx Excel file for Mycobacterium bovis AF2122/97 +#NC_006932 Bab1_define_filter.xlsx /vsnp/NC_006932/Bab1_define_filter.xlsx Excel file for Brucella abortus bv. 1 str. 9-941 diff -r 000000000000 -r 84a356e0950a tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Fri Feb 07 13:02:25 2020 -0500 @@ -0,0 +1,7 @@ + + + value, name, path, description + +
+
+