view bwa.xml @ 12:bd3a1e0de84c draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/bwa commit 13b3ab10ff1a2e4be39b44f885df6bbe7c23099a
author devteam
date Fri, 30 Dec 2016 08:11:12 -0500
parents 546ada4a9f43
children 53646aaaafef
line wrap: on
line source

<?xml version="1.0"?>
<tool id="bwa" name="Map with BWA" version="@VERSION@.1">
  <description>- map short reads (&lt; 100 bp) against reference genome</description>
  <macros>
    <import>read_group_macros.xml</import>
    <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 ):
        -L ${analysis_type.L}
      #end if
    #end if
    </token>
    <token name="@read_group_options@">
      #if $use_rg:
        @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>
  <expand macro="requirements" />
  <expand macro="stdio" />
  <command>
<![CDATA[
    @set_reference_fasta_filename@

    ## setup vars for rg handling...
    @define_read_group_helpers@
    #if str( $input_type.input_type_selector ) == "paired":
      #set $rg_auto_name = $read_group_name_default($input_type.fastq_input1, $input_type.fastq_input2)
    #elif str( $input_type.input_type_selector ) in ["single_bam", "paired_bam"]:
      #set $rg_auto_name = $read_group_name_default($input_type.bam_input)
    #else
      #set $rg_auto_name = $read_group_name_default($input_type.fastq_input1)
    #end if
    @set_use_rg_var@
    @set_read_group_vars@

    ## 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 &&

      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 &&

      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 &&

      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 &&

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

      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 &&

      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 sort -O bam -o '$bam_output'
]]>
  </command>

  <inputs>
    <expand macro="reference_source_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="read_group_conditional" />

    <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)">
      <expand macro="dbKeyActionsBwa" />
    </data>
  </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="PL" value="CAPILLARY"/>
      <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 a 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).

-----

**Indices: Selecting reference genomes for BWA**

Galaxy wrapper for BWA allows you select between precomputed and user-defined indices for reference genomes using **Will you select a reference genome from your history or use a built-in index?** flag. This flag has two options:

  1. **Use a built-in genome index** - when selected (this is default), Galaxy provides the user with **Select reference genome index** dropdown. Genomes listed in this dropdown have been pre-indexed with bwa index utility and are ready to be mapped against.  
  2. **Use a genome from the history and build index** - when selected, Galaxy provides the user with **Select reference genome sequence** dropdown. This dropdown is populated by all FASTA formatted files listed in your current history. If your genome of interest is uploaded into history it will be shown there. Selecting a genome from this dropdown will cause Galaxy to first transparently index it using `bwa index` command, and then run mapping with `bwa aln`.
    
If your genome of interest is not listed here you have two choices:

  1. Contact galaxy team using **Help->Support** link at the top of the interface and let us know that an index needs to be added
  2. Upload your genome of interest as a FASTA file to Galaxy history and selected **Use a genome from the history and build index** option.

-----

**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>