Repository revision
33:f76cbb84d67f

Repository 'bowtie2'
hg clone https://toolshed.g2.bx.psu.edu/repos/devteam/bowtie2

Bowtie2 tool metadata
Miscellaneous
Bowtie2
- map reads against reference genome
bowtie2
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.5.4+galaxy0
2.5.4+galaxy0
bowtie2 --version
True
Version lineage of this tool (guids ordered most recent to oldest)
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.5.4+galaxy0 (this tool)
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.5.3+galaxy1
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.5.3+galaxy0
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.5.0+galaxy0
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.4.5+galaxy1
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.4.5+galaxy0
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.4.2+galaxy0
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.4.3+galaxy0
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.4.3
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.4.2
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.4.1
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.4
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.3.1
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.2.2
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.2.1
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.0.1
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.3.0
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.2.8
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.2.6.2
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/2.2.6
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/0.6
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/0.5
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/0.4
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/0.3
toolshed.g2.bx.psu.edu/repos/devteam/bowtie2/bowtie2/0.2
bowtie2
Requirements (dependencies defined in the <requirements> tag set)
name version type
bowtie2 2.5.4 package
samtools 1.22.1 package
Additional information about this tool
## Use pipefail if available to quit with first non-zero exit code
set -o | grep -q pipefail && set -o pipefail;
## prepare bowtie2 index
#set index_path = ''
#if str($reference_genome.source) == "history":
    bowtie2-build --threads \${GALAXY_SLOTS:-4} '$reference_genome.own_file' genome &&
    ln -s -f '$reference_genome.own_file' genome.fa &&
    #set index_path = 'genome'
#else:
    #set index_path = $reference_genome.index.fields.path
#end if

## Link in the input files, so bowtie2 can tell their type

#set compressed="False"
#set reads_are_fastq = True
#if str($library.type) == 'paired_collection':
    #if $library.input_1.forward.is_of_type("fastq.gz", "fastqsanger.gz"):
        #set read1 = "input_f.fastq.gz"
        #set compressed = "GZ"
    #else if $library.input_1.forward.is_of_type("fastq.bz2", "fastqsanger.bz2"):
        #set read1 = "input_f.fastq.bz2"
        #set compressed = "BZ2"
    #else if $library.input_1.forward.is_of_type('fasta'):
        #set reads_are_fastq = False
        #set read1 = "input_f.fasta"
    #else:
        #set read1 = "input_f.fastq"
    #end if
    ln -f -s '${library.input_1.forward}' ${read1} &&

    #if $library.input_1.reverse.is_of_type("fastq.gz", "fastqsanger.gz"):
        #set read2 = "input_r.fastq.gz"
        #set compressed = "GZ"
    #else if $library.input_1.reverse.is_of_type("fastq.bz2", "fastqsanger.bz2"):
        #set read2 = "input_r.fastq.bz2"
        #set compressed = "BZ2"
    #else if $library.input_1.reverse.is_of_type("fasta"):
        #set read2 = "input_r.fasta"
    #else:
        #set read2 = "input_r.fastq"
    #end if
    ln -f -s '${library.input_1.reverse}' ${read2} &&
#else:
    #if $library.input_1.is_of_type("fastq.gz", "fastqsanger.gz"):
        #set read1 = "input_f.fastq.gz"
        #set compressed = "GZ"
    #else if $library.input_1.is_of_type("fastq.bz2", "fastqsanger.bz2"):
        #set read1 = "input_f.fastq.bz2"
        #set compressed = "BZ2"
    #else if $library.input_1.is_of_type("fasta"):
        #set reads_are_fastq = False
        #set read1 = "input_f.fasta"
    #else:
        #set read1 = "input_f.fastq"
    #end if
    ln -f -s '${library.input_1}' ${read1} &&
#end if


## compute number of threads to be used for bowtie2
## the bowtie parameter -p specifies the number of alignment threads to use (in
## addition to a control thread) # just using GALAXY_SLOTS will lead to
## overcommiting ressources (in particular because there may be a samtools sort or view
## running in parallel). 
## for now we use one thread less than GALAXY_SLOTS
THREADS=\${GALAXY_SLOTS:-4} &&
if [ "\$THREADS" -gt 1 ]; then (( THREADS-- )); fi &&

## execute bowtie2

bowtie2

## number of threads
-p "\$THREADS"

## index file path
-x '$index_path'

## Input reads are fasta?
#if not reads_are_fastq:
    -f
#end if

## Input reads
#if str( $library.type ) == "single":
    -U '${read1}'
    #if str( $library.unaligned_file ) == "true":
        #if $compressed == "GZ":
            --un-gz 'unaligned_reads'
        #else if $compressed == "BZ2":
            --un-bz2 'unaligned_reads'
        #else:
            --un 'unaligned_reads'
        #end if
    #end if
    #if str( $library.aligned_file ) == "true":
        #if $compressed == "GZ":
            --al-gz 'aligned_reads'
        #else if $compressed == "BZ2":
            --al-bz2 'aligned_reads'
        #else:
            --al 'aligned_reads'
        #end if
    #end if

#else:
    -1 '${read1}'
    -2 '${read2}'
    #if str( $library.unaligned_file ) == "true":
        #if $compressed == "GZ":
            --un-conc-gz 'unaligned_reads'
        #else if $compressed == "BZ2":
            --un-conc-bz2 'unaligned_reads'
        #else:
            --un-conc 'unaligned_reads'
        #end if
    #end if
    #if str( $library.aligned_file ) == "true":
        #if $compressed == "GZ":
            --al-conc-gz 'aligned_reads'
        #else if $compressed == "BZ2":
            --al-conc-bz2 'aligned_reads'
        #else:
            --al-conc 'aligned_reads'
        #end if
    #end if
    #if str( $library.paired_options.paired_options_selector ) == "yes":
        -I ${library.paired_options.I}
        -X ${library.paired_options.X}
        ${library.paired_options.fr_rf_ff}
        ${library.paired_options.no_mixed}
        ${library.paired_options.no_discordant}
        ${library.paired_options.dovetail}
        ${library.paired_options.no_contain}
        ${library.paired_options.no_overlap}
    #end if
#end if

## Read group information.

#def identifier_or_name($input1)
    #if hasattr($input1, 'element_identifier')
        #return $input1.element_identifier
    #else
        #return $input1.name.rstrip('.gz').rstrip('.fastq').rstrip('.fq').rstrip('.bz2')
    #end if
#end def

#def clean(name)
    #import re
    #set $name_clean = re.sub('[^\w\-_\.]', '_', $name)
    #return $name_clean
#end def

#def read_group_name_default($input1, $input2=None)
    #if $input2 is None
        #return $clean($identifier_or_name($input1))
    #else
        #import itertools
        #set $input_name1 = $clean($identifier_or_name($input1))
        #set $input_name2 = $clean($identifier_or_name($input2))
        #set $common_prefix = ''.join([c[0] for c in itertools.takewhile(lambda x: all(x[0] == y for y in x), zip(*[$input_name1, $input_name2]))])
        #if len($common_prefix) > 3
            #return $common_prefix
        #else
            #return $input_name1
        #end if
    #end if
#end def

#def format_read_group(prefix, value, quote='', arg='')
    #if $value
        #return $arg + $quote + $prefix + $value + $quote
    #else
        #return ''
    #end if
#end def

#def rg_param(name)
    #if $varExists("rg")
        #return $rg.get($name, None)
    #else
        #return $getVar($name, None)
    #end if
#end def

#set $use_rg = True
    
#if str( $library.type ) == "single":
    #set $rg_auto_name = $read_group_name_default($library.input_1)
#else
    #set $rg_auto_name = $read_group_name_default($library.input_1)
#end if

#set $use_rg = str($rg.rg_selector) != "do_not_set"
    

#if $use_rg
    #if $rg_param('read_group_id_conditional') is None
        #set $rg_id = $rg_auto_name
    #elif $rg_param('read_group_id_conditional').do_auto_name == "yes"
        #set $rg_id = $rg_auto_name
    #else
        #set $rg_id = str($rg_param('read_group_id_conditional').ID)
    #end if

    #if $rg_param('read_group_sm_conditional') is None
        #set $rg_sm = ''
    #elif $rg_param('read_group_sm_conditional').do_auto_name == "yes"
        #set $rg_sm = $rg_auto_name
    #else
        #set $rg_sm = str($rg_param('read_group_sm_conditional').SM)
    #end if

    #if $rg_param('PL')
        #set $rg_pl = str($rg_param('PL'))
    #else
        #set $rg_pl = ''
    #end if

    #if $rg_param('read_group_lb_conditional') is None
        #set $rg_lb = ''
    #elif $rg_param('read_group_lb_conditional').do_auto_name == "yes"
        #set $rg_lb = $rg_auto_name
    #else
        #set $rg_lb = str($rg_param('read_group_lb_conditional').LB)
    #end if

    #if $rg_param('CN')
        #set $rg_cn = str($rg_param('CN'))
    #else
        #set $rg_cn = ''
    #end if

    #if $rg_param("DS")
        #set $rg_ds = str($rg_param("DS"))
    #else
        #set $rg_ds = ''
    #end if

    #if $rg_param("DT")
        #set $rg_dt = str($rg_param("DT"))
    #else
        #set $rg_dt = ''
    #end if

    #if $rg_param("FO")
        #set $rg_fo = str($rg_param("FO"))
    #else
        #set $rg_fo = ''
    #end if

    #if $rg_param("KS")
        #set $rg_ks = str($rg_param("KS"))
    #else
        #set $rg_ks = ''
    #end if

    #if $rg_param("PG")
        #set $rg_pg = str($rg_param("PG"))
    #else
        #set $rg_pg = ''
    #end if

    #if $rg_param("PI") != None
        #set $rg_pi = str($rg_param("PI"))
    #else
        #set $rg_pi = ''
    #end if

    #if $rg_param("PU")
        #set $rg_pu = str($rg_param("PU"))
    #else
        #set $rg_pu = ''
    #end if
#end if
    
#if $use_rg
  $format_read_group("", $rg_id, '"', arg='--rg-id ')
  $format_read_group("SM:", $rg_sm, '"', arg='--rg ')
  $format_read_group("PL:", $rg_pl, '"', arg='--rg ')
  $format_read_group("LB:", $rg_lb, '"', arg='--rg ')
  $format_read_group("CN:", $rg_cn, '"', arg='--rg ')
  $format_read_group("DS:", $rg_ds, '"', arg='--rg ')
  $format_read_group("DT:", $rg_dt, '"', arg='--rg ')
  $format_read_group("FO:", $rg_fo, '"', arg='--rg ')
  $format_read_group("KS:", $rg_ks, '"', arg='--rg ')
  $format_read_group("PG:", $rg_pg, '"', arg='--rg ')
  $format_read_group("PI:", $rg_pi, '"', arg='--rg ')
  $format_read_group("PU:", $rg_pu, '"', arg='--rg ')
#end if

## Analysis type
#if ( str( $analysis_type.analysis_type_selector ) == "simple" and str( $analysis_type.presets ) != "no_presets" ):
    $analysis_type.presets
#elif str( $analysis_type.analysis_type_selector ) == "full":
    #if str( $analysis_type.input_options.input_options_selector ) == "yes":
        --skip ${analysis_type.input_options.skip}
        --qupto ${analysis_type.input_options.qupto}
        --trim5 ${analysis_type.input_options.trim5}
        --trim3 ${analysis_type.input_options.trim3}
        ${analysis_type.input_options.qv_encoding}
        ${analysis_type.input_options.solexa_quals}
        ${analysis_type.input_options.int_quals}
    #end if

    #if str( $analysis_type.alignment_options.alignment_options_selector ) == "yes":
        -N ${analysis_type.alignment_options.N}
        -L ${analysis_type.alignment_options.L}
        -i '${analysis_type.alignment_options.i}'
        --n-ceil '${analysis_type.alignment_options.n_ceil}'
        --dpad ${analysis_type.alignment_options.dpad}
        --gbar ${analysis_type.alignment_options.gbar}
        ${analysis_type.alignment_options.ignore_quals}
        ${analysis_type.alignment_options.nofw}
        ${analysis_type.alignment_options.norc}
        ${analysis_type.alignment_options.no_1mm_upfront}
        #if str( $analysis_type.alignment_options.align_mode.align_mode_selector ) == "end-to-end":
            --end-to-end
            --score-min '${analysis_type.alignment_options.align_mode.score_min_ete}'
        #elif str( $analysis_type.alignment_options.align_mode.align_mode_selector ) == "local":
            --local
            --score-min '${analysis_type.alignment_options.align_mode.score_min_loc}'
        #end if
    #end if

    #if str( $analysis_type.scoring_options.scoring_options_selector ) == "yes":
        #if ( str( $analysis_type.alignment_options.alignment_options_selector ) == "yes" and str( $analysis_type.alignment_options.align_mode.align_mode_selector ) == "local" ):
            --ma ${analysis_type.scoring_options.ma}
        #end if
        --mp '${analysis_type.scoring_options.mp}'
        --np ${analysis_type.scoring_options.np}
        --rdg ${analysis_type.scoring_options.rdg_read_open},${analysis_type.scoring_options.rdg_read_extend}
        --rfg ${analysis_type.scoring_options.rfg_ref_open},${analysis_type.scoring_options.rfg_ref_extend}
    #end if

    #if str( $analysis_type.reporting_options.reporting_options_selector ) == "k":
        -k ${analysis_type.reporting_options.k}
    #elif str( $analysis_type.reporting_options.reporting_options_selector ) == "a":
        -a
    #end if

    #if str( $analysis_type.effort_options.effort_options_selector ) == "yes":
        -D ${analysis_type.effort_options.D}
        -R ${analysis_type.effort_options.R}
    #end if
    #if str( $analysis_type.other_options.other_options_selector ) == "yes":
        ${analysis_type.other_options.non_deterministic}
        --seed ${analysis_type.other_options.seed}
    #end if

#elif str( $analysis_type.analysis_type_selector ) == "cline":
    ${analysis_type.cline}
#end if

#if str( $sam_options.sam_options_selector ) == "yes":
    ${sam_options.no_unal}
    ${sam_options.omit_sec_seq}
    ${sam_options.sam_no_qname_trunc}
    ${sam_options.xeq}
    ${sam_options.soft_clipped_unmapped_tlen}
    ${sam_options.reorder}
#end if

## mapping stats (i.e. stderr from bowtie2)
#if $save_mapping_stats
    2> >(tee '$mapping_stats' >&2) 
#end if

## output file
#if str( $sam_options.sam_options_selector ) == "no" or (str( $sam_options.sam_opt ) == "false" and str($sam_options.reorder) == ''):
    ## Convert SAM output to sorted BAM
    ## using the two pipe stages has the following effect
    ## - mapping and sorting run in parallel, during this time sort produces
    ##   presorted temporary files but does not produce output (hence
    ##   view does not run)
    ## - once mapping is finished sort will start to merge the temporary
    ##   files (which should be fast also on a single thread) gives the
    ##   sorted output to view which only compresses the files (now
    ##   using full parallelism again)
    | samtools sort -l 0 -T "\${TMPDIR:-.}" -O bam | samtools view --no-PG -O bam -@ \${GALAXY_SLOTS:-1} -o '$output'
#else if $sam_options.reorder:
    | samtools view --no-PG -b -o '$output' 
#else:
    > '$output'
#end if
        
None
False
Functional tests
name inputs outputs required files
Test-1 library|input_1: bowtie2-fq1.fq
library|unaligned_file: True
library|type: single
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
analysis_type|analysis_type_selector: simple
name: value
name: value
bowtie2-fq1.fq
bowtie2-ref.fasta
value
Test-2 library|input_1: paired collection
library|unaligned_file: False
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
analysis_type|analysis_type_selector: simple
name: value
bowtie2-fq1.fq
bowtie2-fq2.fq
bowtie2-ref.fasta
value
Test-3 library|input_1: paired collection
library|unaligned_file: True
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
analysis_type|analysis_type_selector: simple
name: value
bowtie2-fq1.fq
bowtie2-fq2.fq
bowtie2-ref.fasta
value
Test-4 library|input_1: paired collection
library|unaligned_file: False
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
rg|read_group_id_conditional|ID: rg1
rg|read_group_id_conditional|do_auto_name: no
rg|PL: CAPILLARY
rg|rg_selector: set
analysis_type|analysis_type_selector: simple
sam_options|sam_opt: True
sam_options|sam_options_selector: yes
name: value
bowtie2-fq1.fq
bowtie2-fq2.fq
bowtie2-ref.fasta
value
Test-5 library|input_1: paired collection
library|unaligned_file: False
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
analysis_type|analysis_type_selector: simple
save_mapping_stats: True
name: value
name: value
bowtie2-fq1.fq
bowtie2-fq2.fq
bowtie2-ref.fasta
value
Test-6 library|input_1: paired collection
library|unaligned_file: True
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|index: test_value
reference_genome|source: indexed
analysis_type|analysis_type_selector: simple
name: value
bowtie2-fq1.fq.gz
bowtie2-fq2.fq.gz
value
Test-7 library|input_1: paired collection
library|aligned_file: True
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
analysis_type|analysis_type_selector: simple
name: value
bowtie2-fq1.fq.bz2
bowtie2-fq2.fq.bz2
bowtie2-ref.fasta
value
Test-8 library|input_1: paired collection
library|unaligned_file: True
library|aligned_file: True
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
analysis_type|analysis_type_selector: simple
name: value
bowtie2-fq1.fa
bowtie2-fq2.fa
bowtie2-ref.fasta
value
Test-9 library|input_1: paired collection
library|unaligned_file: False
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
analysis_type|analysis_type_selector: simple
sam_options|reorder: True
sam_options|sam_options_selector: yes
name: value
bowtie2-fq1.fa
bowtie2-fq2.fa
bowtie2-ref.fasta
value
Test-10 library|input_1: paired collection
library|unaligned_file: False
library|paired_options|paired_options_selector: no
library|type: paired_collection
reference_genome|own_file: bowtie2-ref.fasta
reference_genome|source: history
analysis_type|analysis_type_selector: simple
sam_options|sam_opt: True
sam_options|sam_options_selector: yes
name: value
bowtie2-fq1.fa
bowtie2-fq2.fa
bowtie2-ref.fasta
value