changeset 46:9346d2955707 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_fetch_gene_annotation/ commit 8652f36a3a3838dca989426961561e81432acf4f
author iuc
date Tue, 04 Apr 2017 18:07:39 -0400
parents 16e961b2f35c
children 3a02b8ab423a
files data_manager/data_manager.py data_manager/gene_annotation_fetcher.xml data_manager_conf.xml data_manager_gene_annotation/data_manager/data_manager.py data_manager_gene_annotation/data_manager/gene_annotation_fetcher.xml data_manager_gene_annotation/data_manager_conf.xml data_manager_gene_annotation/test-data/gene_annotation_out.json data_manager_gene_annotation/tool-data/gene_annotation.loc.sample data_manager_gene_annotation/tool_data_table_conf.xml.sample data_manager_gene_annotation/tool_dependencies.xml tool-data/gene_annotation.loc.sample tool_data_table_conf.xml.sample
diffstat 10 files changed, 131 insertions(+), 146 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/data_manager.py	Tue Apr 04 18:07:39 2017 -0400
@@ -0,0 +1,74 @@
+import argparse
+import datetime
+import json
+import os
+import sys
+import uuid
+
+import requests
+from requests.exceptions import ContentDecodingError
+
+
+def url_download(url):
+    """Attempt to download gene annotation file from a given url
+    :param url: full url to gene annotation file
+    :type url: str.
+    :returns: name of downloaded gene annotation file
+    :raises: ContentDecodingError, IOError
+    """
+    response = requests.get(url=url, stream=True)
+
+    # Generate file_name
+    file_name = response.url.split("/")[-1]
+
+    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" encoding
+            # formats
+            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_name)
+
+    return file_name
+
+
+def main():
+    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()
+
+    # Attempt to download gene annotation file from given url
+    gene_annotation_file_name = url_download(args.url)
+
+    # Update Data Manager JSON and write to file
+    data_manager_entry = {
+        'data_tables': {
+            'gff_gene_annotations': {
+                'value': str(datetime.datetime.now()),
+                'dbkey': str(args.name),
+                'name': gene_annotation_file_name,
+                'path': os.path.join(work_dir, gene_annotation_file_name)
+            }
+        }
+    }
+
+    with open(os.path.join(args.output), "w+") as f:
+        f.write(json.dumps(data_manager_entry))
+
+
+if __name__ == '__main__':
+    main()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/gene_annotation_fetcher.xml	Tue Apr 04 18:07:39 2017 -0400
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<tool id="gene_annotation_fetcher_data_manager" name="Gene Annotation Fetch" tool_type="manage_data" version="1.0.1">
+    <description>gene annotation fetcher</description>
+    <requirements>
+        <requirement type="package" version="2.13.0">requests</requirement>
+    </requirements>
+    <command detect_errors="exit_code">
+    <![CDATA[
+        python '$__tool_directory__/data_manager.py' --out '${out_file}'
+        #if $gene_annotation_url:
+            --url '${gene_annotation_url}'
+        #end if
+        #if $database_name:
+            --name '${database_name}'
+        #end if
+    ]]>
+    </command>
+    <inputs>
+        <param name="database_name" type="text" optional="true" label="Name for this database" help="Enter a unique identifier, or leave blank for today's date" />
+        <param name="gene_annotation_url" type="text" label="Enter URL for gene annotation files" />
+    </inputs>
+    <outputs>
+        <data format="data_manager_json" name="out_file" />
+    </outputs>
+    <help>
+    </help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml	Tue Apr 04 18:07:39 2017 -0400
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<data_managers>
+
+    <data_manager tool_file="data_manager/gene_annotation_fetcher.xml" id="gene_annotation_fetcher" version="1.0.0">
+        <data_table name="gff_gene_annotations">
+            <output>
+                <column name="value" />
+                <column name="dbkey" />
+                <column name="name" />
+                <column name="path" output_ref="out_file" >
+                    <move type="file">
+                        <source>${path}</source>
+                        <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">${dbkey}/seq/${path}</target>
+                    </move>
+                    <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/${dbkey}/seq/${path}</value_translation>
+                    <value_translation type="function">abspath</value_translation>
+                </column>
+            </output>
+        </data_table>
+    </data_manager>
+
+</data_managers>
--- a/data_manager_gene_annotation/data_manager/data_manager.py	Fri Jul 08 15:01:07 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-import os
-import sys
-import json
-import argparse
-import requests
-from requests.exceptions import ContentDecodingError
-
-
-def url_download(url):
-    """Attempt to download gene annotation file from a given url
-    :param url: full url to gene annotation file
-    :type url: str.
-    :returns: name of downloaded gene annotation file
-    :raises: ContentDecodingError, IOError
-    """
-    response = requests.get(url=url, stream=True)
-
-    # Generate file_name
-    file_name = response.url.split("/")[-1]
-
-    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" encoding
-            # formats
-            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_name)
-
-    return file_name
-
-
-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=None, 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()
-
-    # Attempt to download gene annotation file from given url
-    gene_annotation_file_name = url_download(args.url)
-
-    name = str(args.name)
-
-    if not name:
-        name = gene_annotation_file_name.split(".")[0]
-
-    # Update Data Manager JSON and write to file
-    data_manager_entry = {
-        'data_tables': {
-            'gene_annotation': {
-                'value': gene_annotation_file_name,
-                'dbkey': gene_annotation_file_name.split(".")[0],
-                'name': name,
-                'path': os.path.join(work_dir, gene_annotation_file_name)
-            }
-        }
-    }
-
-    with open(os.path.join(args.output), "w+") as f:
-        f.write(json.dumps(data_manager_entry))
-
-if __name__ == '__main__':
-    main()
--- a/data_manager_gene_annotation/data_manager/gene_annotation_fetcher.xml	Fri Jul 08 15:01:07 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<tool id="gene_annotation_fetcher_data_manager" name="Gene Annotation Fetch" tool_type="manage_data" version="1.0.0">
-    <description>gene annotation fetcher</description>
-    <stdio>
-        <exit_code description="Error" level="fatal" range="1:" />
-    </stdio>
-    <command interpreter="python">
-    <![CDATA[
-        data_manager.py --out "${out_file}"
-        #if $gene_annotation_url:
-            --url "${gene_annotation_url}"
-        #end if
-        #if $database_name:
-            --name "${database_name}"
-        #end if
-    ]]>
-    </command>
-    <inputs>
-        <param
-                help="Enter a descriptive name to be used in the tool drop-down menus" label="Identifier for this DataTable entry" name="database_name" type="text" optional="True" />
-        <param
-                label="Enter URL pointing to a remote GTF/GFF file" name="gene_annotation_url" type="text" optional="False"/>
-    </inputs>
-    <outputs>
-        <data format="data_manager_json" name="out_file" />
-    </outputs>
-    <tests>
-        <test>
-            <param name="database_name" value="cool_name"/>
-            <param name="gene_annotation_url" value="http://www.scott-ouellette.com/gene_annotations/chr1-hg19_genes.gtf"/>
-            <output name="out_file" file="gene_annotation_out.json" compare="contains"/>
-            <!--<extra_files type="file" name="chr1-hg19_genes.gtf" value="chr1-hg19_genes.gtf"/>-->
-        </test>
-    </tests>
-</tool>
--- a/data_manager_gene_annotation/data_manager_conf.xml	Fri Jul 08 15:01:07 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-<?xml version="1.0"?>
-<data_managers>
-
-	<data_manager tool_file="data_manager/gene_annotation_fetcher.xml" id="gene_annotation_fetcher" version="1.0.0">
-		<data_table name="gene_annotation">
-			<output>
-				<column name="value" />
-				<column name="dbkey" />
-				<column name="name" />
-				<column name="path" output_ref="out_file">
-					<move type="file">
-						<source>${path}</source>
-						<target base="${GALAXY_DATA_MANAGER_DATA_PATH}">gene_annotations/${value}</target>
-					</move>
-					<value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/gene_annotations/${value}</value_translation>
-					<value_translation type="function">abspath</value_translation>
-				</column>
-			</output>
-		</data_table>
-	</data_manager>
-
-</data_managers>
--- a/data_manager_gene_annotation/test-data/gene_annotation_out.json	Fri Jul 08 15:01:07 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-{"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
--- a/data_manager_gene_annotation/tool_data_table_conf.xml.sample	Fri Jul 08 15:01:07 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-<?xml version="1.0"?>
-<tables>
-    <!-- Locations of gene annotation data -->
-    <table name="gene_annotation" comment_char="#">
-        <columns>value, dbkey, name, path</columns>
-        <file path="tool-data/gene_annotation.loc" />
-    </table>
-</tables>
\ No newline at end of file
--- a/data_manager_gene_annotation/tool_dependencies.xml	Fri Jul 08 15:01:07 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-<?xml version="1.0"?>
-<tool_dependency>
-</tool_dependency>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Tue Apr 04 18:07:39 2017 -0400
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<tables>
+    <!-- Locations of gene annotation data -->
+    <table name="gff_gene_annotations" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/gene_annotation.loc" />
+    </table>
+</tables>
\ No newline at end of file