view hubArchiveCreator.xml @ 19:0152500d9acd draft

Uploaded
author rmarenco
date Thu, 13 Oct 2016 22:49:01 -0400
parents d786bca6a75d
children 40469b265ddb
line wrap: on
line source

<tool id="hubArchiveCreator" name="Hub Archive Creator" version="2.3.0">
    <description>
        This Galaxy tool permits to prepare your files to be ready for
        Assembly Hub visualization.
    </description>

    <requirements>
        <!-- Conda dependencies -->
        <requirement type="package" version="332">ucsc-bedtobigbed</requirement>
        <requirement type="package" version="332">ucsc-fatotwobit</requirement>
        <requirement type="package" version="332">ucsc-genepredtobed</requirement>
        <requirement type="package" version="332">ucsc-genepredtobiggenepred</requirement>
        <requirement type="package" version="332">ucsc-gff3togenepred</requirement>
        <requirement type="package" version="332">ucsc-gtftogenepred</requirement>
        <!-- TODO: Change the conda ucsc-psltobigpsl and take one > v337 because of bugs before -->
        <!-- <requirement type="package" version="332">ucsc-psltobigpsl</requirement> -->
        <requirement type="package" version="332">ucsc-twobitinfo</requirement>
        <requirement type="package" version="1.3">samtools</requirement>
        <!-- ToolShed dependencies -->
        <requirement type="package" version="312">ucsc_tools</requirement>
        <requirement type="package" version="0.0.1">gff3ToGenePred</requirement>
        <requirement type="package" version="0.0.1">gtfToGenePred</requirement>
        <requirement type="package" version="0.0.1">genePredToBed</requirement>
        <requirement type="package" version="0.0.1">genePredToBigGenePred</requirement>
        <requirement type="package" version="0.0.1">pslToBigPsl</requirement>
        <requirement type="package" version="1.2">samtools</requirement>
    </requirements>

    <stdio>
        <regex match="^pass1"
               source="stderr"
               level="log"
               description="bedToBigBed"/>
        <!-- TODO: Add the case pass1 and 0 chroms -->
        <!-- TODO: Add the case pass2 and 0 records or 0 fields -->
    </stdio>

    <!-- Idea: python \ -augustus [parameters] \ -trfBig [parameters] -->
    <command detect_errors="exit_code"><![CDATA[
        mkdir -p $output.extra_files_path;
        python $__tool_directory__/hubArchiveCreator.py

        ## Ask the user to enter the genome name
        --genome_name '$genome_name'

        #import json

        #set global data_parameter_dict = {}

        ## Function to retrieve the data of the inputs
        #def prepare_json($input_to_prepare, $order_index, $extra_data_dict={})
            #set false_path = str($input_to_prepare)
            #set name = $input_to_prepare.name

            #set data_dict = {"name": $name}
            #silent data_dict.update($extra_data_dict)

            ## Add the ordering by taking the tool form indexes
            #silent $data_dict.update({"order_index": $order_index})

            #silent $data_parameter_dict.update({$false_path: $data_dict})

        #end def


        ## Get the number of digits from tracks, to have a unique integer from group index and track index

        #set temp_max_digit = 0

        #for $g in $group
            #if len($g.format) > $temp_max_digit
                #silent temp_max_digit = len($g.format)
            #end if
        #end for

        #set nb_digits_max_track = len(str($temp_max_digit))

        ## END Get the number of digits

        #for $i_g, $g in enumerate( $group )
            #for $i, $f in enumerate( $g.format )
                ## Create the order index using index_group+1 concatenated with index_track
                #set index_group_final = str($i_g + 1)
                #set index_track_final = str($index_group_final) + str($i).zfill($nb_digits_max_track)

                ## For each format, we have a few mandatory fields we store in a dict
                #set track_color = str($f.formatChoice.track_color)
                #set group_name = str($g.group_name)

                #set extra_data_dict = {"track_color": $track_color,
                                        "group_name": $group_name}

                #if $f.formatChoice.format_select == "bam"
                    --bam $f.formatChoice.BAM
                    #set bam_index = $f.formatChoice.BAM.metadata.bam_index

                    ## Add Bam format specific fields
                    #silent extra_data_dict.update({"index": $bam_index})

                    #silent $prepare_json($f.formatChoice.BAM, $index_track_final, extra_data_dict)
                #end if
                #if $f.formatChoice.format_select == "bed"
                    #if $f.formatChoice.bedChoice.bed_select == "bed"
                        --bed $f.formatChoice.bedChoice.BED
                        #silent $prepare_json($f.formatChoice.bedChoice.BED, $index_track_final,
                                                extra_data_dict)
                    #end if
                    #if $f.formatChoice.bedChoice.bed_select == "bed_simple_repeats_option"
                        --bedSimpleRepeats $f.formatChoice.bedChoice.BED_simple_repeats
                        #silent $prepare_json($f.formatChoice.bedChoice.BED_simple_repeats, $index_track_final,
                                                extra_data_dict)
                    #end if
                #end if
                #if $f.formatChoice.format_select == "psl"
                    --psl $f.formatChoice.PSL
                    #silent $prepare_json($f.formatChoice.PSL, $index_track_final,
                                           extra_data_dict)
                #end if
                #if $f.formatChoice.format_select == "bigwig"
                    --bigwig $f.formatChoice.BIGWIG
                    #silent $prepare_json($f.formatChoice.BIGWIG, $index_track_final,
                                            extra_data_dict)
                #end if
                #if $f.formatChoice.format_select == "gff3"
                    --gff3 $f.formatChoice.GFF3
                    #silent $prepare_json($f.formatChoice.GFF3, $index_track_final,
                                            extra_data_dict)
                #end if
                #if $f.formatChoice.format_select == "gtf"
                    ## Add also GTF from Agustus? See https://github.com/ENCODE-DCC/kentUtils/issues/8
                    --gtf $f.formatChoice.GTF
                    #silent $prepare_json($f.formatChoice.GTF, $index_track_final,
                                             extra_data_dict)
                #end if
            #end for
        #end for

        ## We combine the fasta file dataset name with his false path in a JSON object
        #set fasta_json = json.dumps({"false_path": str($fasta_file), "name": $fasta_file.name})
        -f '$fasta_json'

        ## Dump the final json
        #set all_data_json = json.dumps($data_parameter_dict)

        --data_json '$all_data_json'

        ## Retrieve the user email
        --user_email $__user_email__

        -d $__tool_directory__

        -e $output.files_path

        $advanced_options.debug_mode

        -o $output;
    ]]></command>

    <inputs>
        <param
                name="genome_name"
                type="text"
                size="30"
                value="unknown"
                label="UCSC Genome Browser assembly ID"
        />
        <param
                format="fasta"
                name="fasta_file"
                type="data"
                label="Reference genome"
        />
        <repeat name="group" title="New group">
            <param type="text" name="group_name" label="Group name" value="Default group"/>
            <repeat name="format" title="New track">
                <conditional name="formatChoice">
                    <param name="format_select" type="select" label="Format">
                        <option value="bam" selected="true">BAM</option>
                        <option value="bed">BED</option>
                        <option value="psl">PSL</option>
                        <option value="bigwig">BIGWIG</option>
                        <option value="gff3">GFF3</option>
                        <option value="gtf">GTF</option>
                    </param>

                    <when value="bam">
                        <param
                                format="bam"
                                name="BAM"
                                type="data"
                                label="BAM File"
                        />
                        <!-- TODO: Find a solution to avoid repetition and to generate a new color depending on the others -->
                        <param name="track_color" type="color" label="Track color" value="#000000">
                            <sanitizer>
                                <valid initial="string.letters,string.digits">
                                    <add value="#"/>
                                </valid>
                            </sanitizer>
                        </param>
                    </when>
                    <when value="bed">
                        <conditional name="bedChoice">
                            <param name="bed_select" type="select" label="Bed Choice">
                                <option value="bed" selected="true">BED Generic (bed3+)</option>
                                <option value="bed_simple_repeats_option">BED Simple repeat (bed4+12 / simpleRepeat.as)</option>
                            </param>
                            <when value="bed">
                                <param
                                        format="bed"
                                        name="BED"
                                        type="data"
                                        label="Generic Bed File Choice"
                                />

                            </when>
                            <when value="bed_simple_repeats_option">
                                <param
                                        format="bed"
                                        name="BED_simple_repeats"
                                        type="data"
                                        label="Bed Simple Repeats (Bed4+12) File"
                                />
                            </when>
                        </conditional>
                        <param name="track_color" type="color" label="Track color" value="#000000">
                            <sanitizer>
                                <valid initial="string.letters,string.digits">
                                    <add value="#"/>
                                </valid>
                            </sanitizer>
                        </param>
                    </when>
                    <when value="psl">
                        <param
                                format="psl"
                                name="PSL"
                                type="data"
                                label="PSL File"
                        />
                        <param name="track_color" type="color" label="Track color" value="#000000">
                            <sanitizer>
                                <valid initial="string.letters,string.digits">
                                    <add value="#"/>
                                </valid>
                            </sanitizer>
                        </param>
                    </when>
                    <when value="bigwig">
                        <param
                                format="bigwig"
                                name="BIGWIG"
                                type="data"
                                label="BIGWIG File"
                        />
                        <param name="track_color" type="color" label="Track color" value="#000000">
                            <sanitizer>
                                <valid initial="string.letters,string.digits">
                                    <add value="#"/>
                                </valid>
                            </sanitizer>
                        </param>
                    </when>
                    <when value="gff3">
                        <param
                                format="gff3"
                                name="GFF3"
                                type="data"
                                label="GFF3 File"
                        />
                        <param name="track_color" type="color" label="Track color" value="#000000">
                            <sanitizer>
                                <valid initial="string.letters,string.digits">
                                    <add value="#"/>
                                </valid>
                            </sanitizer>
                        </param>
                    </when>
                    <when value="gtf">
                        <param
                                format="gtf"
                                name="GTF"
                                type="data"
                                label="GTF File"
                        />
                        <param name="track_color" type="color" label="Track color" value="#000000">
                            <sanitizer>
                                <valid initial="string.letters,string.digits">
                                    <add value="#"/>
                                </valid>
                            </sanitizer>
                        </param>
                    </when>
                </conditional>
            </repeat>
        </repeat>
        <conditional name="advanced_options">
            <param name="advanced_options_selector" type="select" label="Advanced options">
                <option value="off" selected="true">Hide advanced options</option>
                <option value="on">Display advanced options</option>
            </param>
            <!-- TODO: Avoid redundancy here -->
            <when value="on">
                <param name="debug_mode" type="boolean"
                       label="Activate debug mode" checked="false"
                       truevalue="--debug_mode" falsevalue="">
                    <help>
                        Use this option if you are a G-OnRamp developer
                    </help>
                </param>
            </when>
            <when value="off">
                <param name="debug_mode" type="hidden"
                       value="">
                </param>
            </when>
    </conditional>
</inputs>

    <outputs>
        <data format="trackhub" name="output"/>
    </outputs>

    <tests>
        <!-- Can also use assert_command to test command -->
        <!-- Testing GFF3 input -->
        <test>
            <param name="fasta_file" value="dbia3.fa"/>
            <repeat name="format">
                <conditional name="formatChoice">
                    <param name="format_select" value="gff3"/>
                    <param name="GFF3" value="augustusDbia3.gff3"/>
                </conditional>
            </repeat>
            <repeat name="format">
                <param name="BED_simple_repeats" value="dbia3_trfBig_unsorted.bed"/>
                <!-- TODO: Ask why the tests are not passing with this xml:
                     Error creating a job for these tool inputs - Error executing tool: 'NoneType' object has no attribute 'current_history'
                <conditional name="formatChoice">
                    <param name="format_select" value="bed"/>
                    <conditional name="bedChoice">
                        <param name="bed_select" value="bed_simple_repeats_option"/>
                        <param name="BED_simple_repeats" value="dbia3_trfBig_unsorted.bed"/>
                    </conditional>
                </conditional>
                -->
            </repeat>

            <output name="output">
                <assert_contents>
                    <has_text text="myHub"/>
                </assert_contents>
                <assert_contents>
                    <has_text text="dbia3_trfBig.bb"/>
                </assert_contents>
                <assert_contents>
                    <has_text text="SAODOAii qwwqod92921"/>
                </assert_contents>
            </output>
        </test>
        <test>
            <param name="fasta_file" value="dbia3.fa"/>
            <param name="GFF3" value="augustusDbia3.gff3"/>
            <output name="output" file="augustusOutput.html" lines_diff="2">
                <extra_files type="directory" value="myHub"/>
                <extra_files type="file" name="myHub/dbia3/tracks/augustusDbia3.bb" value="augustusDbia3.bb"/>
            </output>
        </test>
        <!-- Testing Generic BED input -->
        <!-- Testing Bed Simple repeat input -->
    </tests>

    <help>
        This Galaxy tool permits to prepare your files to be ready for
        Assembly Hub visualization.
    </help>
</tool>