changeset 0:26a6f95e82c8 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_mitos commit 791f28c8a7194fdd1ecec05ad166932d461899b2"
author iuc
date Fri, 27 Mar 2020 17:50:23 -0400
parents
children 1ff9996995ee
files data_manager/data_manager.py data_manager/data_manager_mitos.xml data_manager_conf.xml test-data/mitos.loc test-data/mitos_refseq39.json tool-data/mitos.loc.sample tool_data_table_conf.xml.sample tool_data_table_conf.xml.test
diffstat 8 files changed, 225 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/data_manager.py	Fri Mar 27 17:50:23 2020 -0400
@@ -0,0 +1,91 @@
+import argparse
+import json
+import os
+import shutil
+import tarfile
+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
+
+ZENODO = {
+    "mitos": "2683856",
+    "mitos2": "3685310"
+}
+NAMES = {
+    "mitos1-refdata": "RefSeq39 + MiTFi tRNA models",
+    "refseq39": "RefSeq39 (equivalent to MITOS1 data)",
+    "refseq63m": "RefSeq63 Metazoa",
+    "refseq63f": "RefSeq63 Fungi",
+    "refseq63o": "RefSeq63 Opisthokonta",
+    "refseq89m": "RefSeq89 Metazoa",
+    "refseq89f": "RefSeq89 Fungi",
+    "refseq89o": "RefSeq89 Opisthokonta"
+}
+
+
+def url_download(tpe, db, workdir):
+    """
+    download http://ab.inf.uni-tuebingen.de/data/software/megan6/download/FNAME
+    to workdir
+    and unzip
+
+    return the name of the resulting dir
+    """
+    tarfname = os.path.join(workdir, db + ".tar.bz")
+    if not os.path.exists(workdir):
+        os.makedirs(workdir)
+    src = None
+    dst = None
+    try:
+        req = Request("https://zenodo.org/record/{zenodoid}/files/{db}.tar.bz2?download=1".format(zenodoid=ZENODO[tpe], db=db))
+        src = urlopen(req)
+        with open(tarfname, 'wb') as dst:
+            while True:
+                chunk = src.read(2**10)
+                if chunk:
+                    dst.write(chunk)
+                else:
+                    break
+    finally:
+        if src:
+            src.close()
+    with tarfile.open(tarfname, "r:bz2") as tar:
+        dirname = tar.getnames()[0]
+        tar.extractall(workdir)
+    os.remove(tarfname)
+    return dirname
+
+
+def main(tpe, db, outjson):
+    workdir = os.getcwd()
+
+    path = url_download(tpe, db, workdir)
+
+    data_manager_entry = {}
+    data_manager_entry['value'] = db
+    data_manager_entry['name'] = NAMES[db]
+    data_manager_entry['type'] = tpe
+    data_manager_entry['path'] = path
+    data_manager_json = dict(data_tables=dict(mitos=data_manager_entry))
+
+    with open(outjson) as f:
+        params = json.loads(f.read())
+    target_directory = params['output_data'][0]['extra_files_path']
+    os.mkdir(target_directory)
+    # output_path = os.path.abspath(os.path.join(os.getcwd(), 'mitos'))
+    shutil.move(os.path.join(workdir, path), target_directory)
+    with open(outjson, 'w') as fh:
+        fh.write(json.dumps(data_manager_json, sort_keys=True))
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser(description='Create data manager json.')
+    parser.add_argument('--out', action='store', help='JSON filename')
+    parser.add_argument('--type', action='store', help='mitos version')
+    parser.add_argument('--db', action='store', help='db name')
+    args = parser.parse_args()
+
+    main(args.type, args.db, args.out)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/data_manager_mitos.xml	Fri Mar 27 17:50:23 2020 -0400
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<tool id="data_manager_mitos" name="MITOS" tool_type="manage_data" version="0.0.1">
+    <description>reference data downloader</description>
+    <requirements>
+        <requirement type="package" version="3.7">python</requirement>
+    </requirements>
+    <command detect_errors="exit_code">
+    <![CDATA[
+    python '$__tool_directory__/data_manager.py' 
+    --out '${out_file}'
+    --type '$type_cond.type_select'
+    --db '$type_cond.database'
+    ]]>
+    </command>
+    <inputs>
+        <conditional name="type_cond">
+            <param name="type_select" type="select" label="MITOS version">
+                <option value="mitos">MITOS</option>
+                <option value="mitos2">MITOS2</option>
+            </param>
+            <when value="mitos">
+                <param name="database" type="select" label="Reference data version">
+                    <option value="mitos1-refdata">RefSeq39 + MiTFi tRNA models</option>
+                </param>
+            </when>
+            <when value="mitos2">
+                <param name="database" type="select" label="Reference data version">
+                    <option value="refseq39">RefSeq39 (equivalent to MITOS1 data)</option>
+                    <option value="refseq63m">RefSeq63 Metazoa</option>
+                    <option value="refseq63f">RefSeq63 Fungi</option>
+                    <option value="refseq63o">RefSeq63 Opisthokonta</option>
+                    <option value="refseq89m">RefSeq89 Metazoa</option>
+                    <option value="refseq89f">RefSeq89 Fungi</option>
+                    <option value="refseq89o">RefSeq89 Opisthokonta</option>
+                </param>
+            </when>
+        </conditional>
+    </inputs>
+    <outputs>
+        <data name="out_file" format="data_manager_json" />
+    </outputs>
+    <tests>
+        <test>
+            <conditional name="type_cond">
+                <param name="type_select" value="mitos"/>
+                <param name="database" value="mitos1-refdata"/>
+            </conditional>
+            <output name="out_file" file="mitos_refseq39.json"/>
+        </test>
+    </tests>
+    <help>
+This data manager downloads MITOS and MITOS2 reference data for use in Galaxy.
+
+For MITOS the reference data includes 
+
+- protein data bases derived from RefSeq release 39 (see Bernt et al. 2012)
+- covariance models for tRNAs and rRNAs as described in Jühling et al 2012
+
+Data is downloaded from https://zenodo.org/record/2683856.
+
+For MITOS2 the reference data sets are available for three different taxons
+
+- Metazoa
+- Fungi
+- Opisthokonta
+
+these have been computed for RefSeq release 63 and 89. In addition the reference data 
+for MITOS1 has been converted to be usable in MITOS2.
+contains
+
+The reference data sets contain: 
+
+- protein data bases derived from the corresponding RefSeq release Donath et al. 2019
+- covariance models computed for the data in the RefSeq releas based on the MITOS1 models 
+- in addition for Metazoa Release 63 also hidden markov models are available as described in Al Arab et al. 2017
+
+Data is downloaded from https://zenodo.org/record/3685310.
+    </help>
+    <citations>
+        <citation type="doi">10.1016/j.ympev.2012.08.023</citation>
+        <citation type="doi">10.1093/nar/gkr1131</citation>
+        <citation type="doi">10.1016/j.ympev.2016.09.024</citation>
+        <citation type="doi">10.1093/nar/gkz833</citation>
+    </citations>
+</tool>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml	Fri Mar 27 17:50:23 2020 -0400
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<data_managers>
+    <data_manager tool_file="data_manager/data_manager_mitos.xml" id="mitos_fetcher" version="0.0.1">
+        <data_table name="mitos">
+            <output>
+                <column name="value" />
+                <column name="name" />
+                <column name="type" />
+                <column name="path" output_ref="out_file">
+                    <move type="directory" relativize_symlinks="True">
+                        <source>${path}</source>
+                        <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">mitos/${path}</target>
+                    </move>
+                    <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/mitos/${path}</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/test-data/mitos.loc	Fri Mar 27 17:50:23 2020 -0400
@@ -0,0 +1,4 @@
+mitos1-refdata	RefSeq39 + MiTFi tRNA models	mitos	/tmp/tmpbtwefN/tmpiplugx/tmpydhEfm/database/data_manager_tool-datacoy8bz/mitos/mitos1-refdata
+mitos1-refdata	RefSeq39 + MiTFi tRNA models	mitos	/tmp/tmpGIPfAb/tmpfKzrSO/tmpOaxm5C/database/data_manager_tool-data6ViNKD/mitos/mitos1-refdata
+mitos1-refdata	RefSeq39 + MiTFi tRNA models	mitos	/tmp/tmpoaKkwC/tmprSa8eg/tmpT61Fpn/database/data_manager_tool-data0wohya/mitos/mitos1-refdata
+mitos1-refdata	RefSeq39 + MiTFi tRNA models	mitos	/tmp/tmpo_lErk/tmpzfa6qz/tmpCY3yzt/database/data_manager_tool-dataCMEecR/mitos/mitos1-refdata
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/mitos_refseq39.json	Fri Mar 27 17:50:23 2020 -0400
@@ -0,0 +1,1 @@
+{"data_tables": {"mitos": {"name": "RefSeq39 + MiTFi tRNA models", "path": "mitos1-refdata", "type": "mitos", "value": "mitos1-refdata"}}}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/mitos.loc.sample	Fri Mar 27 17:50:23 2020 -0400
@@ -0,0 +1,8 @@
+# consists of 4 tab separated columns:
+# - value identifier
+# - name the name shown in the tool form
+# - type mitos/mitos2
+# - path the directory containing the reference data
+# 
+# example:
+# mitos1-refdata	RefSeq39 + MiTFi tRNA models	mitos	/tmp/tmpSp4v2Y/tmpR7DRNf/tmp53wbgs/database/data_manager_tool-dataWhw0Ns/mitos/mitos1-refdata
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Fri Mar 27 17:50:23 2020 -0400
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<tables>
+    <!-- Locations of data downloaded for the megan tools -->
+    <table name="mitos" comment_char="#">
+        <columns>value, name, type, path</columns>
+        <file path="tool-data/mitos.loc" />
+    </table>
+</tables>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.test	Fri Mar 27 17:50:23 2020 -0400
@@ -0,0 +1,7 @@
+<tables>
+    <!-- Locations of indexes in the Bowtie2 mapper format -->
+    <table name="mitos" comment_char="#">
+        <columns>value, name, type, path</columns>
+        <file path="${__HERE__}/test-data/mitos.loc" />
+    </table>
+</tables>