changeset 5:5459ec34767a draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/data_managers/data_manager_funannotate commit 8341270dd36185ebf59d15282bc79f1215e936a4
author iuc
date Fri, 07 Mar 2025 22:33:29 +0000
parents 1c81a82b5b8e
children
files data_manager/extract.py data_manager/funannotate.xml data_manager/funannotate_options.xml data_manager_conf.xml test-data/funannotate.loc test-data/funannotate_options.loc tool-data/funannotate_options.loc.sample tool_data_table_conf.xml.sample tool_data_table_conf.xml.test
diffstat 9 files changed, 142 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/extract.py	Fri Mar 07 22:33:29 2025 +0000
@@ -0,0 +1,49 @@
+import json
+import os
+import sys
+
+fun_db = sys.argv[1]
+fun_db_value = sys.argv[2]
+dmjson = sys.argv[3]
+
+content = []
+# get options for parameter --busco_db
+# which are just the subfolders of the db dir (minus outgroups/ and trained_species/)
+# https://github.com/nextgenusfs/funannotate/blob/8cc40728fee61566fdf736c1f2292e14cc117660/funannotate/predict.py#L319
+for d in os.scandir(fun_db):
+    if not d.is_dir():
+        continue
+    if d.name in ['outgroups', 'trained_species']:
+        continue
+    if not os.path.exists(os.path.join(d, "dataset.cfg")):
+        continue
+    name = d.name.replace("_", " ").capitalize()
+    content.append({'value': d.name, 'name': name, 'select': 'busco_db', 'db_value': fun_db_value})
+
+# --busco_seed_species
+# trained_species
+for d in os.scandir(os.path.join(fun_db, "trained_species")):
+    if not d.is_dir():
+        continue
+    if not os.path.exists(os.path.join(d, "info.json")):
+        continue
+    name = d.name.replace("_", " ").capitalize()
+    content.append({'value': d.name, 'name': name, 'select': 'trained_species', 'db_value': fun_db_value})
+
+# --busco_seed_species
+# outgroups
+for f in os.scandir(os.path.join(fun_db, "outgroups")):
+    if f.is_dir():
+        continue
+    if not f.name.endswith("_buscos.fa"):
+        continue
+    value = f.name[:-10]
+    name = ' - '.join([x.replace("_", " ").capitalize() for x in value.split('.')])
+    content.append({'value': value, 'name': name, 'select': 'outgroup', 'db_value': fun_db_value})
+
+with open(dmjson, "w") as fh:
+    json.dump({"data_tables": {"funannotate_options": content}}, fh)
+
+print(f'{len([c for c in content if c["select"]=="busco_db"])} x busco_db\n')
+print(f'{len([c for c in content if c["select"]=="trained_species"])} x trained_species\n')
+print(f'{len([c for c in content if c["select"]=="outgroup"])} x outgroup\n')
--- a/data_manager/funannotate.xml	Fri Mar 07 22:33:21 2025 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-<tool id="data_manager_funannotate" name="Funannotate data manager" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" tool_type="manage_data" profile="20.01">
-    <macros>
-        <token name="@TOOL_VERSION@">1.8.15</token>
-        <token name="@VERSION_SUFFIX@">0</token>
-    </macros>
-    <requirements>
-        <requirement type="package" version="@TOOL_VERSION@">funannotate</requirement>
-    </requirements>
-    <version_command>funannotate check --show-versions</version_command>
-    <command detect_errors="exit_code"><![CDATA[
-        #if $wget:
-            ## Asked for wget, we assume there's a certificate problem on (at least) one
-            ## of the many requested servers, force disable of all checks
-            echo "check_certificate = off" > \$HOME/.wgetrc &&
-        #end if
-
-        funannotate setup
-            -d '$output_file.extra_files_path'
-        #if $partial_data
-            -i merops -b eukaryota
-        #else
-            -b all
-        #end if
-            $wget
-        &&
-        cp '$dmjson' '$output_file'
-    ]]></command>
-    <configfiles>
-        <configfile name="dmjson"><![CDATA[
-#from datetime import datetime
-#set version_id=datetime.now().strftime("%Y-%m-%d-%H%M%S")
-    {
-      "data_tables":{
-        "funannotate":[
-          {
-            "value":"$version_id",
-            "description":"Funannotate database $version_id",
-            "format_version":"1.0",
-            "path":"$output_file.extra_files_path"
-          }
-        ]
-      }
-    }]]></configfile>
-    </configfiles>
-    <inputs>
-        <param name="partial_data" type="hidden" value="" help="Used for testing"/>
-        <param name="wget" type="boolean" truevalue="--wget" falsevalue="" checked="False" label="Download using wget" help="Try this if you get certificate errors"/>
-    </inputs>
-    <outputs>
-        <data name="output_file" format="data_manager_json"/>
-    </outputs>
-    <tests>
-        <test>
-            <param name="partial_data" value="--partial"/>
-            <output name="output_file">
-                <assert_contents>
-                    <has_text text="Funannotate database "/>
-                    <has_text text='"format_version":"1.0"'/>
-                </assert_contents>
-            </output>
-        </test>
-        <test>
-            <param name="partial_data" value="--partial"/>
-            <param name="wget" value="True"/>
-            <output name="output_file">
-                <assert_contents>
-                    <has_text text="Funannotate database "/>
-                    <has_text text='"format_version":"1.0"'/>
-                </assert_contents>
-            </output>
-        </test>
-    </tests>
-    <help><![CDATA[
-        This data managers fetches data from various databases for the funannotate
-        annotation tool and updates the funannotate data table.
-
-        .. _funannotate: https://funannotate.readthedocs.io
-    ]]></help>
-    <citations>
-        <citation type="doi">10.5281/zenodo.4054262</citation>
-    </citations>
-</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/funannotate_options.xml	Fri Mar 07 22:33:29 2025 +0000
@@ -0,0 +1,61 @@
+<tool id="data_manager_funannotate_options" name="Funannotate options data manager" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" tool_type="manage_data" profile="20.01">
+    <macros>
+        <token name="@TOOL_VERSION@">1.8.15</token>
+        <token name="@VERSION_SUFFIX@">0</token>
+    </macros>
+    <requirements>
+        <requirement type="package" version="@TOOL_VERSION@">funannotate</requirement>
+    </requirements>
+    <version_command>funannotate check --show-versions</version_command>
+    <command detect_errors="exit_code"><![CDATA[
+        #if $test:
+            funannotate setup -d ./test/ -i busco busco_outgroups -b eukaryota > /dev/null &&
+            #set db_path="./test"
+        #else
+            #set db_path=$database.fields.path
+        #end if
+        python '$__tool_directory__/extract.py' '$db_path' '$database' '$output_file'
+    ]]></command>
+    <inputs>
+        <param name="test" type="hidden" value="" help="Used for testing"/>
+        <param name="database" label="Funannotate database" type="select">
+            <options from_data_table="funannotate">
+                <column name="value" index="0" />
+                <column name="name" index="1" />
+                <column name="path" index="3" />
+                <filter type="sort_by" column="0" reverse_sort_order="true"/>
+                <!-- <filter type="static_value" column="2" value="1.0" /> -->
+            </options>
+        </param>
+    </inputs>
+    <outputs>
+        <data name="output_file" format="data_manager_json"/>
+    </outputs>
+    <tests>
+        <test>
+            <param name="test" value="true"/>
+            <param name="database" value="test"/>
+            <output name="output_file">
+                <assert_contents>
+                    <has_text text="busco_db" n="1"/>
+                    <has_text text="outgroup" n="6"/>
+                    <has_text text="trained_species" n="166"/>
+                </assert_contents>
+            </output>
+            <assert_stdout>
+                <has_line line="1 x busco_db"/>
+                <has_line line="166 x trained_species"/>
+                <has_line line="6 x outgroup"/>
+            </assert_stdout>
+        </test>
+    </tests>
+    <help><![CDATA[
+        This data managers determines the options available in the select parameters of the funannotate tool
+        for a given funannotate DB in the funannotate data table
+
+        .. _funannotate: https://funannotate.readthedocs.io
+    ]]></help>
+    <citations>
+        <citation type="doi">10.5281/zenodo.4054262</citation>
+    </citations>
+</tool>
--- a/data_manager_conf.xml	Fri Mar 07 22:33:21 2025 +0000
+++ b/data_manager_conf.xml	Fri Mar 07 22:33:29 2025 +0000
@@ -1,18 +1,12 @@
 <?xml version="1.0"?>
 <data_managers>
-    <data_manager tool_file="data_manager/funannotate.xml" id="data_manager_funannotate">
-        <data_table name="funannotate">
+    <data_manager tool_file="data_manager/funannotate_options.xml" id="data_manager_funannotate_options">
+        <data_table name="funannotate_options">
             <output>
                 <column name="value" />
-                <column name="description" />
-                <column name="format_version" />
-                <column name="path" output_ref="output_file" >
-                    <move type="directory" relativize_symlinks="True">
-                        <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">funannotate/${value}</target>
-                    </move>
-                    <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/funannotate/${value}</value_translation>
-                    <value_translation type="function">abspath</value_translation>
-                </column>
+                <column name="name" />
+                <column name="select" />
+                <column name="db_value"/>
             </output>
         </data_table>
     </data_manager>
--- a/test-data/funannotate.loc	Fri Mar 07 22:33:21 2025 +0000
+++ b/test-data/funannotate.loc	Fri Mar 07 22:33:29 2025 +0000
@@ -7,10 +7,4 @@
 # for example
 # 2021-07-20-120000	Funannotate database 2021-07-20-120000	1.0	/tmp/database/funannotate/2021-07-20-120000
 # 2021-05-27-120000	Funannotate database 2021-05-27-120000	3.0	/tmp/database/funannotate/2021-05-27-120000
-2025-02-17-000000	Funannotate database 2025-02-17-000000		/tmp/tmpm1ezjinx/galaxy-dev/tool-data/funannotate/2025-02-17-000000
-2025-02-17-210445	Funannotate database 2025-02-17-210445		/tmp/tmpg0tuguj6/galaxy-dev/tool-data/funannotate/2025-02-17-210445
-2025-02-17-210504	Funannotate database 2025-02-17-210504		/tmp/tmpg0tuguj6/galaxy-dev/tool-data/funannotate/2025-02-17-210504
-2025-02-17-210714	Funannotate database 2025-02-17-210714	1.0	/tmp/tmpdtjxf3c7/galaxy-dev/tool-data/funannotate/2025-02-17-210714
-2025-02-17-210732	Funannotate database 2025-02-17-210732	1.0	/tmp/tmpdtjxf3c7/galaxy-dev/tool-data/funannotate/2025-02-17-210732
-2025-02-17-211010	Funannotate database 2025-02-17-211010	1.0	/tmp/tmp07fm9fgh/galaxy-dev/tool-data/funannotate/2025-02-17-211010
-2025-02-17-211028	Funannotate database 2025-02-17-211028	1.0	/tmp/tmp07fm9fgh/galaxy-dev/tool-data/funannotate/2025-02-17-211028
+test	Funannotate database Test	1.0	./test/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/funannotate_options.loc	Fri Mar 07 22:33:29 2025 +0000
@@ -0,0 +1,9 @@
+# this is a tab separated file describing options available for selects in the funannotate tool
+# these options are derived separetely for each funannotate DB
+#
+# the columns are:
+# value	name	select	db_value
+#
+# db_value is the ID of the funannotate DB
+# value and name are the value and name to be used
+# select describes the command line parameter / select for which the values can be used
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/funannotate_options.loc.sample	Fri Mar 07 22:33:29 2025 +0000
@@ -0,0 +1,9 @@
+# this is a tab separated file describing options available for selects in the funannotate tool
+# these options are derived separetely for each funannotate DB
+#
+# the columns are:
+# value	name	select	db_value
+#
+# db_value is the ID of the funannotate DB
+# value and name are the value and name to be used
+# select describes the command line parameter / select for which the values can be used
\ No newline at end of file
--- a/tool_data_table_conf.xml.sample	Fri Mar 07 22:33:21 2025 +0000
+++ b/tool_data_table_conf.xml.sample	Fri Mar 07 22:33:29 2025 +0000
@@ -3,4 +3,8 @@
         <columns>value, description, format_version, path</columns>
         <file path="tool-data/funannotate.loc" />
     </table>
+    <table name="funannotate_options" comment_char="#" allow_duplicate_entries="False">
+        <columns>value, name, select, db_value</columns>
+        <file path="tool-data/funannotate_options.loc" />
+    </table>
 </tables>
--- a/tool_data_table_conf.xml.test	Fri Mar 07 22:33:21 2025 +0000
+++ b/tool_data_table_conf.xml.test	Fri Mar 07 22:33:29 2025 +0000
@@ -3,4 +3,8 @@
         <columns>value, description, format_version, path</columns>
         <file path="${__HERE__}/test-data/funannotate.loc" />
     </table>
+    <table name="funannotate_options" comment_char="#" allow_duplicate_entries="False">
+        <columns>value, name, select, db_value</columns>
+        <file path="${__HERE__}/test-data/funannotate_options.loc" />
+    </table>
 </tables>