view draw_features.xml @ 4:3ba596014675 draft

Uploaded
author greg
date Thu, 02 Mar 2023 15:20:20 +0000
parents fcf01dad2ceb
children c318e520dca1
line wrap: on
line source

<tool id="draw_features" name="PIMA: draw features" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description>of annotated assemblies</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <command detect_errors="exit_code"><![CDATA[
#import re

#if $contigs.is_of_type('fasta.gz'):
    gunzip -c '$contigs' > 'contigs.fasta' &&
#else:
    ln -s '$contigs' 'contigs.fasta' &&
#end if

mkdir feature_hits_dir &&
mkdir output_dir &&

#for $i in $feature_hits:
    #set file_name = $i.file_name
    #set identifier = re.sub('[^\s\w\-\\.]', '_', str($i.element_identifier))
    cat '$i' | awk '$7 != "."' | awk '{OFS="\t";locus=$7"\t"$8"\t"$9; if($5 > s[locus]){s[locus]=$5;id = sprintf("%.3f", $5); b[locus] = $1"\t"$2"\t"$3"\t"$4"\t"id"\t"$6}} END{for(i in b){print b[i]}}' | sort  -k 1,1 -k2,2n > 'feature_hits_dir/$identifier' &&
#end for

python '$__tool_directory__/draw_features.py'
--contigs 'contigs.fasta'
--feature_hits_dir 'feature_hits_dir'
--output_dir 'output_dir'
#if str($output_process_log) == 'yes':
    && mv 'process_log' '$process_log'
#end if
]]></command>
    <inputs>
        <param name="contigs" type="data" format="fasta,fasta.gz" label="Fasta file of assembled contigs"/>
        <param name="feature_hits" format="bed" type="data_collection" collection_type="list" label="Collection of feature hits BED files"/>
        <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>
        <collection name="features_bed" type="list" format="bed" label="${tool.name} on ${on_string} (best bed)">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.(?P&lt;ext&gt;bed)" directory="feature_hits_dir"/>
        </collection>
        <collection name="features_png" type="list" format="png" label="${tool.name} on ${on_string} (png)">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.(?P&lt;ext&gt;png)" directory="output_dir"/>
        </collection>
    </outputs>
    <tests>
        <test>
            <param name="contigs" value="PS01519_contigs.fasta.gz" ftype="fasta.gz"/>
            <param name="feature_hits">
                <collection type="list">
                    <element name="amr_cds.bed" value="amr_cds.bed"/>
                </collection>
            </param>
            <output_collection name="features_bed" type="list" count="1">
                <element name="amr_cds" ftype="bed">
                    <assert_contents>
                        <has_size value="129" delta="10"/>
                    </assert_contents>
                </element>
            </output_collection>
            <output_collection name="features_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 FASTA file of assembled contigs and a collection of 2 BED files containing the feature hits and plots
the features.
    </help>
    <expand macro="citations"/>
</tool>