changeset 24:a70b4c3bdd8b draft

planemo upload
author scottx611x
date Thu, 23 Jun 2016 15:28:06 -0400
parents cb42506ae8ce
children 689075526eb3
files data_manager_gene_annotation/data_manager/data_manager.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/data_manager_gene_annotation/data_manager/data_manager.py	Thu Jun 23 15:23:35 2016 -0400
+++ b/data_manager_gene_annotation/data_manager/data_manager.py	Thu Jun 23 15:28:06 2016 -0400
@@ -29,8 +29,6 @@
 
 
 def url_download(url, name):
-    # Good to note here that requests will automatically handle
-    # content_encoding types: "gzip" and "deflate"
     response = requests.get(url=url, stream=True)
 
     # Generate file_name
@@ -39,6 +37,8 @@
     block_size = 10 * 1024 * 1024  # 10MB chunked download
     with open(file_name, 'w+') as f:
         try:
+            # Good to note here that requests' iter_content() will
+            # automatically handle decoding "gzip" and "deflate" formats
             for buf in response.iter_content(block_size):
                 f.write(buf)
         except (ContentDecodingError, IOError) as e:
@@ -46,13 +46,13 @@
                              % e)
             os.remove(file_name)
 
-    return file_name
+    return os.path.join(os.getcwd(), file_name)
 
 
 def main(args):
 
     # Attempt to download gene annotation file from given url
-    gene_annotation_file_name = url_download(
+    gene_annotation_file_path = url_download(
         "http://www.scott-ouellette.com/gene_annotations/chr1-hg19_genes.gtf", args.name)
 
     # Update Data Manager JSON and write to file
@@ -61,8 +61,8 @@
             'gene_annotation': {
                 'value': str(datetime.datetime.now()),
                 'dbkey': str(args.name),
-                'name': gene_annotation_file_name.split(".")[0],
-                'path': gene_annotation_file_name,
+                'name': gene_annotation_file_path.split(".")[0],
+                'path': gene_annotation_file_path,
             }
         }
     }