view coverm_contig.xml @ 1:688a777e1b19 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tools/coverm commit 2388df7187533fb66b7729730340d2eb7b93c112
author iuc
date Tue, 24 Jan 2023 12:33:11 +0000
parents 6941d0d453ba
children f8cb3f0a19fa
line wrap: on
line source

<tool id="coverm_contig" name="CoverM contig" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description>Calculate coverage of individual contigs</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <command><![CDATA[
         #if $reads.read_type == "single" or $reads.read_type == "interleaved"
            mkdir -p reads1 &&
            #set file_paths1 = []
            #for $input_file in $reads.single
                
                #set $fname = $input_file.element_identifier.replace(" ","_")
                #set $file_path = 'reads1/' + $fname
                ln -s '$input_file' '$file_path' &&
                $file_paths1.append($file_path)
            #end for
        #else if $reads.read_type == "bam"
            mkdir -p bam &&
            #set bam_files = []
            #for $input_file in $reads.bam
                
                #set $fname = $input_file.element_identifier.replace(" ","_")
                #set $file_path = 'bam/' + $fname
                ln -s '$input_file' '$file_path' &&
                $bam_files.append($file_path)
            #end for
        #else if $reads.read_type == "paired"
            mkdir -p paired_reads1 &&
            #set fw_reads1 = []
            #for $input_file in $reads.read1
                
                #set $fname = $input_file.element_identifier.replace(" ","_")
                #set $file_path = 'paired_reads1/' + str($fname)
                ln -s '$input_file' '$file_path' &&
                $fw_reads1.append($file_path)
            #end for
            #set rv_reads1 = []
            #for $input_file in $reads.read2
                
                #set $fname = $input_file.element_identifier.replace(" ","_")
                #set $file_path = 'paired_reads1/' + str($fname)
                ln -s '$input_file' '$file_path' &&
                $rv_reads1.append($file_path)
            #end for
            #silent $fw_reads1.sort()
            #silent $rv_reads1.sort()
        #else
            mkdir -p paired_reads &&
            #set paired_reads1 = []
            #for $i, $input_file in enumerate($reads.paired_reads)
                #set $file_path = 'paired_reads/fw' + str($i)
                ln -s '$input_file.forward' '$file_path' &&
                $paired_reads1.append($file_path)
                #set $file_path = 'paired_reads/rv' + str($i)
                ln -s '$input_file.reverse' '$file_path' &&
                $paired_reads1.append($file_path)
            #end for
        #end if           
        #if $add_reads.extra_read.read_type == "single" or $add_reads.extra_read.read_type == "interleaved"
            mkdir -p add_reads1 &&
            #set add_file_paths1 = []
            #for $input_file in $add_reads.extra_read.single
                #set $fname = $input_file.element_identifier.replace(" ","_")
                #set $file_path = 'add_reads1/' + $fname
                ln -s '$input_file' '$file_path' &&
                $add_file_paths1.append($file_path)
            #end for
        #else if $add_reads.extra_read.read_type == "bam"
            mkdir -p add_bam &&
            #set add_bam_files = []
            #for $input_file in $reads.bam
                #set $fname = $input_file.element_identifier.replace(" ","_")
                #set $file_path = 'add_bam/' + $fname
                ln -s '$input_file' '$file_path' &&
                $add_bam_files.append($file_path)
            #end for
        #else if $add_reads.extra_read.read_type == "paired"
            mkdir -p add_paired_reads1 &&
            #set add_fw_reads1 = []
            #for $input_file in $add_reads.extra_read.read1
                #set $fname = $input_file.element_identifier.replace(" ","_")
                #set $file_path = 'add_paired_reads1/' + str($fname)
                ln -s '$input_file' '$file_path' &&
                $add_fw_reads1.append($file_path)
            #end for
            #set add_rv_reads1 = []
            #for $input_file in $add_reads.extra_read.read2
                #set $fname = $input_file.element_identifier.replace(" ","_")
                #set $file_path = 'add_paired_reads1/' + str($fname)
                ln -s '$input_file' '$file_path' &&
                $add_rv_reads1.append($file_path)
            #end for
            #silent $add_fw_reads1.sort()
            #silent $add_rv_reads1.sort()
        #else if $add_reads.extra_read.read_type == "paired_collection"
            mkdir -p add_paired_reads &&
            #set add_paired_reads1 = []
            #for $i, $input_file in enumerate($add_reads.extra_read.paired_reads)
                #set $ext = $input_file.forward.ext
                #set $file_path = 'add_paired_reads/fw' + str($i) + '.' + $ext
                ln -s '$input_file.forward' '$file_path' &&
                $add_paired_reads1.append($file_path)
                #set $file_path = 'add_paired_reads/rv' + str($i) + '.' + $ext
                ln -s '$input_file.reverse' '$file_path' &&
                $add_paired_reads1.append($file_path)
            #end for
        #end if
        
        #if $reads.ref_fasta_history
            mkdir -p reference &&
            #set ref_files = []
                #for $input_file in $reads.ref_fasta_history
                    #set $fname = $input_file.element_identifier.replace(" ","_")
                    #set $file_path = 'reference/' + $fname
                    ln -s '$input_file' '$file_path' &&
                    $ref_files.append($file_path)
                #end for
        #end if

        coverm contig
            #if $reads.read_type == 'paired'
                -1
                #for $read in $fw_reads1
                    '${read}'
                #end for
                -2
                #for $read in $rv_reads1
                    '${read}'
                #end for
            #else if $reads.read_type == 'paired_collection'
                --coupled
                #for $read in $paired_reads1
                    '${read}'
                #end for
            #else if $reads.read_type == 'single'
                --single
                #for $read in $file_paths1
                    '${read}'
                #end for
            #else if $reads.read_type == 'interleaved'
                --interleaved
                #for $read in $file_paths1
                    '${read}'
                #end for
            #else if $reads.read_type == 'bam'
                -b
                #for $read in $bam_files
                    '${read}'
                #end for
            #end if

            #if $add_reads.extra_read.read_type == 'paired'
                -1
                #for $read in $add_fw_reads1
                    '${read}'
                #end for
                -2
                #for $read in $add_rv_reads1
                    '${read}'
                #end for
            #else if $add_reads.extra_read.read_type == 'paired_collection'
                --coupled
                #for $read in $add_paired_reads1
                    '${read}'
                #end for
            #else if $add_reads.extra_read.read_type == 'single'
                --single
                #for $read in $add_file_paths1
                    '${read}'
                #end for
            #else if $add_reads.extra_read.read_type == 'interleaved'
                --interleaved
                #for $read in $add_file_paths1
                    '${read}'
                #end for
            #else if $add_reads.extra_read.read_type == 'bam'
                #for $read in $add_bam_files
                    '${read}'
                #end for
            #end if
            

            #if $reads.ref_fasta_history:
                --reference
                #for $reference in $ref_files
                    '${reference}'
                #end for
            #end if

            $shar.sharded

            #if $mapping.mapper:
                --mapper $mapping.mapper
            #end if
            #if $mapping.min_read_aligned_length:
                --min-read-aligned-length $mapping.min_read_aligned_length
            #end if
            #if $mapping.min_read_percent_identity:
                --min-read-percent-identity $mapping.min_read_percent_identity
            #end if
            #if $mapping.min_read_aligned_percent:
                --min-read-aligned-percent $mapping.min_read_aligned_percent
            #end if
            #if $mapping.min_read_aligned_length_pair:
                --min-read-aligned-length-pair $mapping.min_read_aligned_length_pair
            #end if
            #if $mapping.min_read_percent_identity_pair:
                --min-read-percent-identity-pair $mapping.min_read_percent_identity_pair
            #end if
            #if $mapping.min_read_aligned_percent_pair:
                --min-read-aligned-percent-pair $mapping.min_read_aligned_percent_pair
            #end if
            $mapping.proper_pairs_only
            $mapping.exclude_supplementary

            --methods $cov.relative_abundance $cov.mean $cov.cond_methods.trimmed_mean $cov.covered_bases $cov.covered_fraction
            $cov.variance $cov.length $cov.count $cov.metabat $cov.coverage_histogram $cov.reads_per_base 
            $cov.rpkm $cov.tpm
            #if $cov.min_covered_fraction:
                --min-covered-fraction $cov.min_covered_fraction
            #end if
            #if $cov.contig_end_exclusion:
                --contig-end-exclusion $cov.contig_end_exclusion
            #end if
            #if $cov.cond_methods.trimmed_mean == "trimmed_mean"
                #if $cov.cond_methods.trim_min:
                    --trim-min $cov.cond_methods.trim_min
                #end if
                #if $cov.cond_methods.trim_max:
                    --trim_max $cov.cond_methods.trim_max
                #end if
            #end if

            #if $out.output_format:
                --output-format $out.output_format
            #end if
            --output-file output.tsv
            --threads \${GALAXY_SLOTS:-1}
    ]]></command>
    <inputs>
        <expand macro="reads_for_contig" />
        <expand macro="add_reads" />
        <section name="shar" title="Sharding" expanded="false">
            <param name="sharded" type="boolean" optional="true" truevalue="--sharded" falsevalue="" label="If -b/--bam-files was used: Input BAM files are read-sorted alignments of a set of reads mapped to multiple reference contig sets. Choose the best hit for each read pair. Otherwise if mapping was carried out: Map reads to each reference, choosing the best hit for each pair." />
        </section>
            <expand macro="mapping"/>
            <expand macro="coverage"/>
        <section name="out" title="Output options" expanded="false">
            <param name="output_format" type="select" label="Shape of output" help="'Sparse' for long format, 'dense' for species-by-site. Default: dense]">
                <option value="dense" selected="true">Dense</option>
                <option value="sparse">Sparse</option>
            </param>
        </section>
    </inputs>
    <outputs>
        <data name="output1" format="tsv" from_work_dir="./output.tsv"/>
    </outputs>
    <tests>
        <test>
            <conditional name="reads">
                <param name="read_type" value="paired_collection"/>
                <param name="paired_reads">
                    <collection type="list:paired">
                        <element name="reads_for_seq1_and_seq2..fq">
                            <collection type="paired">
                                <element name="forward" value="reads_for_seq1_and_seq2.1.fq.gz"/>
                                <element name="reverse" value="reads_for_seq1_and_seq2.2.fq.gz"/>
                            </collection>
                        </element>
                    </collection>
                </param>
                <param name="ref_fasta_history" value="7seqs.fna"/>
            </conditional>
            <output name="output1" file="contig_test1.tsv" ftype="tsv"/>
        </test> 
        <test>
            <conditional name="reads">
                <param name="read_type" value="single"/>
                <param name="single" value="bad_reads.interleaved.fq"/>
                <param name="ref_fasta_history" value="2seqs.fasta"/>
            </conditional>
            <section name="cov">
                <param name="contig_end_exclusion" value="0"/>
            </section>
            <section name="out">
                <param name="output_format" value="sparse"/>
            </section>            
            <output name="output1" file="contig_test2.tsv" ftype="tsv"/>
        </test> 
        <test>
            <conditional name="reads">
                <param name="read_type" value="interleaved"/>
                <param name="single" value="bad_reads.all.interleaved.fa"/>
                <param name="ref_fasta_history" value="2seqs.fasta"/>
            </conditional>
            <section name="cov">
                <param name="contig_end_exclusion" value="0"/>
            </section>
            <section name="mapping">
                <param name="min_read_aligned_length_pair" value="300"/>
                <param name="proper_pairs_only" value="true"/>
            </section>
            <section name="out">
                <param name="output_format" value="sparse"/>
            </section>            
            <output name="output1" file="contig_test3.tsv" ftype="tsv"/>
        </test> 
        <test>
            <conditional name="reads">
                <param name="read_type" value="paired"/>
                <param name="read1" value="reads_for_seq1_and_seq2.1.fq.gz"/>
                <param name="read2" value="reads_for_seq1_and_seq2.2.fq.gz"/>
                <param name="ref_fasta_history" value="2seqs.fasta"/>
            </conditional>
            <section name="add_reads">
                <conditional name="extra_read">
                    <param name="read_type" value="paired_collection"/>
                    <param name="paired_reads">
                        <collection type="list:paired">
                            <element name="reads_for_seq1_and_seq2..fq">
                                <collection type="paired">
                                    <element name="forward" value="reads_for_seq1_and_seq2.1.fq.gz"/>
                                    <element name="reverse" value="reads_for_seq1_and_seq2.2.fq.gz"/>
                                </collection>
                            </element>
                        </collection>
                    </param>
                </conditional>
            </section>
            <section name="cov">
                <param name="contig_end_exclusion" value="0"/>
            </section>
            <section name="mapping">
                <param name="--min-read-percent-identity" value="0.95"/>
            </section>
            <output name="output1" file="contig_test4.tsv" ftype="tsv"/>
        </test> 
        <test>
            <conditional name="reads">
                <param name="read_type" value="bam"/>
                <param name="bam" value="tpm_test.bam"/>
            </conditional>
            <section name="cov">
                <param name="mean" value="true"/>
                <param name="tpm" value="true"/>
            </section>
            <section name="out">
                <param name="output_format" value="sparse"/>
            </section>            
            <output name="output1" file="contig_test5.tsv" ftype="tsv"/>
        </test> 
        </tests>
    <help><![CDATA[
.. class:: infomark
    
**Method for calculating coverage**

Calculation of genome-wise coverage (genome mode) is similar to calculating contig-wise (contig mode) coverage, except that the unit of reporting is per-genome rather than per-contig. For calculation methods which exclude base positions based on their coverage, all positions from all contigs are considered together. 

- Relative abundance: Percentage relative abundance of each genome, and the unmapped read percentage
- Mean: Average number of aligned reads overlapping each position on the genome
- Trimmed mean: Average number of aligned reads overlapping each position after removing the most deeply and shallowly covered positions.
- Covered fraction: Fraction of genome covered by 1 or more reads
- Covered bases: Number of bases covered by 1 or more reads
- Variance: Variance of coverage depths
- Length: Length of each genome in base pairs
- Count: Number of reads aligned toq each genome. Note that a single read may be aligned to multiple genomes with supplementary alignments
- Reads per base: Number of reads aligned divided by the length of the genome
- MetaBAT: Reproduction of the `MetaBAT <https://bitbucket.org/berkeleylab/metabat>`_ tool output
- Coverage histogram: Histogram of coverage depths
- RPKM: Reads mapped per kilobase of genome, per million mapped reads
- TPM: Transcripts Per Million as described in `Li et al 2010 <https://doi.org/10.1093/bioinformatics/btp692>`_

    ]]></help>
    <expand macro="citation"/>
</tool>