view bwa.xml @ 3:607ca4b95837 draft

Uploaded
author devteam
date Fri, 20 Mar 2015 12:21:16 -0400
parents e29bc5c169bc
children ac30bfd3e2a8
line wrap: on
line source

<?xml version="1.0"?>
<tool id="bwa" name="Map with BWA" version="0.2.1">
  <description>- map short reads (&lt; 100 bp) against reference genome</description>
  <macros>
    <import>bwa_macros.xml</import>
    <token name="@command_options@">
    #if str( $analysis_type.analysis_type_selector ) == "full":
      -n ${analysis_type.n}
      -o ${analysis_type.o}
      -e ${analysis_type.e}
      -i ${analysis_type.i}
      -d ${analysis_type.d}
      -l ${analysis_type.l}
      -k ${analysis_type.k}
      -m ${analysis_type.m}
      -M ${analysis_type.M}
      -O ${analysis_type.O}
      -E ${analysis_type.E}
      -R ${analysis_type.R}
      -q ${analysis_type.q}

      #if str( $analysis_type.B ):
        -B ${analysis_type.B}
      #end if

      #if str( $analysis_type.L ):
        -B ${analysis_type.L}
      #end if
    #end if
    </token>
    <token name="@read_group_options@">
      #if str( $rg.rg_selector ) == "set":
        @set_rg_string@
        -r '$rg_string'
      #end if
    </token>

    <xml name="advanced_pe_options">
      <param name="adv_pe_options_selector" type="select" label="Set advanced paired end options?" help="Provides additional controls">
        <option value="set">Set</option>
        <option value="do_not_set" selected="True">Do not set</option>
      </param>
      <when value="set">
        <param name="a" type="integer" value="500" label="Maximum insert size for a read pair to be considered being mapped properly." help="sampe -a; This option is only used when there are not enough good alignment to infer the distribution of insert sizes; default=500"/>
        <param name="o" type="integer" value="100000" label="Maximum occurrences of a read for pairing. A read with more occurrences will be treated as a single-end read." help="sampe -o; Reducing this parameter helps faster pairing; default=100000"/>
        <param name="n" type="integer" value="3" label="Maximum number of alignments to output in the XA tag for reads paired properly." help="sampe -n; If a read has more than this many hits, the XA tag will not be written; default=3"/>
        <param name="N" type="integer" value="10" label="Maximum number of alignments to output in the XA tag for disconcordant read pairs (excluding singletons)." help="sampe -N; If a read has more than this many hits, the XA tag will not be written; default=10"/>
        <param name="c" type="float" value="0.00005" label="Prior of chimeric rate (lower bound)" help="sampe -c"/>
      </when>
      <when value="do_not_set">
        <!-- do nothing -->
      </when>
    </xml>
    <xml name="advanced_se_options">
      <param name="adv_se_options_selector" type="select" label="Set advanced single end options?" help="Provides additional controls">
        <option value="set">Set</option>
        <option value="do_not_set" selected="True">Do not set</option>
      </param>
      <when value="set">
        <param name="n" type="integer" value="3" label="Maximum number of alignments to output in the XA tag." help="-n; If a read has more than this many hits, the XA tag will not be written; default=3"/>
      </when>
      <when value="do_not_set">
        <!-- do nothing -->
      </when>
    </xml>
  </macros>

  <requirements>
    <requirement type="package" version="0.7.10.039ea20639">bwa</requirement>
    <requirement type="package" version="1.1">samtools</requirement>
  </requirements>
  <stdio>
    <exit_code range="1:" />
  </stdio>
  <command>
    #set $reference_fasta_filename = "localref.fa"

    #if str( $reference_source.reference_source_selector ) == "history":
        ln -s "${reference_source.ref_file}" "${reference_fasta_filename}" &amp;&amp;

        ## The following shell commands decide with of the BWA indexing algorithms (IS or BWTSW) will be run
        ## depending ob the size of the input FASTA dataset
           (
            size=`stat -c %s "${reference_fasta_filename}" 2&gt;/dev/null`;                  ## Linux
            if [ $? -eq 0 ];
            then
              if [ "\$size" -lt 2000000000 ];
              then
                bwa index -a is "${reference_fasta_filename}";
              else
                bwa index -a bwtsw "${reference_fasta_filename}";
              fi;
            fi;

            eval \$(stat -s "${reference_fasta_filename}" 2&gt;/dev/null);                   ## OSX
            if [ -n "\$st_size" ];
            then
              if [ "\$st_size" -lt 2000000000 ];
              then
                bwa index -a is "${reference_fasta_filename}";
                echo "Generating BWA index with is algorithm";
              else
                bwa index -a bwtsw "${reference_fasta_filename}";
                echo "Generating BWA index with bwtsw algorithm";
              fi;
            fi;
            ) &amp;&amp;
    #else:
        #set $reference_fasta_filename = str( $reference_source.ref_file.fields.path )
    #end if

    ## Begin bwa command line

####### Fastq paired

    #if str( $input_type.input_type_selector ) == "paired" or str( $input_type.input_type_selector ) == "paired_collection":
      bwa aln
      -t "\${GALAXY_SLOTS:-1}"

      @command_options@

      "${reference_fasta_filename}"

      #if str( $input_type.input_type_selector ) == "paired_collection":
        "${input_type.fastq_input1.forward}"
      #else
        "${input_type.fastq_input1}"
      #end if

      > first.sai &amp;&amp;

      bwa aln
      -t "\${GALAXY_SLOTS:-1}"

      @command_options@

      "${reference_fasta_filename}"

      #if str( $input_type.input_type_selector ) == "paired_collection":
        "${input_type.fastq_input1.reverse}"
      #else
        "${input_type.fastq_input2}"
      #end if

      > second.sai &amp;&amp;

      bwa sampe

      #if str( $input_type.adv_pe_options.adv_pe_options_selector) == "True":
        -a ${$input_type.adv_pe_options.a}
        -o ${$input_type.adv_pe_options.o}
        -n ${$input_type.adv_pe_options.n}
        -N ${$input_type.adv_pe_options.N}
      #end if

      @read_group_options@

      #if str( $input_type.input_type_selector ) == "paired_collection":
        "${reference_fasta_filename}" first.sai second.sai "${input_type.fastq_input1.forward}" "${input_type.fastq_input1.reverse}"
      #else:
        "${reference_fasta_filename}" first.sai second.sai "${input_type.fastq_input1}" "${input_type.fastq_input2}"
      #end if

####### Fastq single

    #elif str( $input_type.input_type_selector ) == "single":
      bwa aln
      -t "\${GALAXY_SLOTS:-1}"

      @command_options@

      "${reference_fasta_filename}"
      "${input_type.fastq_input1}"
      > first.sai &amp;&amp;

      bwa samse

      #if str( $input_type.adv_se_options.adv_se_options_selector) == "True":
        -n ${$input_type.adv_se_options.n}
      #end if

      @read_group_options@

      "${reference_fasta_filename}" first.sai "${input_type.fastq_input1}"

####### BAM paired

    #elif str( $input_type.input_type_selector ) == "paired_bam":
      bwa aln
      -t "\${GALAXY_SLOTS:-1}"
      -b
      -1

      @command_options@

      "${reference_fasta_filename}"
      "${input_type.bam_input}"
      > first.sai &amp;&amp;

      bwa aln
      -t "\${GALAXY_SLOTS:-1}"
      -b
      -2
      @command_options@
      "${reference_fasta_filename}"
      "${input_type.bam_input}"
      > second.sai &amp;&amp;

      bwa sampe

      #if str( $input_type.adv_bam_pe_options.adv_pe_options_selector) == "True":
        -a ${$input_type.adv_bam_pe_options.a}
        -o ${$input_type.adv_bam_pe_options.o}
        -n ${$input_type.adv_bam_pe_options.n}
        -N ${$input_type.adv_bam_pe_options.N}
      #end if

      @read_group_options@

      "${reference_fasta_filename}" first.sai second.sai "${input_type.bam_input}" "${input_type.bam_input}"

####### Fastq single   ------------ to do next

    #elif str( $input_type.input_type_selector ) == "single_bam":
      bwa aln
      -t "\${GALAXY_SLOTS:-1}"
      -b
      -0

      @command_options@

      "${reference_fasta_filename}"
      "${input_type.bam_input}"
      > first.sai &amp;&amp;

      bwa samse

      #if str( $input_type.adv_bam_se_options.adv_se_options_selector) == "True":
        -n ${$input_type.adv_bam_se_options.n}
      #end if

      @read_group_options@

      "${reference_fasta_filename}" first.sai "${input_type.bam_input}"
    #end if

    | samtools view -Sb - > temporary_bam_file.bam &amp;&amp;

    samtools sort -f temporary_bam_file.bam ${bam_output}
  </command>

  <inputs>

    <conditional name="reference_source">
      <param name="reference_source_selector" type="select" label="Load reference genome from">
        <option value="cached">Local cache</option>
        <option value="history">History</option>
      </param>
      <when value="cached">
        <param name="ref_file" type="select" label="Using reference genome" help="Select genome from the list">
          <options from_data_table="bwa_mem_indexes">
            <filter type="sort_by" column="2" />
            <validator type="no_options" message="No indexes are available" />
          </options>
          <validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
        </param>
      </when>
      <when value="history">
        <param name="ref_file" type="data" format="fasta" label="Use the following dataset as the reference sequence" help="You can upload a FASTA sequence to the history and use it as reference" />
      </when>
    </conditional>
    <conditional name="input_type">
      <param name="input_type_selector" type="select" label="Select input type" help="Select between fastq and bam datasets and between paired and single end data">
        <option value="paired">Paired fastq</option>
        <option value="paired_collection">Paired fastq collection</option>
        <option value="single">Single fastq</option>
        <option value="paired_bam">Paired BAM</option>
        <option value="single_bam">Single BAM</option>
      </param>
      <when value="paired">
        <param name="fastq_input1" type="data" format="fastqsanger" label="Select first set of reads" help="Specify dataset with forward reads"/>
        <param name="fastq_input2" type="data" format="fastqsanger" label="Select second set of reads" help="Specify dataset with reverse reads"/>
        <conditional name="adv_pe_options">

          <expand macro="advanced_pe_options" />

        </conditional>
      </when>

      <when value="paired_collection">
        <param name="fastq_input1" format="fastqsanger" type="data_collection" collection_type="paired" label="Select a paired collection" help="See help section for an explanation of dataset collections"/>
        <conditional name="adv_pe_options">

          <expand macro="advanced_pe_options" />

        </conditional>
      </when>

      <when value="single">
        <param name="fastq_input1" type="data" format="fastqsanger" label="Select fastq dataset" help="Specify dataset with single reads"/>
        <conditional name="adv_se_options">

          <expand macro="advanced_se_options" />

        </conditional>
      </when>

      <!-- the difference between single and paired bams is in the <command> tag portion and realated to -0, -1, and -2 options -->

      <when value="paired_bam">
        <param name="bam_input" type="data" format="bam" label="Select BAM dataset" help="Specify BAM dataset with paired reads"/>
        <conditional name="adv_bam_pe_options">

          <expand macro="advanced_pe_options" />

        </conditional>
      </when>

      <when value="single_bam">
        <param name="bam_input" type="data" format="bam" label="Select BAM dataset" help="Specify BAM dataset with single reads"/>
        <conditional name="adv_bam_se_options">

          <expand macro="advanced_se_options" />

        </conditional>
      </when>

    </conditional>

    <expand macro="readgroup_params" />

    <conditional name="analysis_type">
      <param name="analysis_type_selector" type="select" label="Select analysis mode">
        <option value="illumina">1.Simple Illumina mode</option>
        <option value="full">2.Full list of options</option>
      </param>
      <when value="illumina">
        <!-- do nothing -->
      </when>
      <when value="full">
        <param name="n" type="text" value="0.04" label="maximum edit distance if the value is integer, or the fraction of missing alignments given 2% uniform base error rate if float. In the latter case, the maximum edit distance is automatically chosen for different read lengths." help="aln -n; default=0.04"/>
        <param name="o" type="integer" value="1" label="maximum number or gap openings" help="aln -o; default=1"/>
        <param name="e" type="integer" value="-1" label="maximum number of gap extensions" help="aln -e; -1 disables long gaps and invokes k-difference mode; default=-1"/>
        <param name="i" type="integer" value="5"  label="do not put an indel within this many bp towards the ends" help="aln -i; default=5"/>
        <param name="d" type="integer" value="10" label="maximum occurrences for extending a long deletion" help="aln -d; default=10"/>
        <param name="l" type="integer" value="32" label="seed length" help="aln -l; default=32"/>
        <param name="k" type="integer" value="2" label="maximum differences in the seed" help="aln -k; default=2"/>
        <param name="m" type="integer" value="2000000" label="maximum entries in the queue" help="aln -m; default=2000000"/>
        <param name="M" type="integer" value="3" label="mismatch penalty" help="aln -M; default=3"/>
        <param name="O" type="integer" value="11" label="gap open penalty" help="aln -O; default=11"/>
        <param name="E" type="integer" value="4" label="gap extension penalty" help="aln -E; default=4"/>
        <param name="R" type="integer" value="30" label="stop searching when there are more than this value of equally best hits" help="aln -R; default=30"/>
        <param name="q" type="integer" value="0" label="quality threshold for read trimming down to 35bp" help="aln -q; default=0"/>
        <param name="B" type="integer" optional="True" label="length of barcode" help="aln -B; optional parameter"/>
        <param name="L" type="float" optional="True" label="log-scaled gap penalty for long deletions" help="aln -L; optional parameter"/>
      </when>
    </conditional>
  </inputs>

  <outputs>
    <data format="bam" name="bam_output" label="${tool.name} on ${on_string} (mapped reads in BAM format)"/>
  </outputs>

  <tests>
    <test>
      <param name="reference_source_selector" value="history" />
      <param name="ref_file" ftype="fasta" value="bwa-mem-mt-genome.fa"/>
      <param name="input_type_selector" value="paired"/>
      <param name="fastq_input1" ftype="fastqsanger" value="bwa-mem-fastq1.fq"/>
      <param name="fastq_input2" ftype="fastqsanger" value="bwa-mem-fastq2.fq"/>
      <param name="analysis_type_selector" value="illumina"/>
      <output name="bam_output" ftype="bam" file="bwa-aln-test1.bam" lines_diff="2" />
    </test>
    <test>
      <param name="reference_source_selector" value="history" />
      <param name="ref_file" ftype="fasta" value="bwa-mem-mt-genome.fa"/>
      <param name="input_type_selector" value="paired_bam"/>
      <param name="bam_input" ftype="bam" value="bwa-aln-bam-input.bam"/>
      <param name="analysis_type_selector" value="illumina"/>
      <output name="bam_output" ftype="bam" file="bwa-aln-test2.bam" lines_diff="2" />
    </test>
    <test>
      <param name="reference_source_selector" value="history" />
      <param name="ref_file" ftype="fasta" value="bwa-mem-mt-genome.fa"/>
      <param name="input_type_selector" value="paired"/>
      <param name="fastq_input1" ftype="fastqsanger" value="bwa-mem-fastq1.fq"/>
      <param name="fastq_input2" ftype="fastqsanger" value="bwa-mem-fastq2.fq"/>
      <param name="rg_selector" value="set"/>
      <param name="ID" value="rg1"/>
      <param name="analysis_type_selector" value="illumina"/>
      <output name="bam_output" ftype="bam" file="bwa-aln-test3.bam" lines_diff="2" />
    </test>
  </tests>
  <help>
**What is does**

BWA is a software package for mapping low-divergent sequences against a large reference genome, such as the human genome. The bwa-aln algorithm is designed for Illumina sequence reads up to 100bp. For longer reads use BWA-MEM algorithm distributed as separate Galaxy tool.

This Galaxy tool wraps bwa-aln, bwa-samse and -sampe modules of bwa read mapping tool:

  - bwa aln - actual mapper placing reads onto the reference sequence
  - bwa samse - post-processor converting suffix array coordinates into genome coordinates in SAM format for single reads
  - bam sampe - post-processor for paired reads

Galaxy implementation takes fastq or BAM (unaligned BAM) datasets as input and produces output in BAM (not SAM; in reality SAM produced by the bwa is converted to BAM on the fly by samtools view command) format, which can be further processed using various BAM utilities exiting in Galaxy (BAMTools, SAMTools, Picard).

-----

**Galaxy-specific option**

Galaxy allows three levels of control over bwa-mem options provided by **Select analysis mode** menu option. These are:

  1. *Simple Illumina mode*: The simplest possible bwa mem application in which it alignes single or paired-end data to reference using default parameters. It is equivalent to the following command: bwa mem &lt;reference index&gt; &lt;fastq dataset1&gt; [fastq dataset2]
  2. *Full list of options*: Allows access to all options through Galaxy interface.

------

**bwa-aln options**

Each Galaxy parameter widget corresponds to command line flags listed below::

    -n NUM    max #diff (int) or missing prob under 0.02 err rate (float) [0.04]
    -o INT    maximum number or fraction of gap opens [1]
    -e INT    maximum number of gap extensions, -1 for disabling long gaps [-1]
    -i INT    do not put an indel within INT bp towards the ends [5]
    -d INT    maximum occurrences for extending a long deletion [10]
    -l INT    seed length [32]
    -k INT    maximum differences in the seed [2]
    -m INT    maximum entries in the queue [2000000]
    -M INT    mismatch penalty [3]
    -O INT    gap open penalty [11]
    -E INT    gap extension penalty [4]
    -R INT    stop searching when there are >INT equally best hits [30]
    -q INT    quality threshold for read trimming down to 35bp [0]
    -B INT    length of barcode
    -L        log-scaled gap penalty for long deletions
    -N        non-iterative mode: search for all n-difference hits (slooow)
    -I        the input is in the Illumina 1.3+ FASTQ-like format
    -b        the input read file is in the BAM format
    -0        use single-end reads only (effective with -b)
    -1        use the 1st read in a pair (effective with -b)
    -2        use the 2nd read in a pair (effective with -b)

**bwa-samse options**::

    -a INT    maximum insert size [500]
    -o INT    maximum occurrences for one end [100000]
    -n INT    maximum hits to output for paired reads [3]
    -N INT    maximum hits to output for discordant pairs [10]
    -c FLOAT  prior of chimeric rate (lower bound) [1.0e-05]
    -r STR    read group header line [null]

**bwa-sampe options**::

    -n INT    maximum hits to output for paired reads [3]
    -r STR    read group header line [null]

@dataset_collections@

@RG@

@info@
  </help>
  <citations>
    <citation type="doi">10.1093/bioinformatics/btp324</citation>
    <citation type="doi">10.1093/bioinformatics/btp698</citation>
  </citations>
</tool>