# HG changeset patch # User sanbi-uwc # Date 1587046019 0 # Node ID c401f63b3d124875dc1b11ee44776c94f5a9f047 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_fetch_refseq commit 120c6491f4b0888220e432693a9805d8198d7397" diff -r 000000000000 -r c401f63b3d12 data_manager/fetch_artic_primers.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/fetch_artic_primers.py Thu Apr 16 14:06:59 2020 +0000 @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +from __future__ import print_function, division + +import argparse +import json +import os +import os.path +import sys + +import requests + +DATA_TABLE_NAME = 'artic_primers' +def fetch_artic_primers(output_filename, output_directory, primers): + primer_sets = { + 'ARTICv1': 'https://raw.githubusercontent.com/artic-network/artic-ncov2019/master/primer_schemes/nCoV-2019/V1/nCoV-2019.bed', + 'ARTICv2': 'https://raw.githubusercontent.com/artic-network/artic-ncov2019/master/primer_schemes/nCoV-2019/V2/nCoV-2019.bed', + 'ARTICv3': 'https://raw.githubusercontent.com/artic-network/artic-ncov2019/master/primer_schemes/nCoV-2019/V3/nCoV-2019.bed' + } + + if not os.path.isdir(output_directory): + os.makedirs(output_directory) + data_manager_dict = json.load(open(output_filename)) + data_manager_dict['data_tables'] = data_manager_dict.get('data_tables', {}) + data_manager_dict['data_tables'][DATA_TABLE_NAME] = data_manager_dict['data_tables'].get(DATA_TABLE_NAME, []) + + data = [] + for name, url in primer_sets.items(): + response = requests.get(url) + if response.status_code != 200: + print('Error: download of', url, 'failed with code', response.status_code, file=sys.stderr) + exit(response.status_code) + bed_output_filename = os.path.join(output_directory, name + '.bed') + open(bed_output_filename, 'w').write(response.text) + description = name[:-2] + ' ' + name[-2:] + ' primer set' + data.append(dict(value=name, path=bed_output_filename, description=description)) + data_manager_dict['data_tables'][DATA_TABLE_NAME].extend(data) + print(data_manager_dict) + json.dump(data_manager_dict, open(output_filename, 'w')) + +class SplitArgs(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + setattr(namespace, self.dest, values.split(',')) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Fetch ARTIC primer files for Galaxy use') + parser.add_argument('--output_directory', default='tmp', help='Directory to write output to') + parser.add_argument('--galaxy_datamanager_filename', help='Galaxy JSON format file describing data manager inputs') + parser.add_argument('--primers', default='ARTCIv1,ARTICv2,ARTICv3', action=SplitArgs, help='Comma separated list of primers to fetch') + args = parser.parse_args() + fetch_artic_primers(args.galaxy_datamanager_filename, args.output_directory, args.primers) \ No newline at end of file diff -r 000000000000 -r c401f63b3d12 data_manager/fetch_artic_primers.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/fetch_artic_primers.xml Thu Apr 16 14:06:59 2020 +0000 @@ -0,0 +1,31 @@ + + + python + requests + + + + python '$__tool_directory__/fetch_artic_primers.py' + --galaxy_datamanager_filename '${output_file}' + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 000000000000 -r c401f63b3d12 data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Thu Apr 16 14:06:59 2020 +0000 @@ -0,0 +1,19 @@ + + + + + + + + + + ${path} + artic_primers/#echo str($name).bed# + + artic_primers/#echo str($name).bed# + abspath + + + + + diff -r 000000000000 -r c401f63b3d12 test-data/artic.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/artic.json Thu Apr 16 14:06:59 2020 +0000 @@ -0,0 +1,21 @@ +{ + "data_tables": { + "artic_primers": [ + { + "value": "ARTICv1", + "description": "ARTIC v1 primer set", + "path": "tmp/ARTICv1.bed" + }, + { + "value": "ARTICv2", + "description": "ARTIC v2 primer set", + "path": "tmp/ARTICv2.bed" + }, + { + "value": "ARTICv3", + "description": "ARTIC v3 primer set", + "path": "tmp/ARTICv3.bed" + } + ] + } +} diff -r 000000000000 -r c401f63b3d12 tool-data/all_fasta.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/all_fasta.loc.sample Thu Apr 16 14:06:59 2020 +0000 @@ -0,0 +1,18 @@ +#This file lists the locations and dbkeys of all the fasta files +#under the "genome" directory (a directory that contains a directory +#for each build). The script extract_fasta.py will generate the file +#all_fasta.loc. This file has the format (white space characters are +#TAB characters): +# +# +# +#So, all_fasta.loc could look something like this: +# +#apiMel3 apiMel3 Honeybee (Apis mellifera): apiMel3 /path/to/genome/apiMel3/apiMel3.fa +#hg19canon hg19 Human (Homo sapiens): hg19 Canonical /path/to/genome/hg19/hg19canon.fa +#hg19full hg19 Human (Homo sapiens): hg19 Full /path/to/genome/hg19/hg19full.fa +# +#Your all_fasta.loc file should contain an entry for each individual +#fasta file. So there will be multiple fasta files for each build, +#such as with hg19 above. +# diff -r 000000000000 -r c401f63b3d12 tool-data/artic_primers.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/artic_primers.loc.sample Thu Apr 16 14:06:59 2020 +0000 @@ -0,0 +1,7 @@ +# this is a tab separated file describing the location of ARTIC primers for use in SARS-CoV-2 sequencing +# +# the columns are: +# value description path +# +# for example +# ARTICv1 ARTIC v1 primers /data/galaxy/tool_data/artic_primers/ARTICv1.bed \ No newline at end of file diff -r 000000000000 -r c401f63b3d12 tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Thu Apr 16 14:06:59 2020 +0000 @@ -0,0 +1,7 @@ + + + + value, description, path + +
+
\ No newline at end of file