Mercurial > repos > stevecassidy > alveoimport
diff alveo_item_list_downloader.py @ 1:6fef3489d97c draft
planemo upload commit 0fca33c3b7285bd31f6c7380393d08bbdad4e4d6
author | stevecassidy |
---|---|
date | Mon, 15 Aug 2016 23:45:46 -0400 |
parents | bfe39bd252df |
children | 7b6021997b8e |
line wrap: on
line diff
--- a/alveo_item_list_downloader.py Mon Jul 18 23:49:40 2016 -0400 +++ b/alveo_item_list_downloader.py Mon Aug 15 23:45:46 2016 -0400 @@ -23,15 +23,20 @@ # this file name pattern allows galaxy to discover the dataset designation and type FNPAT = "%(designation)s_%(ext)s" -def galaxy_name(fname): - """construct a filename suitable for Galaxy dataset discovery""" + +def galaxy_name(itemname, fname): + """construct a filename suitable for Galaxy dataset discovery + designation - (dataset identifier) is the file basename + ext - defines the dataset type and is the file extension + """ root, ext = os.path.splitext(fname) ext = ext[1:] # remove initial . - fname = FNPAT % {'designation': fname, 'ext': ext} + fname = FNPAT % {'designation': itemname, 'ext': ext} return fname + def download_documents(item_list, patterns, output_path): """ Downloads a list of documents to the directory specificed by output_path. @@ -54,7 +59,7 @@ for doc in documents: for pattern in patterns: if not pattern == '' and fnmatch(doc.get_filename(), pattern): - fname = galaxy_name(doc.get_filename()) + fname = galaxy_name(item.metadata()['alveo:metadata']['dc:identifier'], doc.get_filename()) try: doc.download_content(dir_path=output_path, filename=fname) downloaded.append(doc.get_filename())