changeset 7:6ad04790da12 draft

"planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/microbedb commit 86feecfffe799823fcbae7c56b04d4ef7c87117d"
author brinkmanlab
date Mon, 09 Nov 2020 23:15:23 +0000
parents b7884a377566
children 7c2f036e13a7
files __dbkeys__.loc.sample all_fasta.sql all_fasta.xml builds.sql data_manager_conf.xml tool_data_table_conf.xml.sample
diffstat 6 files changed, 33 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/__dbkeys__.loc.sample	Mon Nov 09 23:15:23 2020 +0000
@@ -0,0 +1,1 @@
+#<unique_build_id>	<display_name>	<file_path_to_len>
\ No newline at end of file
--- a/all_fasta.sql	Mon Nov 09 18:37:30 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-SELECT json_object('data_tables', json_object('all_fasta', json_group_array(json_object('value', unique_build_id, 'dbkey', dbkey, 'name', label, 'path', file_path))))
-FROM (
- SELECT (r.rep_accnum || '.' || r.rep_version)                                           AS unique_build_id,
-        (r.rep_accnum || '_' || r.rep_version)                                           AS dbkey,
-        (REPLACE(r.definition, ', complete genome.', '') || ' [' || r.rep_accnum || '.' || r.rep_version ||
-         ']')                                                                            AS label,
-        (:basepath || '/' || genomeproject.gpv_directory || '/' || genomeproject.filename || '_genomic.fna') AS file_path
- FROM genomeproject
-          JOIN replicon r ON genomeproject.gpv_id = r.gpv_id AND r.rep_type = 'chromosome'
- WHERE genomeproject.version_id = (SELECT version_id FROM version WHERE is_current == 1)
-   AND genomeproject.file_types IS NOT NULL
-   AND genomeproject.file_types LIKE '%.fna%'
-   AND r.rep_type = 'chromosome'
-)
\ No newline at end of file
--- a/all_fasta.xml	Mon Nov 09 18:37:30 2020 +0000
+++ b/all_fasta.xml	Mon Nov 09 23:15:23 2020 +0000
@@ -13,20 +13,33 @@
     </requirements>
     <version_command>sqlite3 --version</version_command>
     <command><![CDATA[
-        #import os.path
-        sqlite3 -readonly $db '.param set :basepath ${os.path.dirname(str($db))}' '.read $__tool_directory__/all_fasta.sql' > '$output'
-        #if $builds
-        && touch $__app__.config.builds_file_path && sqlite3 -readonly $db < '$builds_sql'
-        #end if
+        sqlite3 -readonly '$db' < '$sql' > '$output'
     ]]></command>
     <configfiles>
-        <configfile name="builds_sql"><![CDATA[
-            #include $__tool_directory__+"/builds.sql"
+        <configfile name="sql"><![CDATA[
+            #import os.path
+            SELECT json_object('data_tables',
+                json_object('all_fasta', json_group_array(json_object('value', unique_build_id, 'dbkey', dbkey, 'name', label, 'path', file_path))),
+            #if $builds
+                json_object('__dbkeys__', json_group_array(json_object('value', dbkey, 'name', label, 'len_path', ''))),
+            #end if
+            ) FROM (
+             SELECT (r.rep_accnum || '.' || r.rep_version) AS unique_build_id,
+                    (r.rep_accnum || '_' || r.rep_version) AS dbkey,
+                    (REPLACE(r.definition, ', complete genome.', '') || ' [' || r.rep_accnum || '.' || r.rep_version || ']') AS label,
+                    ('${os.path.dirname(str($db))}/' || genomeproject.gpv_directory || '/' || genomeproject.filename || '_genomic.fna') AS file_path
+             FROM genomeproject
+                      JOIN replicon r ON genomeproject.gpv_id = r.gpv_id AND r.rep_type = 'chromosome'
+             WHERE genomeproject.version_id = (SELECT version_id FROM version WHERE is_current == 1)
+               AND genomeproject.file_types IS NOT NULL
+               AND genomeproject.file_types LIKE '%.fna%'
+               AND r.rep_type = 'chromosome'
+            )
         ]]></configfile>
     </configfiles>
     <inputs>
         <param name="db" type="text" value="/cvmfs/microbedb.brinkmanlab.ca/microbedb.sqlite" label="Path" help="Absolute path to microbedb.sqlite on Galaxy host server"/>
-        <param name="builds" type="boolean" label="Append references to builds" help="Append genomes to Galaxies builds.txt, listing them at /api/genomes"/>
+        <param name="builds" type="boolean" label="Add genomes to __dbkeys__" help="Add genomes to __dbkeys__ table, listing them at /api/genomes"/>
     </inputs>
     <outputs>
         <data name="output" format="data_manager_json" />
--- a/builds.sql	Mon Nov 09 18:37:30 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-DROP TABLE IF EXISTS builds_temp;
-CREATE TEMP TABLE builds_temp(dbkey unique, label);
-.mode csv
-.separator '	'
-.import '$__app__.config.builds_file_path' builds_temp
-INSERT OR REPLACE INTO builds_temp (dbkey, label)
-SELECT (r.rep_accnum || '_' || r.rep_version)                                           AS dbkey,
-    (REPLACE(r.definition, ', complete genome.', '') || ' [' || r.rep_accnum || '.' || r.rep_version ||
-     ']')                                                                            AS label
-FROM genomeproject
-      JOIN replicon r ON genomeproject.gpv_id = r.gpv_id AND r.rep_type = 'chromosome'
-WHERE genomeproject.version_id = (SELECT MAX(version_id) FROM version)
-    AND genomeproject.file_types IS NOT NULL
-    AND genomeproject.file_types LIKE '%.fna%'
-    AND r.rep_type = 'chromosome';
-.mode list
-.separator '	'
-.once '$__app__.config.builds_file_path'
-SELECT dbkey, label FROM builds_temp ORDER BY dbkey;
\ No newline at end of file
--- a/data_manager_conf.xml	Mon Nov 09 18:37:30 2020 +0000
+++ b/data_manager_conf.xml	Mon Nov 09 23:15:23 2020 +0000
@@ -1,16 +1,20 @@
 <?xml version="1.0"?>
 <data_managers>
     <data_manager id="microbedb_all_fasta" tool_file="all_fasta.xml" version="1.0.0">
-        <!-- Defines a Data Table to be modified -->
         <data_table name="all_fasta">
-            <!-- Handle the output of the Data Manager Tool -->
             <output>
-                <!-- Columns that will be specified by the Data Manager Tool -->
                 <column name="value" />
                 <column name="dbkey" />
                 <column name="name" />
                 <column name="path" />
             </output>
         </data_table>
+        <data_table name="__dbkeys__">
+            <output>
+                <column name="value" />
+                <column name="name" />
+                <column name="len_path" />
+            </output>
+        </data_table>
     </data_manager>
 </data_managers>
--- a/tool_data_table_conf.xml.sample	Mon Nov 09 18:37:30 2020 +0000
+++ b/tool_data_table_conf.xml.sample	Mon Nov 09 23:15:23 2020 +0000
@@ -3,4 +3,8 @@
         <columns>value, dbkey, name, path</columns>
         <file path="all_fasta.loc" />
     </table>
+    <table name="__dbkeys__" comment_char="#" allow_duplicate_entries="False">
+        <columns>value, name, len_path</columns>
+        <file path="__dbkeys__.loc" />
+    </table>
 </tables>
\ No newline at end of file