Mercurial > repos > iuc > data_manager_plant_tribes_scaffolds_downloader
changeset 4:93253aebaf2e draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_plant_tribes_scaffolds_downloader commit 6085b7d47fcb47ad1587ac2542abdef782f61fe4"
author | iuc |
---|---|
date | Fri, 17 Jul 2020 04:19:35 -0400 |
parents | 5833ef61c1f8 |
children | 1550b1741780 |
files | data_manager/data_manager_plant_tribes_scaffolds_download.py data_manager/data_manager_plant_tribes_scaffolds_download.xml data_manager_conf.xml test-data/plant_tribes_scaffolds.json test-data/plant_tribes_scaffolds.loc tool_data_table_conf.xml.test |
diffstat | 5 files changed, 44 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/data_manager/data_manager_plant_tribes_scaffolds_download.py Fri Aug 17 07:04:08 2018 -0400 +++ b/data_manager/data_manager_plant_tribes_scaffolds_download.py Fri Jul 17 04:19:35 2020 -0400 @@ -7,9 +7,8 @@ import shutil import sys import tarfile -import urllib2 import zipfile - +from urllib.request import Request, urlopen DEFAULT_DATA_TABLE_NAMES = ["plant_tribes_scaffolds"] @@ -52,22 +51,20 @@ src = None dst = None try: - req = urllib2.Request(url) - src = urllib2.urlopen(req) - dst = open(file_path, 'wb') - while True: - chunk = src.read(2**10) - if chunk: - dst.write(chunk) - else: - break + 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: - print >>sys.stderr, str(e) + sys.exit(str(e)) finally: if src: src.close() - if dst: - dst.close() return file_path @@ -117,9 +114,8 @@ args = parser.parse_args() -# Some magic happens with tools of type "manage_data" in that the output -# file contains some JSON data that allows us to define the target directory. -params = json.loads(open(args.out_file).read()) +with open(args.out_file) as fh: + params = json.loads(fh.read()) target_directory = params['output_data'][0]['extra_files_path'] make_directory(target_directory) @@ -131,6 +127,5 @@ # Get the scaffolds data. data_manager_dict = download(target_directory, args.web_url, args.config_web_url, description) # Write the JSON output dataset. -fh = open(args.out_file, 'wb') -fh.write(json.dumps(data_manager_dict)) -fh.close() +with open(args.out_file, 'w') as fh: + fh.write(json.dumps(data_manager_dict, sort_keys=True))
--- a/data_manager/data_manager_plant_tribes_scaffolds_download.xml Fri Aug 17 07:04:08 2018 -0400 +++ b/data_manager/data_manager_plant_tribes_scaffolds_download.xml Fri Jul 17 04:19:35 2020 -0400 @@ -1,18 +1,15 @@ -<tool id="data_manager_plant_tribes_scaffolds_download" name="PlantTribes Scaffolds Download" version="1.1.0" tool_type="manage_data"> +<tool id="data_manager_plant_tribes_scaffolds_download" name="PlantTribes Scaffolds Download" version="1.1.1" tool_type="manage_data"> <description></description> - <stdio> - <exit_code range=":-1" level="fatal" description="Error: Cannot open file" /> - <exit_code range="1:" level="fatal" description="Error" /> - </stdio> - <command> - <![CDATA[ - python $__tool_directory__/data_manager_plant_tribes_scaffolds_download.py - --name '$name' - --description '$description' - --web_url '$web_url' - --config_web_url '$config_web_url' - --out_file '$out_file' - ]]> + <requirements> + <requirement type="package" version="3.8.3">python</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ +python $__tool_directory__/data_manager_plant_tribes_scaffolds_download.py +--name '$name' +--description '$description' +--web_url '$web_url' +--config_web_url '$config_web_url' +--out_file '$out_file']]> </command> <inputs> <param name="name" type="text" value="" label="Data table entry unique ID"/> @@ -24,6 +21,13 @@ <data name="out_file" format="data_manager_json" /> </outputs> <tests> + <test> + <param name="name" value="12Gv1.0"/> + <param name="description" value="12 plant genomes (Monocots, version 1.0)"/> + <param name="web_url" value="https://github.com/gregvonkuster/galaxy_tools/raw/master/test/plant_tribes/scaffolds/12Gv1.0.tar.bz2"/> + <param name="config_web_url" value="http://bigdata.bx.psu.edu/PlantTribes_scaffolds/configs/12Gv1.0.tar.gz"/> + <output name="out_file" value="plant_tribes_scaffolds.json" compare="contains"/> + </test> </tests> <help> .. class:: infomark
--- a/data_manager_conf.xml Fri Aug 17 07:04:08 2018 -0400 +++ b/data_manager_conf.xml Fri Jul 17 04:19:35 2020 -0400 @@ -3,17 +3,17 @@ <data_manager tool_file="data_manager/data_manager_plant_tribes_scaffolds_download.xml" id="data_manager_plant_tribes_scaffolds_download" > <data_table name="plant_tribes_scaffolds"> <output> - <column name="value" /> + <column name="value"/> <column name="name"/> <column name="path" output_ref="out_file"> - <move type="file"> + <move type="file" relativize_symlinks="True">> <source>${path}</source> <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">plant_tribes/scaffolds/${value}</target> </move> <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/plant_tribes/scaffolds/${value}</value_translation> <value_translation type="function">abspath</value_translation> </column> - <column name="description" /> + <column name="description"/> </output> </data_table> </data_manager>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/plant_tribes_scaffolds.json Fri Jul 17 04:19:35 2020 -0400 @@ -0,0 +1,1 @@ +{"data_tables": {"plant_tribes_scaffolds": [{"description": "12 plant genomes (Monocots, version 1.0)", "name": "12Gv1.0", "path":
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.test Fri Jul 17 04:19:35 2020 -0400 @@ -0,0 +1,7 @@ +<tables> + <!-- Location of scaffolds files for plant_tribes_scaffolds version 1.1.0 --> + <table name="plant_tribes_scaffolds" comment_char="#"> + <columns>value, name, path, description</columns> + <file path="${__HERE__}/test-data/plant_tribes_scaffolds.loc" /> + </table> +</tables>