changeset 0:aec9bc48cdb7 draft

"planemo upload for repository https://github.com/blankenberglab/galaxy-tools-blankenberg/tree/master/data_managers/data_manager_refgenie_pull commit da4cbfcb158b1cf283c5736434fa88b645783306"
author blankenberglab
date Fri, 10 Sep 2021 12:56:54 +0000
parents
children 43d2baff05cd
files data_manager/data_manager_refgenie_pull.py data_manager/data_manager_refgenie_pull.xml data_manager/macros.xml data_manager_conf.xml tool_data_table_conf.xml.sample tool_data_table_conf.xml.test
diffstat 6 files changed, 126 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/data_manager_refgenie_pull.py	Fri Sep 10 12:56:54 2021 +0000
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+
+import argparse
+import logging
+from base64 import urlsafe_b64encode
+from urllib.parse import urljoin
+
+import refgenconf
+import requests
+
+
+log = logging.getLogger("tools.iuc.data_managers.data_manager_refgenie_pull")
+
+
+def galaxy_code_get_refgenie_assets(refgenie_config_file):
+    rgc = refgenconf.RefGenConf(refgenie_config_file)
+    rval = []
+    for urlname, genomes in rgc.listr().items():
+        urlname_64 = urlsafe_b64encode(bytes(urlname, 'utf8')).decode('utf8')
+        ul = []
+        for genome, assets in genomes.items():
+            al = []
+            for name in assets:
+                al.append({'name': name, 'value': '%s/%s/%s' % (urlname_64, genome, name), 'options': [], 'selected': False})
+            ul.append({'name': genome, 'value': genome, 'options': al, 'selected': False})
+        rval.append({'name': urlname, 'value': urlname_64, 'options': ul, 'selected': False})
+    return rval
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-n', '--names', dest='names', action='store', default=None, help='Table names to reload')
+    parser.add_argument('-u', '--url', dest='url', action='store', default=None, help='Base url for reload')
+    parser.add_argument('-k', '--key', dest='key', action='store', default=None, help='Galaxy API Key')
+
+    args = parser.parse_args()
+    if not args.names:
+        tables = requests.get(urljoin(args.url, "api/tool_data"), params={'key': args.key}).json()
+        args.names = [d.get('name') for d in tables]
+    for name in args.names:
+        print(requests.get(urljoin(args.url, "api/tool_data/%s/reload" % (name)), params={'key': args.key}).json())
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/data_manager_refgenie_pull.xml	Fri Sep 10 12:56:54 2021 +0000
@@ -0,0 +1,69 @@
+<tool id="data_manager_refgenie_pull" name="refgenie asset pulling" version="@VERSION@" tool_type="manage_data" profile="20.05">
+    <description>from remote resource</description>
+    <macros>
+        <import>macros.xml</import>
+    </macros>
+    <requirements>
+        <requirement type="package" version="@VERSION@">refgenie</requirement>
+    </requirements>
+    <code file="data_manager_refgenie_pull.py" />
+    <environment_variables>
+        <environment_variable name="API_KEY" inject="api_key" />
+    </environment_variables>
+    <command detect_errors="exit_code"><![CDATA[
+       #for $asset in $assets:
+         #set ga = str($asset).split('/',2)
+         refgenie pull -c '$__app__.config.refgenie_config_file' -g '$ga[1]' '$ga[2]' $force >> '${out_log}' 2>&1
+         &&
+       #end for
+       echo '{}' > '${out_file}'
+       #if $api_refresh:
+         && python '${__tool_directory__}/data_manager_refgenie_pull.py' -k "\$API_KEY" -u '${__galaxy_url__}' >> '${out_log}'
+       #end if
+    ]]></command>
+    <inputs>
+        <param argument="--assets" name="assets" type="drill_down" display="checkbox" hierarchy="exact" multiple="True" optional="False" label="Select desired asset" dynamic_options="galaxy_code_get_refgenie_assets(__trans__.app.config.refgenie_config_file)" help="string of asset-registry-paths">
+            <validator type="regex" message="You must select an asset, not the remote URL or genome.">.+/.+/.+</validator>
+        </param>
+        <param argument="--force" name="force" type="boolean" truevalue="--force" falsevalue="" checked="False" label="Force (re-)download" />
+        <param argument="--api_refresh" name="api_refresh" type="boolean" truevalue="--api_refresh" falsevalue="" checked="True" label="Refresh Galaxy data tables using API" />
+    </inputs>
+    <outputs>
+        <data name="out_file" format="data_manager_json"/>
+        <data name="out_log" format="txt"/>
+    </outputs>
+    <tests>
+        <test>
+            <param name="assets" value="aHR0cDovL3JlZmdlbm9tZXMuZGF0YWJpby5vcmcvdjIvYXNzZXRz/t7/fasta:default"/>
+            <param name="force" value="--force"/>
+            <param name="api_refresh" value=""/>
+            <output name="out_file">
+                <assert_contents>
+                    <has_text text="{}"/>
+                </assert_contents>
+            </output>
+            <output name="out_log">
+                <assert_contents>
+                    <has_text text="Download complete"/>
+                </assert_contents>
+            </output>
+        </test>
+    </tests>
+    <help><![CDATA[
+**What it does**
+
+Fetches a reference genome using refgenie (http://refgenie.databio.org).
+
+.. class:: infomark
+
+**Notice:** Galaxy data tables will be refreshed using API calls.
+
+.. class:: warning
+
+**You must configure Galaxy to use refgenie, by setting 'refgenie_config_file' in the Galaxy config. This tool uses refgenie config file version 0.3.**
+    ]]></help>
+    <citations>
+        <citation type="doi">10.1093/gigascience/giz149</citation>
+        <citation type="doi">10.1101/2020.10.09.327114</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/macros.xml	Fri Sep 10 12:56:54 2021 +0000
@@ -0,0 +1,4 @@
+<macros>
+    <token name="@VERSION@">0.9.1</token>
+</macros>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml	Fri Sep 10 12:56:54 2021 +0000
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<data_managers>
+    <data_manager tool_file="data_manager/data_manager_refgenie_pull.xml" id="refgenie_pull" undeclared_tables="True">
+    </data_manager>
+</data_managers>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Fri Sep 10 12:56:54 2021 +0000
@@ -0,0 +1,3 @@
+<tables>
+    <!-- None for default sample -->
+</tables>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.test	Fri Sep 10 12:56:54 2021 +0000
@@ -0,0 +1,3 @@
+<tables>
+    <!-- None for default test -->
+</tables>