view json_db_config_generating.xml @ 3:8eb6c417d4f5 draft

planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
author tduigou
date Mon, 02 Jun 2025 15:10:45 +0000
parents 33ebf3ea3eb6
children
line wrap: on
line source

<tool id="json_db_config_generating" name="JSON DB_Config Generating" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="21.09">
    <description>Genarate a JSON file used as DB config</description>
    <macros>
        <token name="@VERSION_SUFFIX@">2</token>
        <token name="@TOOL_VERSION@">0.1.0</token>
    </macros>
    <command detect_errors="exit_code"><![CDATA[
        python3 -c "import json; params = {
        'execution': '$execution',
        'JSON_db_uri': '$db_uri',
        'JSON_table': '$table_name',
        'JSON_fragment_column': '$fragment_column',
        'JSON_sequence_column': '$sequence_column',
        'JSON_annotation_column': '$annotation_column'
        }; f = open('$output_json', 'w'); json.dump(params, f, indent=4); f.close()" && echo DEBG && cat '$output_json'
    ]]></command>
    <inputs>
        <conditional name="db_request">
            <param name="execution" type="boolean" label="Save To DB ?" checked ='false' help="If True the execution key in the json file will be true" optional="false"/>
            <when value='true'>
                <section name='db_config' title='DB config' expanded='true'>
                    <param name="db_uri" type="text" label="DB Connection URI" optional="true" />
                    <param name="table_name" type="text" label="DB Table Name" optional="true" />
                    <param name="fragment_column" type="text" label="DB IDs Column Name" optional="true" />
                    <param name="sequence_column" type="text" label="DB Column Contains Sequence For ganbank File" optional="true" />
                    <param name="annotation_column" type="text" label="DB Column Contains Annotation For Ganbank File" optional="true" />
                </section>
            </when>
            <when value='false'>
                <section name='db_config' title='DB config' expanded='false'>
                    <param name="db_uri" type="text" label="DB Connection URI" optional="true" />
                    <param name="table_name" type="text" label="DB Table Name" optional="true" />
                    <param name="fragment_column" type="text" label="DB IDs Column Name" optional="true" />
                    <param name="sequence_column" type="text" label="DB Column Contains Sequence For ganbank File" optional="true" />
                    <param name="annotation_column" type="text" label="DB Column Contains Annotation For Ganbank File" optional="true" />
                </section>
            </when>
        </conditional>
    </inputs>   
    <outputs>
        <data name="output_json" format="json" label="JSON Conf" />
    </outputs>
    <tests>
        <!--test execution is true -->
        <test> 
            <conditional name="db_request">
                <param name="execution" value="true" />
                <param name="db_config|db_uri" value="postgresql://postgres:RK17@localhost:5432/test_fragments_db" />
                <param name="db_config|table_name" value="sample" />
                <param name="db_config|fragment_column" value="fragment" />
                <param name="db_config|sequence_column" value="sequence" />
                <param name="db_config|annotation_column" value="annotation" />
            </conditional>
            <output name="output_json">
                <assert_contents>
                    <has_json_property_with_text property="execution" text="true" />
                    <has_json_property_with_text property="JSON_db_uri" text="postgresql://postgres:RK17__at__localhost:5432/test_fragments_db" />
                    <has_json_property_with_text property="JSON_table" text="sample" />
                    <has_json_property_with_text property="JSON_fragment_column" text="fragment" />
                    <has_json_property_with_text property="JSON_sequence_column" text="sequence" />
                    <has_json_property_with_text property="JSON_annotation_column" text="annotation" />
                </assert_contents>
            </output>
        </test>
        <!--test execution is false -->
        <test> 
            <conditional name="db_request">
                <param name="execution" value="false" />
            </conditional>
            <output name="output_json">
                <assert_contents>
                    <has_json_property_with_text property="execution" text="false" />
                    <has_json_property_with_text property="JSON_db_uri" text="" />
                    <has_json_property_with_text property="JSON_table" text="" />
                    <has_json_property_with_text property="JSON_fragment_column" text="" />
                    <has_json_property_with_text property="JSON_sequence_column" text="" />
                    <has_json_property_with_text property="JSON_annotation_column" text="" />
                </assert_contents>
            </output>
        </test>
    </tests>

    <help><![CDATA[
JSON DB_Config Generating
=========================

Generate a JSON file to be used as a DB configuration. This JSON file can later be used to access the database via the specified URI, as well as the defined table and column names.
This tool is primarily designed to control the execution of the save_to_db tool by enabling or disabling its execution and by providing the database configuration through a JSON file.

**Parameters**:
---------------
* **execution key**: The value of execution key in the JSON (true or false)
* **DB Table Name**: Name of the target table in the PostgreSQL database.
* **DB Column Contains Sequence For ganbank File**: Column storing sequence data, expected to start with "ORIGIN". 
* **DB Column Contains Annotation For Ganbank File**: Column containing annotation data, to save al part before "ORIGIN" in the .gb file.
* **DB IDs Column Name**: Column holding the unique fragment IDs.
* **DB Connection URI**: URI used to connect to the database (e.g., postgresql://user:password@host:port/DB_name).
* NOTE: This tool is designed to manage the execution of save_to_db within a workflow. If parameters are set directly in save_to_db via the user interface, the JSON file data will be ignored.
    ]]></help>
    <citations>
        <citation type="bibtex">
            @unpublished{json_db_config_generating
                author = {Ramiz Khaled},
                title = {{json_db_config_generating}},
                url = {https://github.com/brsynth/},
            }
        </citation>
    </citations>
</tool>