view draw_amr_matrix.xml @ 14:c5e80637cf3d draft

Uploaded
author greg
date Tue, 28 Mar 2023 13:42:30 +0000
parents b1a7e04e6371
children 487a3c008812
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 mutation_regions_dir &&
mkdir amr_matrix_png_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($varscan_vcf_file) != 'None':
    --varscan_vcf_file '$varscan_vcf_file'
#end if
#if str($amr_mutation_regions_bed_file) != 'None':
    --amr_mutation_regions_bed_file '$amr_mutation_regions_bed_file'
    --mutation_regions_dir 'mutation_regions_dir'
#end if
--amr_gene_drug_file '$amr_gene_drug_file'
--reference_genome reference.fa
--amr_matrix_png_dir 'amr_matrix_png_dir'
--errors '$errors'
--in_test_mode '$in_test_mode'
#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="--varscan_vcf_file" type="data" format="vcf" optional="true" label="Varscan VCF file" help="Optional, leave blank to ignore"/>
        <param argument="--amr_mutation_regions_bed_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>
        <param name="in_test_mode" type="hidden" value="false"/>
    </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="errors" format="txt" label="${tool.name} on ${on_string} (errors)"/>
        <collection name="mutation_regions_tsv" type="list" format="tsv" label="${tool.name} on ${on_string} (mutation regions)">
            <filter>amr_mutation_regions_bed_file not in [None, 'None']</filter>
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.(?P&lt;ext&gt;tsv)" directory="mutation_regions_dir"/>
        </collection>
        <collection name="amr_matrix_png" type="list" format="png">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.(?P&lt;ext&gt;png)" directory="amr_matrix_png_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" value="amr_pima_md.bed"/>
                </collection>
            </param>
            <param name="varscan_vcf_file" value="varscan.vcf" ftype="vcf"/>
            <param name="amr_mutation_regions_bed_file" value="amr_mutation_regions.bed" ftype="bed"/>
            <param name="amr_gene_drug_file" value="amr_gene_drug.tsv" ftype="tsv"/>
            <param name="in_test_mode" value="true"/>
            <output_collection name="amr_matrix_png" type="list" count="1">
                <element name="amr_matrix" ftype="png">
                    <assert_contents>
                        <has_size value="28798" delta="1000"/>
                    </assert_contents>
                </element>
            </output_collection>
            <output name="errors" value="errors.txt" ftype="txt"/>
        </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>