diff save_to_db.xml @ 4:c7a7520afb4b draft

planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
author tduigou
date Mon, 02 Jun 2025 09:48:14 +0000
parents eca0d710bbe9
children f934215bdb78
line wrap: on
line diff
--- a/save_to_db.xml	Fri May 23 08:51:50 2025 +0000
+++ b/save_to_db.xml	Mon Jun 02 09:48:14 2025 +0000
@@ -1,8 +1,8 @@
 <tool id="save_to_db" name="Save Data To DB" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="21.09">
     <description>Save data to SQL DB</description>
     <macros>
-        <token name="@VERSION_SUFFIX@">1</token>
-        <token name="@TOOL_VERSION@">0.1.0</token>
+        <token name="@VERSION_SUFFIX@">2</token>
+        <token name="@TOOL_VERSION@">0.2.0</token>
     </macros>
     <requirements>
         <requirement type="package" version="2.2.3">pandas</requirement>
@@ -21,21 +21,25 @@
             --fragment_column '$fragment_column'
             --output '$output'
             --file_name_mapping '$file_name_mapping'
+            --json_conf '$json_conf'
     ]]></command>
     <inputs>
         <param name="genbank_files" type="data_collection" collection_type="list" format="genbank" label="GenBank File(s)"/>
-        <param name="table" type="text" label="DB Table Name" optional="false" />
-        <param name="sequence_column" type="text" label="DB Column Contains Sequence For ganbank File" optional="false" />
-        <param name="annotation_column" type="text" label="DB Column Contains Annotation For Ganbank File" optional="false" />
-        <param name="fragment_column" type="text" label="DB IDs Column Name" optional="false" />
-        <param name="db_uri" type="text" label="DB Connection URI" help="postgresql+psycopg2://username:password@db_container_name:port/database" optional="false" />
+        <param name="table" type="text" label="DB Table Name" optional="true" help="It can be extracted from JSON file -key:'JSON_table'-" />
+        <param name="sequence_column" type="text" label="DB Column Contains Sequence For ganbank File" optional="true" help="It can be extracted from JSON file -key:'JSON_sequence_column'-" />
+        <param name="annotation_column" type="text" label="DB Column Contains Annotation For Ganbank File" optional="true" help="It can be extracted from JSON file -key:'JSON_annotation_column'-" />
+        <param name="fragment_column" type="text" label="DB IDs Column Name" optional="true" help="It can be extracted from JSON file -key:'JSON_fragment_column'-" />
+        <param name="db_uri" type="text" label="DB Connection URI" help="postgresql+psycopg2://username:password@db_container_name:port/database (It can be extracted from JSON file -key:'JSON_db_uri'-)" optional="true" />
+        <section name='adv' title='Advance' expanded='false'>
+            <param name="json_conf" type="data" format='json' label="DB config as a json file" help="JSON file specifying the database URI, table name and the column names for annotation and sequence data" optional="true" />
+        </section>
     </inputs>   
     <outputs>
         <data name="output" format="txt" label="saving report" />
     </outputs>
     <tests>
-    <!--python save_to_db.py -input 'test-data/p7_L7Ae-Weiss.gb,test-data/p6_Nt-IgKLsequence.gb,test-data/p6_Kozak-ATG.gb,test-data/p4_Kt-L7Ae-Weiss.gb,test-data/HC_Amp_ccdB.gb' -sequence_column 'sequence' -annotation_column 'annotation' -db_uri 'postgresql://postgres:RK17@localhost:5432/test_fragments_db' -table 'sample' -fragment_column 'fragment' -output 'test-data/test_raport.txt'
-    but it will not work as there is an extra param '-file_name_mapping' that are generated by galaxy and contain the dict for 'file.dat:fragment name' to stock the fragment name from file name thus use planemo with debug to test -->
+    <!--Only 1 test can be execute because the fragment will be already saved for the second test and it will return error as the fragments are present in the DB (execut ../get_db_data/testMock.py to regenerate initial DB)-->
+        <!--test DB config in the tool -->
         <test> 
             <param name="genbank_files">
                 <collection type="list">
@@ -62,6 +66,29 @@
                 </assert_contents>
             </output>
         </test>
+        <!--test DB config from JSON -->
+        <test> 
+            <param name="genbank_files">
+                <collection type="list">
+                    <element name="p7_L7Ae-Weiss" value="p7_L7Ae-Weiss.gb" />
+                    <element name="p7_gfp_sequence" value="p6_Nt-IgKLsequence.gb" />
+                    <element name="p14_CMVp" value="p6_Kozak-ATG.gb" />
+                    <element name="p16_bGHpolyA" value="p4_Kt-L7Ae-Weiss.gb" />
+                    <element name="p18_CMVp" value="HC_Amp_ccdB.gb" />
+                </collection>
+            </param>
+            <param name="adv|json_conf" value="test-JSON_arg.json" />
+            <output name="output" file="test_raport.txt" ftype="txt" >
+                <assert_contents>
+                     <has_n_lines n="5" />
+                     <has_line_matching expression="p7_L7Ae-Weiss" />
+                     <has_line_matching expression="p6_Nt-IgKLsequence" />
+                     <has_line_matching expression="p6_Kozak-ATG" />
+                     <has_line_matching expression="p4_Kt-L7Ae-Weiss" />
+                     <has_line_matching expression="HC_Amp_ccdB" />
+                </assert_contents>
+            </output>
+        </test>
     </tests>
     
     <help><![CDATA[