changeset 1:f7ad11d31098 draft

planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/tree/master/data_managers/data_manager_megan_tools commit 0e93d2fb8e3c10949811b19ec3329bd1abbb73bf-dirty
author matthias
date Thu, 01 Nov 2018 14:40:23 -0400
parents 1f839ba466da
children 24c02af5fd77
files data_manager/.data_manager.py.swp data_manager/data_manager.py
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
Binary file data_manager/.data_manager.py.swp has changed
--- a/data_manager/data_manager.py	Thu Nov 01 12:25:53 2018 -0400
+++ b/data_manager/data_manager.py	Thu Nov 01 14:40:23 2018 -0400
@@ -47,7 +47,15 @@
 }
 
 def url_download(fname, workdir):
-    file_path = os.path.join(workdir, 'download.dat')
+    """
+    download http://ab.inf.uni-tuebingen.de/data/software/megan6/download/FNAME
+    to workdir
+    and unzip zip file (not gz)
+    
+    return the name of the resulting file 
+           ie gz-file of extracted file in zip-file
+    """
+    file_path = os.path.join(workdir, fname)
     if not os.path.exists(workdir):
         os.makedirs(workdir)
     src = None
@@ -68,20 +76,22 @@
     if zipfile.is_zipfile(file_path):
         fh = zipfile.ZipFile(file_path, 'r')
     else:
-        return
+        return fname
     fh.extractall(workdir)
     os.remove(file_path)
-
+    unzipped = os.listdir(workdir)
+    assert len(unzipped) == 1
+    return unzipped[0]
 
 def main(fname, outjson):
     workdir = os.path.join(os.getcwd(), 'megan_tools')
-    url_download(fname, workdir)
+    path = url_download(fname, workdir)
 
     data_manager_entry = {}
     data_manager_entry['value'] = fname.split(".")[0]
     data_manager_entry['name'] = FILE2NAME[fname]
     data_manager_entry['type'] = FILE2TYPE[fname]
-    data_manager_entry['path'] = '.'
+    data_manager_entry['path'] = path
 
     data_manager_json = dict(data_tables=dict(megan_tools=data_manager_entry))