Repository revision
7:2645575d1bf2

Repository 'stacks2_tsv2bam'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam

Stacks2: tsv2bam tool metadata
Miscellaneous
Sort reads by RAD locus
stacks2_tsv2bam
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.55+galaxy4
2.55+galaxy4
process_radtags -h |& grep process_radtags | head -n 1 | cut -d" " -f 2
True
Version lineage of this tool (guids ordered most recent to oldest)
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.55+galaxy4 (this tool)
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.55+galaxy3
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.55+galaxy2
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.55+galaxy1
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.55+galaxy0
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.53+galaxy0
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.4+galaxy1
toolshed.g2.bx.psu.edu/repos/iuc/stacks2_tsv2bam/stacks2_tsv2bam/2.4+galaxy0
stacks2_tsv2bam
Requirements (dependencies defined in the <requirements> tag set)
name version type
stacks 2.55 package
python 3.7 package
findutils 4.6.0 package
samtools 1.13 package
Additional information about this tool
#from os.path import splitext
    #import re

    #def clean_ext($identifier)
        #while $identifier.endswith(('.1', '.2', '.fa', '.fq', '.fasta', '.fastq', '.gz', '.gzip', '.sam', '.bam'))
            #set $identifier = splitext($identifier)[0]
        #end while
$identifier#slurp
    #end def

    #def fastq_input_foo( $sample, $read_direction="", $infix="" )
        #set $name = $clean_ext($sample.element_identifier)
        #if $sample.is_collection:
            #set $cur_sample=$sample[$read_direction]
        #else:
            #set $cur_sample=$sample
        #end if

        #if $cur_sample.is_of_type('fastqsanger')
            #set $ext =  "fastq"
            #set $inputype = "fastq"
        #else if $cur_sample.is_of_type('fastqsanger.gz')
            #set $ext = "fastq.gz"
            #set $inputype = "gzfastq"
        #else if $cur_sample.is_of_type('fasta')
            #set $ext = "fasta"
            #set $inputype = "fasta"
        #else if $cur_sample.is_of_type('fasta.gz')
            #set $ext = "fasta.gz"
            #set $inputype = "gzfasta"
        #else
            #set $inputype = "UNKNOWN"
        #end if
        #set $data_path = "stacks_inputs/"+$name+$infix+"."+$ext
        #set $link_cmd = "ln -s '%s' '%s' &&" % ($cur_sample, $data_path)
        #return ($link_cmd, $data_path, $name, $inputype)
    #end def

    ## fastq_input_batch determine link command, access path(s), and input type
    ## for batch tools
    ##
    ## inputs
    ## - sample data set / pair
    ## - type "single" / "paired"
    ## return (link_command, fwd_path, rev_path, inputype)
    ## - link_command bash command(s) to link the data sets
    ## - fwd_path file name of the link to the forward data set
    ## - rev_path file name of the link to the forward data set (if type=paired)
    ## - inputype input type as used in stacks ([gz]fast(a|q))
    #def fastq_input_batch($sample, $type)
        #if $type == "single"
            #set ($link_cmd, $path, $name, $inputype) = $fastq_input_foo($sample, "", "")
            #return ($link_cmd, $path, "", $inputype)
        #else:
            #set ($fwd_link_cmd, $fwd_path, $name, $inputype) = $fastq_input_foo($sample, "forward", ".1")
            #set ($rev_link_cmd, $rev_path, $name, $inputype) = $fastq_input_foo($sample, "reverse", ".2")
            #return ( $fwd_link_cmd+$rev_link_cmd, $fwd_path, $rev_path, $inputype)
        #end if
    #end def

    ## fastq_input_nonbatch determine link command, access path(s), and input type
    ## for non-batch tools (procrad, shortreads, denovomap the former need R[12]_
    ## and the latter needs .[12])
    ##
    ## inputs
    ## - samples list of data set / pair
    ## - type "single" / "paired"
    ## - infix_pattern pattern for the infix of the files (needs to contain %d which is replaced by 1/2)
    ## return (link_command, inputype)
    ## - link_command bash command(s) to link the data sets
    ## - inputype input type as used in stacks ([gz]fast(a|q))
    #def fastq_input_nonbatch( $samples, $type, $infix_pattern )
        #set $link_command = ""
        #for $sample in $samples
            #if $type == "single"
                #set ($lc, $path, $name, $inputype) = $fastq_input_foo($sample, "", "")
                #set link_command += lc
            #else:
                #set ($lc, $path, $name, $inputype) = $fastq_input_foo($sample, "forward", $infix_pattern % (1))
                #set link_command += lc
                #set ($lc, $path, $name, $inputype) = $fastq_input_foo($sample, "reverse", $infix_pattern % (2))
                #set link_command += lc
            #end if
        #end for
        #return ($link_command, $inputype)
    #end def
    

mkdir stacks_inputs stacks_outputs &&

#if $output_log
    ln -s '$output_log' stacks_inputs/tsv2bam.log &&
#end if


    #set $samples = []
    #for $input_file in $input_stacks
        #set $filename = str($input_file.element_identifier)
        #if not filename.endswith('.tsv')
            #set $filename = $filename + ".tsv"
        #end if
        #if re.search('^(?!catalog).+\.(tags|alleles|snps)\.tsv$', $filename)
            ln -s '${input_file}' 'stacks_inputs/$filename' &&
            #if $filename.endswith('.tags.tsv')
                $samples.append($filename[:-9])
            #end if
        #end if
    #end for
    
    

    #for $input_file in $input_cat
        #set $filename = str($input_file.element_identifier)
        #if not filename.endswith('.tsv')
            #set $filename = $filename + ".tsv"
        #end if
        #if re.search('^catalog\.(tags|alleles|snps)\.tsv$', $filename)
            ln -s '${input_file}' 'stacks_inputs/$filename' &&
        #end if
    #end for
    

    #for $input_file in $input_matches
        #set $filename = str($input_file.element_identifier)
        #if not filename.endswith('.tsv')
            #set $filename = $filename + ".tsv"
        #end if
        #if re.search('matches.tsv$', $filename)
            ln -s '${input_file}' 'stacks_inputs/$filename' &&
        #end if
    #end for
    

## link fastq files into stacks_inputs/
#set $paired_reads=False
#for $sample in $input_type.fqinputs:
    #if not $sample:
        #continue
    #end if
    #set $paired_reads=True
    #set ($link_cmd, $data_path, $name, $inputype) = $fastq_input_foo($sample, "reverse", ".2")
    $link_cmd
#end for

tsv2bam
-P stacks_inputs
#if $popmap
    -M '$popmap'
#else
    #for $sample in $samples
        -s '$sample'
    #end for
#end if
#if $paired_reads
    --pe-reads-dir stacks_inputs
#end if
-t \${GALAXY_SLOTS:-1}
## tsv2bam writes to stdout and creates a log file
## - make stdout stderr
## - move the additional log file
2>&1

&& mv stacks_inputs/*matches.bam stacks_outputs

## see comment in gstacks
&& for b in stacks_outputs/*matches.bam; do (samtools view -b "\$b" || true) 2> /dev/null > tmp && mv tmp "\$b"; done
None
False
Functional tests
name inputs outputs required files
Test-1 input_stacks: list collection
input_cat: list collection
input_matches: list collection
add_log: True
name: value
ustacks/PopA_01.alleles.tsv
ustacks/PopA_01.snps.tsv
ustacks/PopA_01.tags.tsv
ustacks/PopA_02.alleles.tsv
ustacks/PopA_02.snps.tsv
ustacks/PopA_02.tags.tsv
cstacks/catalog.alleles.tsv
cstacks/catalog.snps.tsv
cstacks/catalog.tags.tsv
sstacks/PopA_01.matches.tsv
sstacks/PopA_02.matches.tsv
value
Test-2 input_stacks: list collection
input_cat: list collection
input_matches: list collection
input_type|fqinputs: ['demultiplexed/PopA_01.2.fq', 'demultiplexed/PopA_02.2.fq']
input_type|input_type_select: single
popmap: denovo_map/popmap_cstacks.tsv
add_log: True
name: value
ustacks/PopA_01.alleles.tsv
ustacks/PopA_01.snps.tsv
ustacks/PopA_01.tags.tsv
ustacks/PopA_02.alleles.tsv
ustacks/PopA_02.snps.tsv
ustacks/PopA_02.tags.tsv
cstacks/catalog.alleles.tsv
cstacks/catalog.snps.tsv
cstacks/catalog.tags.tsv
sstacks/PopA_01.matches.tsv
sstacks/PopA_02.matches.tsv
demultiplexed/PopA_01.2.fq
demultiplexed/PopA_02.2.fq
denovo_map/popmap_cstacks.tsv
value
Test-3 input_stacks: list collection
input_cat: list collection
input_matches: list collection
input_type|fqinputs: ['demultiplexed/PopA_01.2.fq', 'demultiplexed/PopA_02.2.fq']
input_type|input_type_select: single
popmap: denovo_map/popmap_cstacks.tsv
add_log: True
name: value
ustacks/PopA_01.alleles.tsv
ustacks/PopA_01.snps.tsv
ustacks/PopA_01.tags.tsv
ustacks/PopA_02.alleles.tsv
ustacks/PopA_02.snps.tsv
ustacks/PopA_02.tags.tsv
cstacks/catalog.alleles.tsv
cstacks/catalog.snps.tsv
cstacks/catalog.tags.tsv
sstacks/PopA_01.matches.tsv
sstacks/PopA_02.matches.tsv
demultiplexed/PopA_01.2.fq
demultiplexed/PopA_02.2.fq
denovo_map/popmap_cstacks.tsv
value
Test-4 input_stacks: list collection
input_cat: list collection
input_matches: list collection
input_type|fqinputs: list collection
input_type|input_type_select: paired
add_log: True
name: value
ustacks/PopA_01.alleles.tsv
ustacks/PopA_01.snps.tsv
ustacks/PopA_01.tags.tsv
ustacks/PopA_02.alleles.tsv
ustacks/PopA_02.snps.tsv
ustacks/PopA_02.tags.tsv
cstacks/catalog.alleles.tsv
cstacks/catalog.snps.tsv
cstacks/catalog.tags.tsv
sstacks/PopA_01.matches.tsv
sstacks/PopA_02.matches.tsv
demultiplexed/PopA_01.2.fq
demultiplexed/PopA_02.2.fq
value
Test-5 input_stacks: list collection
input_cat: list collection
input_matches: list collection
input_type|fqinputs: list:paired collection
input_type|input_type_select: paired
add_log: True
name: value
ustacks/PopA_01.alleles.tsv
ustacks/PopA_01.snps.tsv
ustacks/PopA_01.tags.tsv
ustacks/PopA_02.alleles.tsv
ustacks/PopA_02.snps.tsv
ustacks/PopA_02.tags.tsv
cstacks/catalog.alleles.tsv
cstacks/catalog.snps.tsv
cstacks/catalog.tags.tsv
sstacks/PopA_01.matches.tsv
sstacks/PopA_02.matches.tsv
demultiplexed/PopA_01.1.fq
demultiplexed/PopA_01.2.fq
demultiplexed/PopA_02.1.fq
demultiplexed/PopA_02.2.fq
value