changeset 37:7af38f95bc8d draft

planemo upload
author scottx611x
date Thu, 23 Jun 2016 17:56:47 -0400
parents f38beb0743d5
children d27c122c2424
files data_manager_gene_annotation/data_manager/data_manager.py data_manager_gene_annotation/data_manager_conf.xml data_manager_gene_annotation/test-data/gene_annotation_out.json
diffstat 3 files changed, 26 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/data_manager_gene_annotation/data_manager/data_manager.py	Thu Jun 23 17:18:20 2016 -0400
+++ b/data_manager_gene_annotation/data_manager/data_manager.py	Thu Jun 23 17:56:47 2016 -0400
@@ -7,28 +7,14 @@
 import requests
 from requests.exceptions import ContentDecodingError
 
-parser = argparse.ArgumentParser(description='Create data manager json.')
-parser.add_argument('--out',
-                    dest='output',
-                    action='store',
-                    help='JSON filename',
-                    )
-parser.add_argument('--name',
-                    dest='name',
-                    action='store',
-                    default=uuid.uuid4(),
-                    help='Data table entry unique ID'
-                    )
-parser.add_argument('--url',
-                    dest='url',
-                    action='store',
-                    help='Download URL'
-                    )
-
-args = parser.parse_args()
-
 
 def url_download(url):
+    """Attempt to download gene annotation file from a given url
+    :param url: NodeSet UUID.
+    :type url: str.
+    :returns: name of downloaded gene annotation file
+    :raises: ContentDecodingError, IOError
+    """
     response = requests.get(url=url, stream=True)
 
     # Generate file_name
@@ -38,7 +24,8 @@
     with open(file_name, 'w+') as f:
         try:
             # Good to note here that requests' iter_content() will
-            # automatically handle decoding "gzip" and "deflate" formats
+            # automatically handle decoding "gzip" and "deflate" encoding
+            # formats
             for buf in response.iter_content(block_size):
                 f.write(buf)
         except (ContentDecodingError, IOError) as e:
@@ -46,14 +33,22 @@
                              % e)
             os.remove(file_name)
 
-    with open("/Users/scott/Desktop/cool.txt", "w+") as f:
-        f.write(os.path.join(os.getcwd(), file_name))
-        f.write("\n")
-
     return file_name
 
 
-def main(args):
+def main():
+
+    # Generate and parse command line args
+    parser = argparse.ArgumentParser(description='Create data manager JSON.')
+    parser.add_argument('--out', dest='output', action='store',
+                        help='JSON filename')
+    parser.add_argument('--name', dest='name', action='store',
+                        default=uuid.uuid4(), help='Data table entry unique ID'
+                        )
+    parser.add_argument('--url', dest='url', action='store',
+                        help='Url to download gtf file from')
+
+    args = parser.parse_args()
 
     work_dir = os.getcwd()
 
@@ -76,4 +71,4 @@
         f.write(json.dumps(data_manager_entry))
 
 if __name__ == '__main__':
-    main(args)
+    main()
--- a/data_manager_gene_annotation/data_manager_conf.xml	Thu Jun 23 17:18:20 2016 -0400
+++ b/data_manager_gene_annotation/data_manager_conf.xml	Thu Jun 23 17:56:47 2016 -0400
@@ -8,11 +8,11 @@
 				<column name="dbkey" />
 				<column name="name" />
 				<column name="path" output_ref="out_file">
-					<move type="file" relativize_symlinks="False">
+					<move type="file">
 						<source>${path}</source>
-						<target base="${GALAXY_DATA_MANAGER_DATA_PATH}">${dbkey}/gene_annotations/${name}</target>
+						<target base="${GALAXY_DATA_MANAGER_DATA_PATH}">gene_annotations/${name}</target>
 					</move>
-					<value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/${dbkey}/gene_annotations/${name}</value_translation>
+					<value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/gene_annotations/${name}</value_translation>
 					<value_translation type="function">abspath</value_translation>
 				</column>
 			</output>
--- a/data_manager_gene_annotation/test-data/gene_annotation_out.json	Thu Jun 23 17:18:20 2016 -0400
+++ b/data_manager_gene_annotation/test-data/gene_annotation_out.json	Thu Jun 23 17:56:47 2016 -0400
@@ -0,0 +1,1 @@
+{"data_tables": {"gene_annotation": {"path": "/Users/scott/PyCharmProjects/Galaxy/galaxy/database/job_working_directory/003/3702/chr1-hg19_genes.gtf", "dbkey": "cool_name", "value": "2016-06-23 17:19:39.412249", "name": "chr1-hg19_genes.gtf"}}}
\ No newline at end of file