changeset 23:cb42506ae8ce draft

planemo upload
author scottx611x
date Thu, 23 Jun 2016 15:23:35 -0400
parents b47ce1c4373e
children a70b4c3bdd8b
files data_manager_gene_annotation/data_manager/data_manager.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/data_manager_gene_annotation/data_manager/data_manager.py	Thu Jun 23 15:11:30 2016 -0400
+++ b/data_manager_gene_annotation/data_manager/data_manager.py	Thu Jun 23 15:23:35 2016 -0400
@@ -34,25 +34,26 @@
     response = requests.get(url=url, stream=True)
 
     # Generate file_name
-    file_path = 'gene_annotation_{}'.format(name)
+    file_name = response.url.split("/")[-1]
 
     block_size = 10 * 1024 * 1024  # 10MB chunked download
-    with open(file_path, 'w+') as f:
+    with open(file_name, 'w+') as f:
         try:
             for buf in response.iter_content(block_size):
                 f.write(buf)
         except (ContentDecodingError, IOError) as e:
             sys.stderr.write("Error occured downloading reference file: %s"
                              % e)
-            os.remove(file_path)
+            os.remove(file_name)
 
-    return file_path
+    return file_name
 
 
 def main(args):
 
     # Attempt to download gene annotation file from given url
-    gene_annotation_file_path = url_download(args.url, args.name)
+    gene_annotation_file_name = url_download(
+        "http://www.scott-ouellette.com/gene_annotations/chr1-hg19_genes.gtf", args.name)
 
     # Update Data Manager JSON and write to file
     data_manager_entry = {
@@ -60,8 +61,8 @@
             'gene_annotation': {
                 'value': str(datetime.datetime.now()),
                 'dbkey': str(args.name),
-                'name': str(args.name),
-                'path': gene_annotation_file_path,
+                'name': gene_annotation_file_name.split(".")[0],
+                'path': gene_annotation_file_name,
             }
         }
     }