# HG changeset patch
# User iuc
# Date 1589059665 14400
# Node ID efed56c325dad6da781a9a0f5e7712c31cc03ecc
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_vsnp_genbank commit 31f4453e44da62788efd01736ed57ad483383b09"
diff -r 000000000000 -r efed56c325da data_manager/vsnp_genbank_fetcher.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/vsnp_genbank_fetcher.py	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,66 @@
+import argparse
+import json
+import os
+import sys
+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, 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(dbkey, name, url, out_file):
+
+    with open(out_file) as fh:
+        params = json.loads(fh.read())
+
+    workdir = params['output_data'][0]['extra_files_path']
+    os.makedirs(workdir)
+    file_path = url_download(url, workdir)
+    entry_name = 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'] = "Genbank file for %s" % name
+    data_manager_json["data_tables"]["vsnp_genbank"] = 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('--name', dest='name', help='Reference display name')
+parser.add_argument('--url', dest='url', help='URL to download Genbank file')
+parser.add_argument('--out_file', dest='out_file', help='JSON output file')
+
+args = parser.parse_args()
+
+download(args.dbkey, args.name, args.url, args.out_file)
diff -r 000000000000 -r efed56c325da data_manager/vsnp_genbank_fetcher.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/vsnp_genbank_fetcher.xml	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,103 @@
+
+
+    Download vSNP Genbank files
+    
+        python
+    
+    
+    
+    
+        
+            
+        
+        
+    
+    
+        
+    
+    
+        
+            
+            
+            
+        
+    
+    
+    
+    
+
diff -r 000000000000 -r efed56c325da data_manager_conf.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,21 @@
+
+
+    
+        
+            
+        
+    
+
+
diff -r 000000000000 -r efed56c325da test-data/AF2122.fa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/AF2122.fa	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,11 @@
+>NC_002945.4 Mycobacterium bovis AF2122/97 genome assembly, chromosome: Mycobacterium_bovis_AF2122/97
+TTGACCGATGACCCCGGTTCAGGCTTCACCACAGTGTGGAACGCGGTCGTCTCCGAACTTAACGGCGACC
+CTAAGGTTGACGACGGACCCAGCAGTGATGCTAATCTCAGCGCTCCGCTGACCCCTCAGCAAAGGGCTTG
+GCTCAATCTCGTCCAGCCATTGACCATCGTCGAGGGGTTTGCTCTGTTATCCGTGCCGAGCAGCTTTGTC
+CAAAACGAAATCGAGCGCCATCTGCGGGCCCCGATTACCGACGCTCTCAGCCGCCGACTCGGACATCAGA
+TCCAACTCGGGGTCCGCATCGCTCCGCCGGCGACCGACGAAGCCGACGACACTACCGTGCCGCCTTCCGA
+AAATCCTGCTACCACATCGCCAGACACCACAACCGACAACGACGAGATTGATGACAGCGCTGCGGCACGG
+GGCGATAACCAGCACAGTTGGCCAAGTTACTTCACCGAGCGCCCGCGCAATACCGATTCCGCTACCGCTG
+GCGTAACCAGCCTTAACCGTCGCTACACCTTTGATACGTTCGTTATCGGCGCCTCCAACCGGTTCGCGCA
+CGCCGCCGCCTTGGCGATCGCAGAAGCACCCGCCCGCGCTTACAACCCCCTGTTCATCTGGGGCGAGTCC
+GGTCTCGGCAAGACACACCTGCTACACGCGGCAGGCAACTATGCCCAACGGTTGTTCCCGGGAATGCGGG
diff -r 000000000000 -r efed56c325da test-data/all_fasta.loc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/all_fasta.loc	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,19 @@
+#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.
+#
+AF2122	AF2122	AF2122	${__HERE__}/AF2122.fa
diff -r 000000000000 -r efed56c325da test-data/vsnp_genbank.json
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/vsnp_genbank.json	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,1 @@
+{"data_tables": {"vsnp_genbank": {"description": "Genbank file for AF2122", "name": "NC_002945v4.gbk", "path":
diff -r 000000000000 -r efed56c325da test-data/vsnp_genbank.loc
diff -r 000000000000 -r efed56c325da tool-data/all_fasta.loc.sample
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/all_fasta.loc.sample	Sat May 09 17:27:45 2020 -0400
@@ -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 efed56c325da tool-data/vsnp_genbank.loc.sample
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/vsnp_genbank.loc.sample	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,4 @@
+## vSNP Genbank files
+#Value	Name	Path	Description
+#AF2122	Mycobacterium_AF2122/NC_002945v4.gbk	vsnp/AF2122/Mycobacterium_AF2122/NC_002945v4.gbk	Genbank file for Mycobacterium bovis AF2122/97
+#NC_006932	Brucella_abortus1/NC_006932-NC_006933.gbk	vsnp/NC_006932/Brucella_abortus1/NC_006932-NC_006933.gbk	Genbank file for Brucella abortus bv. 1 str. 9-941
diff -r 000000000000 -r efed56c325da tool_data_table_conf.xml.sample
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,13 @@
+
+    
+    
+        value, dbkey, name, path
+        
+    
+    
+    
+        value, name, path, description
+        
+    
+
+
diff -r 000000000000 -r efed56c325da tool_data_table_conf.xml.test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.test	Sat May 09 17:27:45 2020 -0400
@@ -0,0 +1,12 @@
+
+    
+    
+        value, dbkey, name, path
+        
+    
+    
+    
+        value, name, path, description
+        
+    
+