view trim_galore_wrapper.xml @ 1:898db63d2e84 draft

upgrade to new version
author bgruening
date Wed, 17 Jul 2013 15:05:43 -0400
parents 3c1664caa8e3
children 9109c2c3be1e
line wrap: on
line source

<tool id="trim_galore" name="Trim Galore" version="0.2.8">
    <!-- Wrapper compatible with Trim Galore version 0.2.8 -->
    <description>adaptive quality and adapter trimmer</description>
    <version_command interpreter="perl">trim_galore --version</version_command>
    <requirements>
        <requirement type="package" version="1.1">cutadapt</requirement>
        <requirement type="package" version="0.10.1">fastqc</requirement>
    </requirements>
    <command interpreter="perl">
        #from glob import glob
        #import tempfile, os

        ##
        ##  Creating a temporary directory where trim_galore will store all result files
        ##

        #set $temp_dir = os.path.abspath(tempfile.mkdtemp())


        ## trim_galore removes .fastq and .fq file extensions of input files. 
        ## That is essential if Galaxy provides links to files (these can have real extensions), but that behaviour is causing an inconsitency in output filenaming.
        ## Fix: link every file to $TMP without file extension

        #if $singlePaired.sPaired == "single":
            #set $input_singles_tmp_handle = tempfile.NamedTemporaryFile( dir=$temp_dir )
            #set $input_singles_tmp = $input_singles_tmp_handle.name
            #silent $input_singles_tmp_handle.close()
            #silent os.system("ln -s %s %s" % (str($singlePaired.input_singles), $input_singles_tmp))
        #else:
            #set $input_mate1_tmp_handle = tempfile.NamedTemporaryFile( dir=$temp_dir )
            #set $input_mate2_tmp_handle = tempfile.NamedTemporaryFile( dir=$temp_dir )
            
            #set $input_mate1_tmp = $input_mate1_tmp_handle.name
            #silent $input_mate1_tmp_handle.close()

            #set $input_mate2_tmp = $input_mate2_tmp_handle.name
            #silent $input_mate2_tmp_handle.close()

            #silent os.system("ln -s %s %s" % (str($singlePaired.input_mate1), $input_mate1_tmp))
            #silent os.system("ln -s %s %s" % (str($singlePaired.input_mate2), $input_mate2_tmp))
        #end if

        trim_galore

        ##
        ##  Input parameters
        ##


        #if $params.settingsType == "custom":

            $params.fastqc
            ## default 20
            --quality $params.quality
            ## default 'AGATCGGAAGAGC'
            #if $params.adapter.strip() != '':
                --adapter $params.adapter
            #end if
            ## default 1
            --stringency $params.stringency
            
            ## default 0.1
            -e $params.error_rate

            ## default 20
            --length $params.min_length

            #if int($params.clip_R1) > 0:
                --clip_R1 $params.clip_R1
            #end if
            
            #if int($params.clip_R2) > 0:
                --clip_R2 $params.clip_R2
            #end if

            #if $params.retain_unpaired.settingsType == "retain_unpaired_output":
                --retain_unpaired
                --length_1 $params.retain_unpaired.length_1
                --length_2 $params.retain_unpaired.length_2
            #end if

        #end if

        ##
        ## RBBS specific options.
        ##

        #if $rrbs.settingsType == "custom":

            $rrbs.rrbs
            $rrbs.non_directional

        #end if

        --output_dir $temp_dir
        --suppress_warn


        #if $singlePaired.sPaired == "single":

            #if $singlePaired.input_singles.ext == "fastqillumina":
                --phred64
            #elif $singlePaired.input_singles.ext == "fastqsanger":
                --phred33
            #end if

            #if $params.settingsType == "custom":
                #if not $params.report:
                    --no_report_file
                #end if
            #end if

            ## input sequence
            $input_singles_tmp
        #else:
            --paired 
            #if $singlePaired.input_mate1.ext == "fastqillumina":
                --phred64
            #elif $singlePaired.input_mate1.ext == "fastqsanger":
                --phred33
            #end if

            $singlePaired.trim1
            #if $singlePaired.adapter2.strip() != '':
                --adapter2 $singlePaired.adapter2
            #end if

            #if $params.settingsType == "custom":
                #if not $params.report:
                    --no_report_file
                #end if
            #end if

            ## input sequences
            $input_mate1_tmp
            $input_mate2_tmp

        #end if

        &amp;&amp;

        ##
        ##  Trim Galore! run is finished. Move the result files to the proper place
        ##


        #if $singlePaired.sPaired == "single":
            #set $single_end_path =  os.path.join($temp_dir, os.path.basename(str($input_singles_tmp)) + '_trimmed.fq')
            mv $single_end_path $trimmed_reads_single;

            #if $params.settingsType == "custom":
                #if $params.report:
                    #set $report_path =  os.path.join($temp_dir, os.path.basename(str($input_singles_tmp)) + '_trimming_report.txt')
                    mv $report_path $report_file;
                #end if
            #end if

        #else:
            #set $paired_end_path_1 =  os.path.join($temp_dir, os.path.basename(str($input_mate1_tmp)) + '_val_1.fq')
            #set $paired_end_path_2 =  os.path.join($temp_dir, os.path.basename(str($input_mate2_tmp)) + '_val_2.fq')
            mv $paired_end_path_1 $trimmed_reads_pair1;
            mv $paired_end_path_2 $trimmed_reads_pair2;

            #if $params.settingsType == "custom":
                #if $params.retain_unpaired.settingsType == "retain_unpaired_output":
                    #set $unpaired_path_1 =  os.path.join($temp_dir, os.path.basename(str($input_mate1_tmp)) + '_unpaired_1.fq')
                    #set $unpaired_path_2 =  os.path.join($temp_dir, os.path.basename(str($input_mate2_tmp)) + '_unpaired_2.fq')
                    mv $unpaired_path_1 $unpaired_reads_1;
                    mv $unpaired_path_2 $unpaired_reads_2;
                #end if

                #if $params.report:
                    #set $report_path =  os.path.join($temp_dir, os.path.basename(str($input_mate1_tmp)) + '_trimming_report.txt')
                    mv $report_path $report_file;
                #end if

            #end if
        #end if

        ## delete the temp_dir
        ##rm -rf $temp_dir

    </command>
    <inputs>

        <!-- Input Parameters -->
        <conditional name="singlePaired">
            <param name="sPaired" type="select" label="Is this library mate-paired?">
              <option value="single">Single-end</option>
              <option value="paired">Paired-end</option>
            </param>
            <when value="single">
                <param name="input_singles" type="data" format="fastqsanger,fastqillumina,fastq,fasta" label="FASTQ/FASTA file" help="FASTQ or FASTA files." />
            </when>
            <when value="paired">
                <param name="input_mate1" type="data" format="fastqsanger,fastqillumina,fastq,fasta" label="FASTQ/FASTA file" help="FASTQ or FASTA files." />
                <param name="input_mate2" type="data" format="fastqsanger,fastqillumina,fastq,fasta" label="FASTQ/FASTA file" help="FASTQ or FASTA files." />
                <param name="trim1" type="boolean" truevalue="--trim1" falsevalue="" checked="False" label="Trims 1 bp off every read from its 3' end." help="" />
                <param name="adapter2" type="text" value="" label="Optional adapter sequence to be trimmed off read 2">
                    <validator type="regex" message="Adapter sequence must contain DNA characters only (A,C,T,G or N)">^[ACTGNactgn]*$</validator>
                </param>
            </when>
        </conditional>


        <conditional name="params">
            <param name="settingsType" type="select" label="Trim galore! advanced settings" help="You can use the default settings or set custom values for any of Trim Galore's parameters.">
              <option value="default">Use Defaults</option>
              <option value="custom">Full parameter list</option>
            </param>
            <when value="default" />
            <!-- Full/advanced params. -->
            <when value="custom">
                <param name="fastqc" type="boolean" truevalue="--fastqc" falsevalue="" checked="False" label="Run FastQC in the default mode on the FastQ file once trimming is complete" help="" />
                <param name="quality" type="integer" value="20" label="Trim low-quality ends from reads in addition to adapter removal." help="For more information please see below." />
                <param name="adapter" type="text" value="AGATCGGAAGAGC" label="Adapter sequence to be trimmed">
                    <validator type="regex" message="Adapter sequence must contain DNA characters only (A,C,T,G or N)">^[ACTGNactgn]*$</validator>
                </param>
                <param name="stringency" type="integer" value="1" label="Overlap with adapter sequence required to trim a sequence" />
                <param name="error_rate" type="float" value="0.1" label="Maximum allowed error rate" />
                <param name="min_length" type="integer" value="20" label="Discard reads that became shorter than length INT" />

                <param name="clip_R1" type="integer" value="0" label="nstructs Trim Galore to remove INT bp from the 5' end of read 1" />
                <param name="clip_R2" type="integer" value="0" label="nstructs Trim Galore to remove INT bp from the 5' end of read 2" />

                <param name="report" type="boolean" truevalue="true" falsevalue="false" checked="False" label="Generate a report file" help="" />

                <conditional name="retain_unpaired">
                    <param name="settingsType" type="select" label="specify if you would like to retain unpaired reads">
                      <option value="no_output">Do not output unpaired reads</option>
                      <option value="retain_unpaired_output">Output unpaired reads</option>
                    </param>
                    <when value="no_output" />
                    <!-- Output params. -->
                    <when value="retain_unpaired_output">
                        <param name="length_1" type="integer" value="35" label="Unpaired single-end read length cutoff needed for read 1 to be written" />
                        <param name="length_2" type="integer" value="35" label="Unpaired single-end read length cutoff needed for read 2 to be written" />
                    </when>  <!-- output -->
                </conditional>  <!-- retain_unpaired -->

            </when>  <!-- full -->
        </conditional>  <!-- params -->

        <conditional name="rrbs">
            <param name="settingsType" type="select" label="RRBS specific settings">
              <option value="default">Use Defaults (no RRBS)</option>
              <option value="custom">Full parameter list</option>
            </param>
            <when value="default" />
            <!-- Full/advanced params. -->
            <when value="custom">
                <param name="rrbs" type="boolean" truevalue="--rrbs" falsevalue="" checked="True" label="Specifies that the input file was an MspI digested RRBS sample" />
                <param name="non_directional" type="boolean" truevalue="--non_directional" falsevalue="" checked="False" label="Selecting this option for non-directional RRBS libraries" />
            </when>  <!-- full -->
      </conditional>  <!-- params -->

    </inputs>
    <outputs>

        <data format="fastq" name="trimmed_reads_single" label="${tool.name} on ${on_string}: trimmed reads">
          <filter>singlePaired['sPaired'] == "single"</filter>
          <actions>
                <action type="format">
                  <option type="from_param" name="singlePaired.input_singles" param_attribute="ext" />
                </action>
          </actions>
        </data>

        <data format="fastq" name="trimmed_reads_pair1" label="${tool.name} on ${on_string}: trimmed reads pair 1">
            <filter>singlePaired['sPaired'] == "paired"</filter>
            <actions>
                <action type="format">
                    <option type="from_param" name="singlePaired.input_mate1" param_attribute="ext" />
                </action>
          </actions>
        </data>

        <data format="fastq" name="trimmed_reads_pair2" label="${tool.name} on ${on_string}: trimmed reads pair 2">
            <filter>singlePaired['sPaired'] == "paired"</filter>
            <actions>
                <action type="format">
                    <option type="from_param" name="singlePaired.input_mate1" param_attribute="ext" />
                </action>
            </actions>
        </data>

        <data format="fastq" name="unpaired_reads_1" label="${tool.name} on ${on_string}: unpaired reads (1)">
          <filter>
            ((
              params['settingsType'] == "custom" and
              params['retain_unpaired']['settingsType'] == "retain_unpaired_output"
            ))
          </filter>
          <actions>
                <action type="format">
                  <option type="from_param" name="singlePaired.input_mate1" param_attribute="ext" />
                </action>
          </actions>
        </data>

        <data format="fastq" name="unpaired_reads_2" label="${tool.name} on ${on_string}: unpaired reads (2)">
          <filter>
            ((
              params['settingsType'] == "custom" and
              params['retain_unpaired']['settingsType'] == "retain_unpaired_output"
            ))
          </filter>
          <actions>
                <action type="format">
                  <option type="from_param" name="singlePaired.input_mate1" param_attribute="ext" />
                </action>
          </actions>
        </data>

        <data format="txt" name="report_file" label="${tool.name} on ${on_string}: report file">
          <filter>
            ((
              params['settingsType'] == "custom" and
              params['report'] == True
            ))
          </filter>
        </data>

    </outputs>
    <tests>
    </tests>

    <help>

**What it does**

TrimGalore!_ is a wrapper script that makes use of the publically available 
adapter trimming tool Cutadapt and FastQC for optional quality control once 
the trimming process has completed.


.. _TrimGalore!: http://www.bioinformatics.babraham.ac.uk/projects/trim_galore/


It is developed by Krueger F at the Babraham Institute.

------


  </help>
</tool>