view draw_amr_matrix.xml @ 4:33a0ea992043 draft

Uploaded
author greg
date Tue, 21 Feb 2023 19:55:42 +0000
parents 9fcc1ffd7526
children 389c98d344ce
line wrap: on
line source

<tool id="draw_amr_matrix" name="PIMA: draw AMR matrix" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description>of genes and drugs</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <command detect_errors="exit_code"><![CDATA[
#import re

mkdir amr_feature_hits_dir &&
mkdir mutations_dir &&
mkdir output_dir &&

#if $reference_source.reference_source_selector == 'history':
    ln -f -s '$reference_source.ref_file' reference.fa &&
#else:
    ln -f -s '$reference_source.ref_file.fields.path' reference.fa &&
#end if

#for $i in $amr_feature_hits:
    #set file_name = $i.file_name
    #set identifier = re.sub('[^\s\w\-\\.]', '_', str($i.element_identifier))
    ln -s '$file_name' 'amr_feature_hits_dir/$identifier' &&
#end for

python '$__tool_directory__/draw_amr_matrix.py'
--amr_feature_hits_dir 'amr_feature_hits_dir'
#if str($amr_deletions_file) != 'None':
    --amr_deletions_file '$amr_deletions_file'
#end if
#if str($amr_mutations_file) != 'None':
    --amr_mutations_file '$amr_mutations_file'
#end if
#if str($amr_mutation_regions_file) != 'None':
    --amr_mutation_regions_file '$amr_mutation_regions_file'
    --region_mutations_output_file '$region_mutations_output_file'
#end if
--amr_gene_drug_file '$amr_gene_drug_file'
--reference_genome reference.fa
--mutations_dir 'mutations_dir'
--output_dir 'output_dir'
#if str($output_process_log) == 'yes':
    && mv 'process_log' '$process_log'
#end if
]]></command>
    <inputs>
        <conditional name="reference_source">
            <param name="reference_source_selector" type="select" label="Select a reference genome from your history or use a cached genome index?">
                <option value="cached">Use a cached genome index</option>
                <option value="history">Select a genome from the history and build the index</option>
            </param>
            <when value="cached">
                <param name="ref_file" type="select" label="Using reference genome" help="Select reference genome">
                    <options from_data_table="all_fasta">
                        <filter type="sort_by" column="2"/>
                        <validator type="no_options" message="No reference genomes are available"/>
                    </options>
                </param>
            </when>
            <when value="history">
                <param name="ref_file" type="data" format="fasta,fastq" label="Select the reference sequence" help="You can upload a FASTA file and use it as reference"/>
            </when>
        </conditional>
        <param argument="--amr_feature_hits" format="bed" type="data_collection" collection_type="list" label="Collection of feature hits BED files"/>
        <param argument="--amr_deletions_file" type="data" format="bed" optional="true" label="AMR deletions file" help="Optional, leave blank to ignore"/>
        <param argument="--amr_mutations_file" type="data" format="tabular,tsv" optional="true" label="AMR mutations file" help="Optional, leave blank to ignore"/>
        <param argument="--amr_mutation_regions_file" type="data" format="bed" optional="true" label="AMR mutation regions BED file" help="Optional, leave blank to ignore"/>
        <param argument="--amr_gene_drug_file" type="data" format="tabular,tsv" label="AMR gene drugs file"/>
        <param name="output_process_log" type="select" display="radio" label="Output process log file?">
            <option value="no" selected="true">No</option>
            <option value="yes">Yes</option>
        </param>
    </inputs>
    <outputs>
        <data name="process_log" format="txt" label="${tool.name} on ${on_string} (process log)">
            <filter>output_process_log == 'yes'</filter>
        </data>
        <data name="region_mutations_output_file" format="tsv" label="${tool.name} on ${on_string} (region mutations)">
            <filter>amr_mutation_regions_file not in [None, 'None']</filter>
        </data>
        <collection name="amr_matrix_png" type="list" format="png">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.(?P&lt;ext&gt;png)" directory="output_dir"/>
        </collection>
    </outputs>
    <tests>
        <test>
            <param name="reference_source_selector" value="history"/>
            <param name="ref_file" ftype="fasta" value="ref_genome.fasta"/>
            <param name="amr_feature_hits">
                <collection type="list">
                    <element name="amr_pima_md.bed" value="amr_pima_md.bed"/>
                </collection>
            </param>
            <param name="amr_gene_drug_file" value="amr_gene_drug.tsv" ftype="tsv"/>
            <output_collection name="amr_matrix_png" type="list" count="1">
                <element name="contig_1" ftype="png">
                    <assert_contents>
                        <has_size value="25383" delta="100"/>
                    </assert_contents>
                </element>
            </output_collection>
        </test>
    </tests>
    <help>
**What it does**

Accepts a collection of best AMR feature hits, an optional AMR deletions BED file, an optional AMR mutations TSV file and a AMR gene
drug mappings file and draws an AMR matrix.
    </help>
    <expand macro="citations"/>
</tool>