view blobtoolkit.xml @ 1:840822c1e84a draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/blobtoolkit commit 797eb67eae4dfe502325c53f78824c5ba4033955
author bgruening
date Mon, 20 Mar 2023 16:37:54 +0000
parents 7d9ee8cd14b8
children 53dd00a4ab68
line wrap: on
line source

<tool id="blobtoolkit" name="BlobToolKit" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="21.05">
    <description>genome assembly QC</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro='requirements' />
    <command detect_errors="exit_code"><![CDATA[
        #if $mode_conditional.selector == 'create'
            mkdir -p './Blobdir' &&
            mkdir -p './taxdump' &&
            ln -s '${mode_conditional.taxdump}' 'taxdump.tar' &&
            tar -xf 'taxdump.tar' -C './taxdump' &&
            ln -s '${mode_conditional.fasta}' 'assembly.fasta' &&
            #if $mode_conditional.meta
                ln -s '${mode_conditional.meta}' 'assembly.yaml' &&
            #end if
            blobtools create
            --fasta 'assembly.fasta'
            #if $mode_conditional.meta
                --meta 'assembly.yaml'
            #end if
            --taxid $mode_conditional.taxid
            --taxdump './taxdump'
            './Blobdir'
            && cp -r './taxdump' './Blobdir/'
            && tar -zcf './Blobdir.tgz' './Blobdir'

        #else if $mode_conditional.selector == 'add'
            #if $mode_conditional.blobdir.is_of_type("tgz")
                tar -zxf '${mode_conditional.blobdir}' -C './' &&
            #else
                tar -xf '${mode_conditional.blobdir}' -C './' &&
            #end if
            #if $mode_conditional.busco
                ln -s '${mode_conditional.busco}' './busco_results.tab' && 
            #end if
            #if $mode_conditional.blast_input.selector == 'enabled'
                ln -s '$mode_conditional.blast_input.hits' './blast_results.tab' &&
            #end if
            #if $mode_conditional.cov
                ln -s '$mode_conditional.cov' './input.bam' &&
            #end if
            #if $mode_conditional.bed
                    mkdir -p './bed_files' &&
                    #import re
                    #for $i, $input in enumerate($mode_conditional.bed):
                        #set $safename = re.sub('[^\w\-_]', '_', $input.element_identifier) + "." + str($i)
                        ln -sf '${input}' './bed_files/${safename}.bed' &&
                    #end for
            #end if
            blobtools add
                --threads \${GALAXY_SLOTS:-8}
                --taxdump './Blobdir/taxdump'
                #if $mode_conditional.busco
                    --busco './busco_results.tab'
                #end if
                #if $mode_conditional.blast_input.selector == 'enabled'
                    --hits './blast_results.tab'
                    #if $mode_conditional.blast_input.hits_cols
                        --hits-cols '${$mode_conditional.blast_input.hits_cols}'
                    #end if
                    --taxrule $mode_conditional.blast_input.taxrule
                    --evalue $mode_conditional.blast_input.evalue
                    --hit-count $mode_conditional.blast_input.hit_count
                    --bitscore $mode_conditional.blast_input.bitscore
                #end if
                #if $mode_conditional.bed
                    --beddir './bed_files'
                #end if
                #if $mode_conditional.cov
                    --cov './input.bam'
                #end if
                #if $mode_conditional.fasta
                    --fasta '${mode_conditional.fasta}'
                #end if
                #if $mode_conditional.trnascan
                    --trnascan '${mode_conditional.trnascan}'
                #end if
                #if $mode_conditional.text_input.selector == 'enabled'
                    --text '${mode_conditional.text_input.text}'
                    --text-cols '${mode_conditional.text_input.text_cols}'
                    $mode_conditional.text_input.text_header
                    $mode_conditional.text_input.text_no_array
                    --text-delimiter $mode_conditional.text_input.text_delimiter
                #end if
                #if $mode_conditional.advanced_options.blobdb
                    --blobdb '${mode_conditional.advanced_options.blobdb}'
                #end if
                #if $mode_conditional.advanced_options.synonyms
                    --synonyms '${mode_conditional.advanced_options.synonyms}'
                #end if
                $mode_conditional.advanced_options.update_plot
                #if $mode_conditional.advanced_options.pileup_args
                    --pileup-args '${mode_conditional.advanced_options.pileup_args}'
                #end if
                $mode_conditional.advanced_options.replace
                './Blobdir'
            && tar -zcf './Blobdir.tgz' './Blobdir'

        #else if $mode_conditional.selector == 'filter'
            #if $mode_conditional.filter_options.list
                    echo $mode_conditional.filter_options.list > id_list.txt &&
            #end if
            #if $mode_conditional.blobdir.is_of_type("tgz")
                tar -zxf '${mode_conditional.blobdir}' -C './' &&
            #else
                tar -xf '${mode_conditional.blobdir}' -C './' &&
            #end if            
            #if $mode_conditional.filter_options.fasta
                ln -s '${mode_conditional.filter_options.fasta}' './input.fasta' &&
            #end if
            #if $mode_conditional.filter_options.fastq_filter.selector == 'enabled'
                ln -s '${mode_conditional.filter_options.fastq_filter.fastq}' './input.fastq' &&
                ln -s '$mode_conditional.filter_options.fastq_filter.cov' './input.bam' &&
            #end if
            blobtools filter
            #if $mode_conditional.filter_options.param
                --param $mode_conditional.filter_options.param
            #end if
            #if $mode_conditional.filter_options.json
                --json $mode_conditional.filter_options.json
            #end if
            #if $mode_conditional.filter_options.list
                --list id_list.txt
            #end if
            $mode_conditional.filter_options.invert
            #if $mode_conditional.filter_options.fasta
                --fasta './input.fasta'
            #end if
            #if $mode_conditional.filter_options.fastq_filter.selector == 'enabled'
                --fastq './input.fastq'
                --cov './input.bam'
            #end if
            #if $mode_conditional.filter_options.text_input.selector == 'enabled'
                --text '${mode_conditional.filter_options.text_input.text}'
                --text-cols '${mode_conditional.filter_options.text_input.text_cols}'
                $mode_conditional.filter_options.text_input.text_header
                --text-delimiter $mode_conditional.filter_options.text_input.text_delimiter
            #end if
            ./Blobdir
            #if $mode_conditional.remove_options.remove_selector or $mode_conditional.remove_options.field
                && blobtools remove
                #for $param in $mode_conditional.remove_options.remove_selector
                    $param
                #end for 
                #if $mode_conditional.remove_options.field
                    --field $mode_conditional.remove_options.field
                #end if
                ./Blobdir
            #end if
            && tar -zcf './Blobdir.tgz' './Blobdir'

        #else if $mode_conditional.selector == 'plots'
            #if $mode_conditional.blobdir.is_of_type("tgz")
                tar -zxf '${mode_conditional.blobdir}' -C './' &&
            #else
                tar -xf '${mode_conditional.blobdir}' -C './' &&
            #end if            
            blobtools view
            --format $mode_conditional.format
            --view 'blob'
            ./Blobdir
            && mv ./Blobdir.blob.circle* ./Blobdir.blob.circle
            && blobtools view
            --format $mode_conditional.format
            --view 'cumulative'
            ./Blobdir
            && mv ./Blobdir.cumulative* Blobdir.cumulative
            && blobtools view
            --format $mode_conditional.format
            --view 'snail'
            ./Blobdir
            && mv ./Blobdir.snail* Blobdir.snail
        #end if
    ]]></command>
    <inputs>
        <conditional name="mode_conditional">
            <param name="selector" type="select" label="Select mode" help="Select a BlobToolKit module">
                <option value="create">Create a BlobToolKit dataset</option>
                <option value="add">Add data to a BlobToolKit dataset</option>
                <option value="filter">Edit a BlobToolKit dataset</option>
                <option value="plots">Generate plots</option>
            </param>
            <when value="create">
                <param argument="--fasta" type="data" format="fasta" label="Genome assembly file" help="FASTA sequence file" />
                <param argument="--meta" type="data" format="yaml" label="Metadata file" optional="true" help="Optional metadata dataset"/>
                <param argument="--taxid" type="integer" value="" label="NCBI taxonomy ID" help="Add ranks to metadata for a taxid"/>
                <param argument="--taxdump" type="data" format="tar,tgz,gz" label="NCBI taxdump directory" help="It should be compressed in tar.gz format"/>
            </when>
            <when value="add">
                <param name="blobdir" type="data" format="tgz" label="Blobdir.tgz file" help="This file should be generated by Blobtool create" />
                <param argument="--busco" type="data" format="tsv,tabular,txt" optional="true" label="BUSCO full table file"/>
                <conditional name="blast_input">
                    <param name="selector" type="select" label="BLAST/Diamond hits">
                        <option value="enabled">Enabled</option>
                        <option value="disabled" selected="true">Disabled</option>
                    </param>
                    <when value="enabled">
                        <param argument="--hits" type="data" format="tsv,tabular" optional="true" label="BLAST/Diamond hits dataset" help="Tabular BLAST/Diamond output file"/>
                        <param argument="--taxrule" type="select" label="BLAST hits to taxa rule" help="Rule to use when assigning BLAST hits to taxa">
                            <option value="bestsum">Bestsum</option>
                            <option value="bestsumorder">Bestsumorder</option>
                            <option value="bestdistsum">Bestdistsum</option>
                            <option value="bestdistsumorder">Bestdistsumorder</option>
                            <option value="blastp">Blastp</option>
                        </param>              
                        <param argument="--evalue" type="float" min="0" value="1" label="E-value cutoff"
                            help="The smaller the E-value, the better the match. Any hits with an evalue weaker than the value specified will be excluded"/>
                        <param argument="--bitscore" type="float" min="0" value="1" label="Bitscore cutoff" 
                            help="The higher the bit-score, the better the sequence similarity. Any hits with an bitscore lower the value specified will be excluded"/>
                        <param argument="--hit-count" type="integer" min="1" value="10" label="Hits to a given taxon" optional="true" 
                            help="By default the 10 highest scoring hits to a given taxon will be used when applying the --taxrule"/>
                        <param argument="--hits-cols" type="text" value="1=qseqid,2=staxids,3=bitscore,5=sseqid,10=qstart,11=qend,14=evalue" optional="true" 
                            label="BLAST/Diamond file column order" help="More information in the help section">
                            <sanitizer invalid_char="">
                                <valid initial="string.letters,string.digits">
                                    <add value="=" />
                                    <add value="," />
                                </valid>
                            </sanitizer>
                            <validator type="regex">[0-9a-z=,]+</validator>
                        </param>
                    </when>
                    <when value="disabled"/>
                </conditional>
                <param argument="--bed" type="data" format="bed" multiple="true" optional="true" label="BED file of coverages per scaffold"/>
                <param argument="--cov" type="data" format="bam,sam,cram" optional="true" label="BAM/SAM/CRAM read alignment file"/>
                <param argument="--fasta" type="data" format="fasta" optional="true" label="FASTA sequence" help="FASTA sequence file" />
                <param argument="--trnascan" type="data" format="tsv,tabular" optional="true" label="tRNAscan2-SE" help="tRNAscan-SE is employed for identifying and annotating tRNA genes in genomes"/>
                <expand macro="macro_text_input">
                    <param argument="--text-no-array" type="boolean" truevalue="--text-no-array" falsevalue="" checked="false" label="Prevent duplicated identifiers" 
                        help="Prevent fields in files with duplicate identifiers being loaded as array fields" />
                </expand>
                <section name="advanced_options" title="Advanced options">
                    <param argument="--blobdb" type="data" format="json" optional="true" label="Blobtools v1 database" help="This file should have been generated with the previous Blobtools tool version"/>
                    <param argument="--synonyms" type="data" format="tsv" optional="true" label="Identifier and sinonyms" help="TSV file containing current identifiers and synonyms"/>
                    <param argument="--update-plot" type="boolean" truevalue="--update-plot" falsevalue="" checked="false" label="Update plot" help="Flag to use new taxrule as default category" />
                    <param argument="--pileup-args" type="text" value="" optional="true" label="Samtools Pileup" help="Key/value pairs to pass to samtools pileup">
                        <sanitizer invalid_char="">
                            <valid initial="string.letters,string.digits">
                                <add value="=" />
                                <add value="," />
                                <add value="-" />
                            </valid>
                        </sanitizer>
                        <validator type="regex">[0-9a-zA-Z=,-]+</validator>
                    </param>
                    <param argument="--replace" type="boolean" truevalue="--replace" falsevalue="" checked="false" label="Replace fields" help="Allow existing fields to be overwritten" />
                </section>
            </when>
            <when value="filter">
                <param name="blobdir" type="data" format="tgz" label="Blobdir file" help="This file should be generated by the moudule create" />
                <section name="filter_options" title="Filter mode options" expanded="true">
                    <param argument="--param" type="text" value="" optional="true" label="Parameter value" help="String of type param=value. Individual param=value pairs can be specified to 
                        filter based on Variable or Category fields">
                        <sanitizer invalid_char="">
                            <valid initial="string.letters,string.digits">
                                <add value="=" />
                                <add value="," />
                                <add value="-" />
                            </valid>
                        </sanitizer>
                        <validator type="regex">[0-9a-zA-Z=,-]+</validator>
                    </param>
                    <param argument="--list" type="text" value="" optional="true" label="List of identifiers" help="Space separated list of identifiers">
                        <sanitizer invalid_char="">
                            <valid initial="string.letters,string.digits">
                                <add value=" " />
                                <add value="-" />
                                <add value="_" />
                            </valid>
                        </sanitizer>
                        <validator type="regex">[0-9a-zA-Z _-]+</validator>
                    </param>
                    <param argument="--json" type="data" format="json" optional="true" label="JSON format list file" help="JSON format list file as generated by BlobtoolKit Viewer"/>
                    <param argument="--fasta" type="data" format="fasta" multiple="true" optional="true" label="Assembly to be filtered" help="FASTA format assembly file to be filtered"/>
                    <conditional name="fastq_filter">
                        <param name="selector" type="select" label="Filter FASTQ reads">
                            <option value="disabled">Disabled</option>
                            <option value="enabled">Enabled</option>
                        </param>
                        <when value="disabled"/>
                        <when value="enabled">
                            <param argument="--fastq" type="data" format="fastq" optional="true" label="Reads to be filtered" help="FASTQ format read file to be filtered"/>
                            <param argument="--cov" type="data" format="bam,sam,cram" optional="true" label="BAM/SAM/CRAM read alignment file" />
                        </when>
                    </conditional>
                    <expand macro="macro_text_input"/>
                    <param argument="--summary-rank" type="text" value="phylum" label="Sumamry rank" help="Taxonomic level for summary">
                        <sanitizer invalid_char="">
                            <valid initial="string.letters"/>
                        </sanitizer>
                        <validator type="regex">[a-zA-Z]+</validator>
                    </param>
                    <param argument="--invert" type="boolean" truevalue="--invert" falsevalue="" checked="false" label="Invert filter" help="Invert the filter (exclude matching records)"/>
                </section>
                <section name="remove_options" title="Remove mode options" expanded="true">
                    <param name="remove_selector" type="select" multiple="true" display="checkboxes" label="Fields to remove">
                        <option value="--all">Remove all fields except identifiers (--all)</option>
                        <option value="--busco">Remove all BUSCO fields (--busco)</option>
                        <option value="--cov">Remove all cov and read_cov fields (--cov)</option>
                        <option value="--fasta">Remove gc, length and ncount fields (--fasta)</option>
                        <option value="--hits">Remove all taxonomy fields (--hits)</option>
                    </param>
                    <param argument="--field" type="text" value="" optional="true" label="Remove fields by ID">
                        <sanitizer invalid_char="">
                            <valid initial="string.letters,string.digits"/>
                        </sanitizer>
                        <validator type="regex">[0-9a-zA-Z]+</validator>
                    </param>
                </section>
            </when>
            <when value="plots">
                <param name="blobdir" type="data" format="tgz" label="Blobdir file" help="This file should be generated by the moudule create" />
                <param argument="--format" type="select" label="Image format">
                    <option value="png">PNG</option>
                    <option value="svg">SVG</option>
                </param>
                <param argument="--param" type="text" optional="true" label="Query parameter" help="Query string parameter."/>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="blobdir" format="tgz" from_work_dir="./Blobdir.tgz" label="${tool.name} on ${on_string}: Blobdir.tgz">
            <filter>mode_conditional['selector'] == 'create' or mode_conditional['selector'] == 'add' or mode_conditional['selector'] == 'filter'</filter>
        </data>
        <data name="plot_circle" format="png" from_work_dir="./Blobdir.blob.circle" label="${tool.name} on ${on_string}: blob plot">
            <filter>mode_conditional['selector'] == 'plots'</filter>
            <change_format>
                <when input="$mode_conditional.format" value="svg" format="svg"/>
            </change_format>
        </data>
        <data name="plot_cumulative" format="png" from_work_dir="./Blobdir.cumulative" label="${tool.name} on ${on_string}: cumulative plot">
            <filter>mode_conditional['selector'] == 'plots'</filter>
            <change_format>
                <when input="$mode_conditional.format" value="svg" format="svg"/>
            </change_format>
        </data>
        <data name="plot_snail" format="png" from_work_dir="./Blobdir.snail" label="${tool.name} on ${on_string}: snail plot">
            <filter>mode_conditional['selector'] == 'plots'</filter>
            <change_format>
                <when input="$mode_conditional.format" value="svg" format="svg"/>
            </change_format>
        </data>
    </outputs>
    <tests>
        <test expect_num_outputs="1">
            <conditional name="mode_conditional">
                <param name="selector" value="create"/>
                <param name="fasta" value="assembly.fasta.gz"/>
                <param name="meta" value="assembly.yaml"/>
                <param name="taxid" value="801"/>
                <param name="taxdump" value="small_taxdump.tar.gz"/>
            </conditional>
            <output name="blobdir" file="test01_blobdir.tar.gz" compare="sim_size" delta="1500"/>
        </test>
        <test expect_num_outputs="1">
            <conditional name="mode_conditional">
                <param name="selector" value="add"/>
                <param name="blobdir" value="test01_blobdir.tar.gz"/>
                <param name="busco" value="busco_full_table.tabular"/>
                <param name="cov" value="bam_file.bam"/>
                <param name="fasta" value="contig.fasta"/>
                <section name="advanced_options">
                    <param name="update_plot" value="false"/>
                </section>
                <conditional name="blast_input">
                    <param name="selector" value="enabled"/>
                    <param name="hits" value="blast_results.tabular"/>
                    <param name="taxrule" value="bestsum"/>
                    <param name="evalue" value="1"/>
                    <param name="bitscore" value="1"/>
                    <param name="hit_count" value="10"/>
                    <param name="hits_cols" value="1=qseqid,2=staxids,3=bitscore,5=sseqid,10=qstart,11=qend,14=evalue"/>
                </conditional>
            </conditional>
            <output name="blobdir" file="test02_blobdir.tar.gz"  compare="sim_size" delta="1500"/>
        </test>
        <test expect_num_outputs="1">
            <conditional name="mode_conditional">
                <param name="selector" value="filter"/>
                <param name="blobdir" value="test02_blobdir.tar.gz"/>
                <section name="filter_options">
                    <param name="fasta" value="contig.fasta"/>
                    <param name="summary_rank" value="phylum"/>
                    <param name="invert" value="false"/>
                </section>
                <section name="remove_options">
                    <param name="remove_selector" value="--all"/>
                </section>
            </conditional>
            <output name="blobdir">
                <assert_contents>
                    <has_size value="672500" delta="1000"/>
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="3">
            <conditional name="mode_conditional">
                <param name="selector" value="plots"/>
                <param name="blobdir" value="test02_blobdir.tar.gz"/>
                <param name="format" value="png"/>
            </conditional>
            <output name="plot_circle" file="test04_circle.png" ftype="png"/>
            <output name="plot_cumulative" file="test04_cumulative.png" ftype="png"/>
            <output name="plot_snail" file="test04_snail.png" ftype="png"/>
        </test>
        <test expect_num_outputs="1">
            <conditional name="mode_conditional">
                <param name="selector" value="filter"/>
                <param name="blobdir" value="test02_blobdir.tar.gz"/>
                <section name="filter_options">
                    <param name="list" value="801 802"/>
                    <param name="fasta" value="contig.fasta"/>
                </section>
                <section name="remove_options">
                    <param name="remove_selector" value="--all"/>
                </section>
            </conditional>
            <output name="blobdir">
                <assert_contents>
                    <has_size value="672497" delta="1000"/>
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[
    BlobToolKit is a software suite to aid researchers in identifying and isolating non-target data in draft and publicly available genome assemblies. It can be used to process assembly, 
    read and analysis files for fully reproducible interactive exploration in the browser-based Viewer. BlobToolKit can be used during assembly to filter non-target DNA, helping researchers produce assemblies with high biological credibility.
    ]]></help>
    <expand macro="citations"/>
</tool>