changeset 0:53eec20e8fb6 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_fetch_busco/ commit 2896dcfd180800d00ea413a59264ef8b11788b8e
author iuc
date Thu, 19 Oct 2017 15:56:20 -0400
parents
children 15b97817550a
files data_manager/busco_fetcher.xml data_manager/data_manager.py data_manager_conf.xml tool-data/busco.loc.sample tool_data_table_conf.xml.sample
diffstat 5 files changed, 169 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/busco_fetcher.xml	Thu Oct 19 15:56:20 2017 -0400
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<tool id="busco_fetcher" name="Busco" tool_type="manage_data" version="1.0.0">
+    <description>dataset dowloader</description>
+    <command detect_errors="exit_code">
+    <![CDATA[
+        python '$__tool_directory__/data_manager.py' --out '${out_file}'
+            --url 'http://busco.ezlab.org/datasets/${dataset}.tar.gz'
+            --name '${dataset}'
+    ]]>
+    </command>
+    <inputs>
+        <param name="dataset" type="select" label="Choose dataset to download">
+            <option value="eukaryota_odb9">eukaryota</option>
+            <option value="metazoa_odb9">metazoa</option>
+            <option value="nematoda_odb9">nematoda</option>
+            <option value="arthropoda_odb9">arthropoda</option>
+            <option value="insecta_odb9">insecta</option>
+            <option value="endopterygota_odb9">endopterygota</option>
+            <option value="hymenoptera_odb9">hymenoptera</option>
+            <option value="diptera_odb9">diptera</option>
+            <option value="vertebrata_odb9">vertebrata</option>
+            <option value="actinopterygii_odb9">actinopterygii</option>
+            <option value="tetrapoda_odb9">tetrapoda</option>
+            <option value="aves_odb9">aves</option>
+            <option value="mammalia_odb9">mammalia</option>
+            <option value="euarchontoglires_odb9">euarchontoglires</option>
+            <option value="laurasiatheria_odb9">laurasiatheria</option>
+            <option value="embryophyta_odb9">embryophyta</option>
+            <option value="protists_ensembl">protists</option>
+            <option value="alveolata_stramenophiles_ensembl">alveolata</option>
+            <option value="fungi_odb9">fungi</option>
+            <option value="microsporidia_odb9">microsporidia</option>
+            <option value="dikarya_odb9">dikarya</option>
+            <option value="ascomycota_odb9">ascomycota</option>
+            <option value="pezizomycotina_odb9">pezizomycotina</option>
+            <option value="eurotiomycetes_odb9">eurotiomycetes</option>
+            <option value="sordariomyceta_odb9">sordariomyceta</option>
+            <option value="saccharomyceta_odb9">saccharomyceta</option>
+            <option value="saccharomycetales_odb9">saccharomycetales</option>
+            <option value="basidiomycota_odb9">basidiomycota</option>
+            <option value="bacteria_odb9">bacteria</option>
+            <option value="proteobacteria_odb9">proteobacteria</option>
+            <option value="rhizobiales_odb9">rhizobiales</option>
+            <option value="betaproteobacteria_odb9">betaproteobacteria</option>
+            <option value="gammaproteobacteria_odb9">gammaproteobacteria</option>
+            <option value="enterobacteriales_odb9">enterobacteriales</option>
+            <option value="deltaepsilonsub_odb9">deltaepsilonsub</option>
+            <option value="actinobacteria_odb9">actinobacteria</option>
+            <option value="cyanobacteria_odb9">cyanobacteria</option>
+            <option value="firmicutes_odb9">firmicutes</option>
+            <option value="clostridia_odb9">clostridia</option>
+            <option value="lactobacillales_odb9">lactobacillales</option>
+            <option value="bacillales_odb9">bacillales</option>
+            <option value="bacteroidetes_odb9">bacteroidetes</option>
+            <option value="spirochaetes_odb9">spirochaetes</option>
+            <option value="tenericutes_odb9">tenericutes</option>
+        </param>
+    </inputs>
+    <outputs>
+        <data name="out_file" format="data_manager_json" />
+    </outputs>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/data_manager.py	Thu Oct 19 15:56:20 2017 -0400
@@ -0,0 +1,69 @@
+import argparse
+import datetime
+import json
+import os
+import shutil
+import tarfile
+import zipfile
+try:
+    # For Python 3.0 and later
+    from urllib.request import Request, urlopen
+except ImportError:
+    # Fall back to Python 2 imports
+    from urllib2 import Request, urlopen
+
+
+def url_download(url, workdir):
+    file_path = os.path.join(workdir, 'download.dat')
+    if not os.path.exists(workdir):
+        os.makedirs(workdir)
+    src = None
+    dst = None
+    try:
+        req = Request(url)
+        src = urlopen(req)
+        with open(file_path, 'wb') as dst:
+            while True:
+                chunk = src.read(2**10)
+                if chunk:
+                    dst.write(chunk)
+                else:
+                    break
+    finally:
+        if src:
+            src.close()
+    if tarfile.is_tarfile(file_path):
+        fh = tarfile.open(file_path, 'r:*')
+    elif zipfile.is_zipfile(file_path):
+        fh = zipfile.ZipFile(file_path, 'r')
+    else:
+        return
+    fh.extractall(workdir)
+    os.remove(file_path)
+
+
+def main(args):
+    workdir = os.path.join(os.getcwd(), 'busco')
+    url_download(args.url, workdir)
+    data_manager_entry = {}
+    data_manager_entry['value'] = args.name.lower()
+    data_manager_entry['name'] = args.name
+    data_manager_entry['path'] = '.'
+    data_manager_json = dict(data_tables=dict(busco=data_manager_entry))
+    params = json.loads(open(args.output).read())
+    target_directory = params['output_data'][0]['extra_files_path']
+    os.mkdir(target_directory)
+    output_path = os.path.abspath(os.path.join(os.getcwd(), 'busco'))
+    for filename in os.listdir(workdir):
+        shutil.move(os.path.join(output_path, filename), target_directory)
+    file(args.output, 'w').write(json.dumps(data_manager_json))
+
+
+if __name__ == '__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=str(datetime.date.today()), help='Data table entry unique ID')
+    parser.add_argument('--url', dest='url', action='store', help='Download URL')
+    args = parser.parse_args()
+
+    main(args)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml	Thu Oct 19 15:56:20 2017 -0400
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<data_managers>
+    <data_manager tool_file="data_manager/busco_fetcher.xml" id="busco_fetcher" version="1.0.0">
+        <data_table name="busco">
+            <output>
+                <column name="value" />
+                <column name="name" />
+                <column name="path" output_ref="out_file">
+                    <move type="directory" relativize_symlinks="True">
+                        <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">busco/${value}</target>
+                    </move>
+                    <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/busco/${value}</value_translation>
+                    <value_translation type="function">abspath</value_translation>
+                </column>
+            </output>
+        </data_table>
+    </data_manager>
+</data_managers>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/busco.loc.sample	Thu Oct 19 15:56:20 2017 -0400
@@ -0,0 +1,13 @@
+# This is a sample file distributed with Galaxy that is used to define a
+# list of busco datasets, using four columns tab separated:
+#
+# <unique_build_id>	<display_name>	<genome_fasta_file_path>
+#
+# Datasets can be retrieved from http://busco.ezlab.org/frame_wget.html
+#
+# "/some/path/arthropoda/" would be the last column in the line
+# If this were for the mm10 mouse genome, the resulting entry would look like:
+#
+#arthropoda_2.0	arthropoda_2.0	/some/path/arthropoda/
+#
+#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Thu Oct 19 15:56:20 2017 -0400
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<tables>
+    <table name="busco" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/busco.loc" />
+    </table>
+</tables>