changeset 3:c2a5823e4763 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tools/coverm commit 2d02165f40a9f8206a69716b2302bc58f5364982
author iuc
date Wed, 26 Jul 2023 07:35:24 +0000
parents f8cb3f0a19fa
children 1dcea261abbe
files coverm_contig.xml macros.xml
diffstat 2 files changed, 686 insertions(+), 548 deletions(-) [+]
line wrap: on
line diff
--- a/coverm_contig.xml	Tue Mar 28 08:36:07 2023 +0000
+++ b/coverm_contig.xml	Wed Jul 26 07:35:24 2023 +0000
@@ -1,356 +1,450 @@
 <tool id="coverm_contig" name="CoverM contig" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
-    <description>Calculate coverage of individual contigs</description>
+    <description>Calculate read coverage per contig</description>
     <macros>
         <import>macros.xml</import>
     </macros>
+    <expand macro="bio_tools"/>
     <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
+#import re
+#import os
+
+#set $single_fp = []
+#set $fw_fp = []
+#set $rv_fp = []
+#set $interl_fp = []
+#set $ref_fp = []
+#set $bam_fp = []
+
+mkdir 'single/' && 
+mkdir 'fw/' &&
+mkdir 'rv/' && 
+mkdir 'interl/' && 
+mkdir 'ref/' && 
+mkdir 'bam/' && 
+
+#if $mapped.mapped == 'mapped'
+    @BAMS@
+#else
+    #if $mapped.mode.mode == 'individual'
+        @INDIVIDUAL_ASSEMBLY_READS@
+        #set $ref = $mapped.mode.reference
+        @INDIVIDUAL_ASSEMBLY_REF@
+    #else
+        @CO_ASSEMBLY_ALL_READS@
+        #set $refs = $mapped.mode.reference
+        @CO_ASSEMBLY_REF@ 
+    #end if
+#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
+coverm 
+    contig
+#if $mapped.mapped == 'mapped'
+    -b
+    #for $bam in $bam_fp
+        '$bam'
+    #end for
+    $mapped.sharded
+#else
+    #if $fw_fp
+    -1
+        #for $read in $fw_fp
+        '$read'
+        #end for
+    -2
+        #for $read in $rv_fp
+        '$read'
+        #end for
+    #else if $single_fp
+    --single
+        #for $read in $single_fp
+        '$read'
+        #end for
+    #else if $interl_fp
+    --interleaved
+        #for $read in $interl_fp
+        '$read'
+        #end for
+    #end if
+    --reference
+    #for $ref in $ref_fp
+        '$ref'
+    #end for
+    #if $mapped.mode.mode == 'co'
+    $mapped.mode.sharded
+    #end if
+    --mapper '$mapped.mapper'
+#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
+    --min-read-aligned-length $alignment.min_read_aligned_length
+    --min-read-percent-identity $alignment.min_read_percent_identity
+    --min-read-aligned-percent $alignment.min_read_aligned_percent
+    $alignment.proper_pairs_only.proper_pairs_only
+#if $alignment.proper_pairs_only.proper_pairs_only != ''
+    --min-read-aligned-length-pair $alignment.proper_pairs_only.min_read_aligned_length_pair
+    --min-read-percent-identity-pair $alignment.proper_pairs_only.min_read_percent_identity_pair
+    --min-read-aligned-percent-pair $alignment.proper_pairs_only.min_read_aligned_percent_pair
+#end if
 
-            #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
+#for method in $cov.methods
+        '$method'
+#end for
+    --min-covered-fraction $cov.min_covered_fraction
+    --contig-end-exclusion $cov.contig_end_exclusion
+    --trim-min $cov.trim_min
+    --trim-max $cov.trim_max
 
-            --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}
+    --output-format '$output_format'
+    --output-file '$output'
+    --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." />
+        <conditional name="mapped">
+            <expand macro="mapped"/>
+            <when value="mapped">
+                <expand macro="mapped_params"/>
+            </when>
+            <when value="not-mapped">
+                <conditional name="mode">
+                    <expand macro="assembly_mode"/>
+                    <when value="individual">
+                        <expand macro="individual_assembly_reads"/>
+                        <expand macro="individual_assembly_reference"/> 
+                    </when>
+                    <when value="co">
+                        <expand macro="co_assembly_reads"/>
+                        <repeat name="extra_reads" title="Additional reads">
+                            <expand macro="co_assembly_reads"/>
+                        </repeat>
+                        <expand macro="co_assembly_reference"/>
+                    </when>
+                </conditional>
+                <expand macro="mapping"/>
+            </when>
+        </conditional>
+        <expand macro="alignment"/>
+        <section name="cov" title="Coverage calculation options" expanded="false">
+            <param argument="--methods" type="select" multiple="true" label="Method(s) for calculating coverage">
+                <option value="mean" selected="true">mean: Average number of aligned reads overlapping each position on the contig</option>
+                <expand macro="cov_method_options"/>
+            </param>
+            <expand macro="coverage_params"/>
         </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>
+        <expand macro="output_format"/>
     </inputs>
     <outputs>
-        <data name="output1" format="tsv" from_work_dir="./output.tsv"/>
+        <data name="output" format="tabular"/>
     </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"/>
+        <test expect_num_outputs="1">
+            <conditional name="mapped">
+                <param name="mapped" value="not-mapped" />
+                <conditional name="mode">
+                    <param name="mode" value="co"/>
+                    <conditional name="read_type">
+                        <param name="type" value="paired_collection"/>
+                        <param name="paired_reads">
+                            <collection type="list:paired">
+                                <element name="reads_for_seq1_and_seq2">
+                                    <collection type="paired">
+                                        <element name="forward" value="reads_for_seq1_and_seq2.1.fq.gz" ftype="fastqsanger.gz"/>
+                                        <element name="reverse" value="reads_for_seq1_and_seq2.2.fq.gz" ftype="fastqsanger.gz"/>
+                                    </collection>
+                                </element>
                             </collection>
-                        </element>
-                    </collection>
-                </param>
-                <param name="ref_fasta_history" value="7seqs.fna"/>
+                        </param>
+                    </conditional>
+                    <param name="reference" value="7seqs.fna" />
+                    <param name="sharded" value="" />
+                </conditional>
+            </conditional>
+            <section name="alignment">
+                <param name="min_read_aligned_length" value="0" />
+                <param name="min_read_percent_identity" value="0" />
+                <param name="min_read_aligned_percent" value="0" />
+                <conditional name="proper_pairs_only">
+                    <param name="proper_pairs_only" value=""/>
+                </conditional>
+                <param name="exclude_supplementary" value=""/>
+            </section>
+            <section name="cov">
+                <param name="methods" value="mean"/>
+                <param name="trim_min" value="5"/>
+                <param name="trim_max" value="95"/>
+                <param name="min_covered_fraction" value="10"/>
+                <param name="contig_end_exclusion" value="75"/>
+            </section>
+            <param name="output_format" value="dense"/>
+            <output name="output" ftype="tabular">
+                <assert_contents>
+                    <has_text text="Contig"/>
+                    <has_text text="Mean"/>
+                    <has_text text="7seqs.fna"/>
+                    <has_text text="genome1~random_sequence_length_11000"/>
+                    <has_text text="genome2~seq1"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="mapped">
+                <param name="mapped" value="not-mapped" />
+                <conditional name="mode">
+                    <param name="mode" value="individual"/>
+                    <conditional name="read_type">
+                        <param name="type" value="paired"/>
+                        <param name="read1" value="reads_for_seq1_and_seq2.1.fq.gz" ftype="fastqsanger.gz"/>
+                        <param name="read2" value="reads_for_seq1_and_seq2.2.fq.gz" ftype="fastqsanger.gz"/>
+                    </conditional>
+                    <param name="reference" value="7seqs.fna" />
+                    <param name="sharded" value="" />
+                </conditional>
             </conditional>
-            <output name="output1" file="contig_test1.tsv" ftype="tsv" sort="true"/>
-        </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"/>
+            <section name="alignment">
+                <param name="min_read_aligned_length" value="0" />
+                <param name="min_read_percent_identity" value="0" />
+                <param name="min_read_aligned_percent" value="0" />
+                <conditional name="proper_pairs_only">
+                    <param name="proper_pairs_only" value=""/>
+                </conditional>
+                <param name="exclude_supplementary" value=""/>
+            </section>
+            <section name="cov">
+                <param name="methods" value="mean"/>
+                <param name="trim_min" value="5"/>
+                <param name="trim_max" value="95"/>
+                <param name="min_covered_fraction" value="10"/>
+                <param name="contig_end_exclusion" value="75"/>
+            </section>
+            <param name="output_format" value="dense"/>
+            <output name="output" ftype="tabular">
+                <assert_contents>
+                    <has_text text="Contig"/>
+                    <has_text text="Mean"/>
+                    <has_text text="7seqs.fna"/>
+                    <has_text text="genome1~random_sequence_length_11000"/>
+                    <has_text text="genome2~seq1"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="mapped">
+                <param name="mapped" value="not-mapped" />
+                <conditional name="mode">
+                    <param name="mode" value="co"/>
+                    <conditional name="read_type">
+                        <param name="type" value="single"/>
+                        <param name="single" value="bad_reads.interleaved.fq"/>
+                    </conditional>
+                    <param name="reference" value="2seqs.fasta" />
+                    <param name="sharded" value="" />
+                </conditional>
             </conditional>
+            <section name="alignment">
+                <param name="min_read_aligned_length" value="0" />
+                <param name="min_read_percent_identity" value="0" />
+                <param name="min_read_aligned_percent" value="0" />
+                <conditional name="proper_pairs_only">
+                    <param name="proper_pairs_only" value=""/>
+                </conditional>
+                <param name="exclude_supplementary" value=""/>
+            </section>
             <section name="cov">
+                <param name="methods" value="mean"/>
+                <param name="trim_min" value="5"/>
+                <param name="trim_max" value="95"/>
+                <param name="min_covered_fraction" value="10"/>
                 <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" sort="true"/>
-        </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"/>
+            <param name="output_format" value="sparse"/>
+            <output name="output" ftype="tabular">
+                <assert_contents>
+                    <has_text text="Contig"/>
+                    <has_text text="Mean"/>
+                    <has_text text="Sample"/>
+                    <has_text text="2seqs.fasta_0/bad_reads.interleaved.fq_single_0"/>
+                    <has_text text="seq2"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="mapped">
+                <param name="mapped" value="not-mapped" />
+                <conditional name="mode">
+                    <param name="mode" value="co"/>
+                    <conditional name="read_type">
+                        <param name="type" value="interleaved"/>
+                        <param name="interleaved" value="bad_reads.all.interleaved.fa"/>
+                    </conditional>
+                    <param name="reference" value="2seqs.fasta" />
+                    <param name="sharded" value="" />
+                </conditional>
             </conditional>
+            <section name="alignment">
+                <param name="min_read_aligned_length" value="0" />
+                <param name="min_read_percent_identity" value="0" />
+                <param name="min_read_aligned_percent" value="0" />
+                <conditional name="proper_pairs_only">
+                    <param name="proper_pairs_only" value=""/>
+                </conditional>
+                <param name="exclude_supplementary" value=""/>
+            </section>
             <section name="cov">
+                <param name="methods" value="mean"/>
+                <param name="trim_min" value="5"/>
+                <param name="trim_max" value="95"/>
+                <param name="min_covered_fraction" value="10"/>
                 <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" sort="true"/>
-        </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"/>
+            <param name="output_format" value="sparse"/>
+            <output name="output" ftype="tabular">
+                <assert_contents>
+                    <has_text text="Contig"/>
+                    <has_text text="Mean"/>
+                    <has_text text="Sample"/>
+                    <has_text text="2seqs.fasta_0/bad_reads.all.interleaved.fa_interleaved_0"/>
+                    <has_text text="seq1"/>
+                    <has_text text="seq2"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="mapped">
+                <param name="mapped" value="not-mapped" />
+                <conditional name="mode">
+                    <param name="mode" value="co"/>
+                    <conditional name="read_type">
+                        <param name="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"/>
+                    </conditional>
+                    <repeat name="extra_reads">
+                        <conditional name="read_type">
+                            <param name="type" value="paired_collection"/>
+                            <param name="paired_reads">
+                                <collection type="list:paired">
+                                    <element name="reads_for_seq1_and_seq2">
+                                        <collection type="paired">
+                                            <element name="forward" value="reads_for_seq1_and_seq2.1.fq.gz" ftype="fastqsanger.gz"/>
+                                            <element name="reverse" value="reads_for_seq1_and_seq2.2.fq.gz" ftype="fastqsanger.gz"/>
+                                        </collection>
+                                    </element>
+                                </collection>
+                            </param>
+                        </conditional>
+                    </repeat>
+                    <param name="reference" value="2seqs.fasta" />
+                    <param name="sharded" value="" />
+                </conditional>
             </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>
+            <section name="alignment">
+                <param name="min_read_aligned_length" value="0" />
+                <param name="min_read_percent_identity" value="0.95" />
+                <param name="min_read_aligned_percent" value="0" />
+                <conditional name="proper_pairs_only">
+                    <param name="proper_pairs-only" value=""/>
                 </conditional>
+                <param name="exclude_supplementary" value=""/>
             </section>
             <section name="cov">
+                <param name="methods" value="mean"/>
+                <param name="trim_min" value="5"/>
+                <param name="trim_max" value="95"/>
+                <param name="min_covered_fraction" value="10"/>
                 <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" sort="true"/>
-        </test> 
-        <test>
-            <conditional name="reads">
-                <param name="read_type" value="bam"/>
-                <param name="bam" value="tpm_test.bam"/>
+            <param name="output_format" value="sparse"/>
+            <output name="output" ftype="tabular">
+                <assert_contents>
+                    <has_text text="Contig"/>
+                    <has_text text="Mean"/>
+                    <has_text text="Sample"/>
+                    <has_text text="2seqs.fasta_0/reads_for_seq1_and_seq2.1.fq.gz_paired_0"/>
+                    <has_text text="2seqs.fasta_0/reads_for_seq1_and_seq2_paired_collection_00"/>
+                    <has_text text="seq1"/>
+                    <has_text text="seq2"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="mapped">
+                <param name="mapped" value="mapped" />
+                <conditional name="mode">
+                    <param name="mode" value="co"/>
+                    <param name="bam_files" value="tpm_test.bam"/>
+                    <param name="sharded" value="" />
+                </conditional>
             </conditional>
+            <section name="alignment">
+                <param name="min_read_aligned_length" value="0" />
+                <param name="min_read_percent_identity" value="0.95" />
+                <param name="min_read_aligned_percent" value="0" />
+                <conditional name="proper_pairs_only">
+                    <param name="proper_pairs-only" value=""/>
+                </conditional>
+                <param name="exclude_supplementary" value=""/>
+            </section>
             <section name="cov">
-                <param name="mean" value="true"/>
-                <param name="tpm" value="true"/>
+                <param name="methods" value="mean,tpm"/>
+                <param name="trim_min" value="5"/>
+                <param name="trim_max" value="95"/>
+                <param name="min_covered_fraction" value="10"/>
+                <param name="contig_end_exclusion" value="75"/>
             </section>
-            <section name="out">
-                <param name="output_format" value="sparse"/>
-            </section>            
-            <output name="output1" file="contig_test5.tsv" ftype="tsv" sort="true"/>
-        </test> 
-        </tests>
+            <param name="output_format" value="sparse"/>
+            <output name="output" ftype="tabular">
+                <assert_contents>
+                    <has_text text="Contig"/>
+                    <has_text text="Mean"/>
+                    <has_text text="Sample"/>
+                    <has_text text="TPM"/>
+                    <has_text text="tpm_test"/>
+                    <has_text text="genome1~random_sequence_length_11000"/>
+                    <has_text text="genome2~seq1"/>
+                    <has_text text="genome3~random_sequence_length_11001"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="mapped">
+                <param name="mapped" value="mapped" />
+                <conditional name="mode">
+                    <param name="mode" value="co"/>
+                    <param name="bam_files" value="tpm_test.bam"/>
+                    <param name="sharded" value="" />
+                </conditional>
+            </conditional>
+            <section name="alignment">
+                <param name="min_read_aligned_length" value="0" />
+                <param name="min_read_percent_identity" value="0.95" />
+                <param name="min_read_aligned_percent" value="0" />
+                <conditional name="proper_pairs_only">
+                    <param name="proper_pairs-only" value=""/>
+                </conditional>
+                <param name="exclude_supplementary" value=""/>
+            </section>
+            <section name="cov">
+                <param name="methods" value="mean,tpm"/>
+                <param name="trim_min" value="5"/>
+                <param name="trim_max" value="95"/>
+                <param name="min_covered_fraction" value="10"/>
+                <param name="contig_end_exclusion" value="75"/>
+            </section>
+            <param name="output_format" value="sparse"/>
+            <output name="output" ftype="tabular">
+                <assert_contents>
+                    <has_text text="Contig"/>
+                    <has_text text="Mean"/>
+                    <has_text text="Sample"/>
+                    <has_text text="TPM"/>
+                    <has_text text="tpm_test"/>
+                    <has_text text="genome1~random_sequence_length_11000"/>
+                    <has_text text="genome2~seq1"/>
+                    <has_text text="genome3~random_sequence_length_11001"/>
+                </assert_contents>
+            </output>
+        </test>
+    </tests>
     <help><![CDATA[
 .. class:: infomark
     
--- a/macros.xml	Tue Mar 28 08:36:07 2023 +0000
+++ b/macros.xml	Wed Jul 26 07:35:24 2023 +0000
@@ -1,13 +1,17 @@
 <macros>
+    <token name="@TOOL_VERSION@">0.6.1</token>
+    <token name="@VERSION_SUFFIX@">1</token>
+    <token name="@PROFILE@">22.01</token>
     <xml name="requirements">
         <requirements>
             <requirement type="package" version="@TOOL_VERSION@">coverm</requirement>
         </requirements>
     </xml>
-    <token name="@INPUT_FORMATS@">fasta,fastq,fastq.gz,fasta.gz</token>
-    <token name="@TOOL_VERSION@">0.6.1</token>
-    <token name="@VERSION_SUFFIX@">0</token>
-    <token name="@PROFILE@">22.01</token>
+    <xml name="bio_tools">
+        <xrefs>
+            <xref type="bio.tools">coverm</xref>
+        </xrefs>
+    </xml>
     <xml name="citation">
         <citations>
             <citation type="bibtex">
@@ -22,275 +26,315 @@
             </citation>
         </citations>
     </xml>
-    <xml name="genome_opt">
-        <conditional name="genome">
-            <param name="ref_or_genome" type="select" label="Select if you want to specify additional genome files.">
-                <option value="genomic">yes</option>
-                <option value="none" selected="true">No (Only when BAM files are provided)</option>
-            </param>
-            <when value="none">
-                <param argument="--single-genome" type="boolean" truevalue="--single-genome" falsevalue="" checked="false" label="All contigs are from the same genome."/>
-                <param type="text" name="separator" optional="true" label="Character, that separates genome names from contig names in the reference file." >
-                    <sanitizer>
-                        <valid initial="string.punctuation">
-                        </valid>
-                    </sanitizer>
-                </param>
+    <xml name="mapped">
+        <param name="mapped" type="select" label="Have the reads already been mapped to contigs?">
+            <option value="mapped">Yes (no read mapping algorithm will be undertaken)</option>
+            <option value="not-mapped" selected="true">No</option>
+        </param>
+    </xml>
+    <xml name="assembly_mode">
+        <param name="mode" type="select" label="Assembly mode?" help="Useful to know if contigs have been generated all samples together (co-assembly) or on each sample individually (individual assembly)">
+            <option value="individual">Individual assembly (1 contig file per sample)</option>
+            <option value="co" selected="true">Co-assembly (1 contig file for several samples)</option>
+        </param>
+    </xml>
+    <xml name="mapped_params">
+        <conditional name="mode">
+            <expand macro="assembly_mode"/>
+            <when value="individual">
+                <param argument="--bam-files" type="data" format="bam" label="BAM file(s)" help="These must be reference sorted (e.g. with samtools sort) unless sharded is specified, in which case they must be read name sorted (e.g. with samtools sort -n)."/>
+            </when>
+            <when value="co">
+                <param argument="--bam-files" type="data" format="bam" multiple="true" label="BAM file(s)" help="These must be reference sorted (e.g. with samtools sort) unless sharded is specified, in which case they must be read name sorted (e.g. with samtools sort -n)."/>
             </when>
-            <when value="genomic">
-                <conditional name="genomic">
-                    <param type="select" label="Reference genome source" name="source">
-                        <option value="history" selected="true">History</option>
-                        <option value="builtin">Built-in</option>
-                    </param>
-                    <when value="history">
-                        <param type="data" name="fasta_history" multiple="true" label="FASTA files of each genome" format="fasta" />
-                    </when>
-                    <when value="builtin">
-                        <param type="select" name="fasta_builtin" multiple="true" label="Reference genome(s)">
-                            <options from_data_table="all_fasta" />
-                        </param>
-                    </when>
-                </conditional>
+        </conditional>
+        <param argument="--sharded" type="boolean" truevalue="--sharded" falsevalue="" checked="false" label="BAM file(s) read-sorted alignments of a set of reads mapped to multiple reference contig sets?" help="If set, it will choose the best hit for each read pair" />
+    </xml>
+    <token name="@BAMS@"><![CDATA[
+    #if $mapped.mode.mode == 'individual'
+        #set $fn = 'bam/' + re.sub('[^\s\w\-\\.]', '_', str($mapped.mode.bam_files.element_identifier))
+        #silent $bam_fp.append( $fn )
+ln -s '$mapped.mode.bam_files' '$fn' &&
+    #else
+        #for $i, $bam in enumerate($mapped.mode.bam_files)
+            #set $fn = 'bam/' + re.sub('[^\s\w\-\\.]', '_', str($bam.element_identifier)) + '_' + str($i)
+            #silent $bam_fp.append( $fn )
+ln -s '$bam' '$fn' &&
+        #end for
+    #end if
+]]></token>
+    <xml name="genomic">
+        <conditional name="genomic">
+            <param type="select" name="source" label="Source of FASTA files with each genome" >
+                <option value="history" selected="true">History</option>
+                <option value="builtin">Built-in</option>
+            </param>
+            <when value="history">
+                <param argument="--genome-fasta-files" type="data" format="fasta" multiple="true" label="FASTA files of each genome"/>
+            </when>
+            <when value="builtin">
+                <param argument="--genome-fasta-files" type="select" multiple="true" label="Reference genome(s)">
+                    <options from_data_table="all_fasta" />
+                </param>
             </when>
         </conditional>
     </xml>
-    <xml name="genome">
-        <conditional name="genome">
-            <param name="ref_or_genome" type="select" label="Reference sequence mode" help="Select if you want to specify genome file(s) or a FASTA reference file or both. NOTE: If genomic FASTA files are specified, then reference is not needed as a reference FASTA file can be derived by concatenating input genomes. However, while not necessary, reference can be specified if an alternate reference sequence set is desired.">
-                <option value="genomic" selected="true">Reference genome</option>
-                <option value="reference">Contigs (e.g. concatenated genomes or metagenome assembly)</option>
+    <xml name="cond_single_genome">
+        <conditional name="cond_single_genome">
+            <param argument="--single-genome" type="select" label="Are all contigs from the same genome?">
+                <option value="--single-genome">True</option>
+                <option value="">False</option>
             </param>
-            <when value="genomic">
-                <conditional name="genomic">
-                    <param type="select" label="Reference genome source" name="source">
-                        <option value="history" selected="true">History</option>
-                        <option value="builtin">Built-in</option>
+            <when value="--single-genome"/>
+            <when value="">
+                <conditional name="genome_contig_definition">
+                    <param argument="choice" type="select" label="How to get genome names and contig names?">
+                        <option value="default" selected="true">Using default behavior</option>
+                        <option value="genome-definition">Providing a file containing newline-separated list of genome name and contig</option>
+                        <option value="separator">Providing character that separates genome names from contig names in the reference file</option>
                     </param>
-                    <when value="history">
-                        <param type="data" name="fasta_history" multiple="true" label="FASTA files of each genome" format="fasta" />
+                    <when value="default"/>
+                    <when value="genome-definition">
+                        <param argument="--genome-definition" type="data" format="tabular" label="File containing newline-separated list of genome_name and contig, separated by tab, to define the genome of each contig." />
                     </when>
-                    <when value="builtin">
-                        <param type="select" name="fasta_builtin" multiple="true" label="Reference genome(s)">
-                            <options from_data_table="all_fasta" />
-                        </param>
-                    </when>
-                </conditional>
-            </when>
-            <when value="reference">
-                <param type="data" name="ref_source" multiple="true" label="Contigs file(s)" format="fasta" help="If multiple references FASTA files are provided and 'sharded' is specified, then reads will be mapped to references separately as sharded BAMs."/>
-                <conditional name="cond_single_genome">
-                    <param name="single_genome" type="select" label="All contigs are from a single genome">
-                        <option value="--single-genome">True</option>
-                        <option value="false">False</option>
-                    </param>
-                    <when value="--single-genome">
-                        <param type="data" name="genome_definition" format="tsv" optional="true" label="File containing newline-separated list of genome_name and contig, separated by tab, to define the genome of each contig." />
-                    </when>
-                    <when value="false">
-                        <param type="text" argument="--separator" optional="true" label="Character, that separates genome names from contig names in the reference file." >
+                    <when value="separator">
+                        <param argument="--separator" type="text" label="Character that separates genome names from contig names in the reference file." >
                             <sanitizer>
                                 <valid initial="string.punctuation">
                                 </valid>
                             </sanitizer>
                         </param>
                     </when>
-                </conditional>                    
-                <conditional name="add_genome">
-                    <param name="add_genome" type="select" label="Add additional Genome Files">
-                        <option value="true">Yes</option>
-                        <option value="false" selected="true">No</option>
-                    </param>
-                    <when value="true">
-                        <conditional name="add_genomic">
-                            <param type="select" label="Reference genome source" name="source">
-                                <option value="history" selected="true">History</option>
-                                <option value="builtin">Built-in</option>
-                            </param>
-                            <when value="history">
-                                <param type="data" name="fasta_history" multiple="true" label="Single FASTA file of contigs" format="fasta" />
-                            </when>
-                            <when value="builtin">
-                                <param type="select" name="fasta_builtin" multiple="true" label="Reference genome">
-                                    <options from_data_table="all_fasta" />
-                                </param>
-                            </when>
-                        </conditional>                           
-                    </when>
-                    <when value="false">
-                    </when>
                 </conditional>
             </when>
         </conditional>
     </xml>
-    <xml name="reads_for_contig">
-        <conditional name="reads">
-            <param type="select" label="Read type" name="read_type">
-                <option value="paired">Paired end</option>
-                <option value="paired_collection" selected="true">Paired collection</option>
-                <option value="single">Single ended</option>
-                <option value="interleaved">Interleaved</option>
-                <option value="bam">BAM file(s)</option>
-            </param>
+    <token name="@INPUT_FORMATS@">fasta,fastq,fastq.gz,fasta.gz</token>
+    <xml name="read_type">
+        <param name="type" type="select" label="Read type" >
+            <option value="single">Single end</option>
+            <option value="paired">Paired end</option>
+            <option value="paired_collection" selected="true">Paired collection</option>
+            <option value="interleaved">Interleaved</option>
+        </param>
+    </xml>
+    <xml name="paired_reads">
+        <param name="paired_reads" type="data_collection" collection_type="list:paired" format="@INPUT_FORMATS@" label="Collection of paired-end FASTA/Q files(s) for mapping" help="One or more pairs of forward and reverse possibly gzipped FASTA/Q files for mapping in order." />
+    </xml>
+    <xml name="individual_assembly_reads">
+        <conditional name="read_type">
+            <expand macro="read_type"/>
+            <when value="single">
+                <param argument="--single" type="data" format="@INPUT_FORMATS@" label="Single Read" />
+            </when>
             <when value="paired">
-                <param type="data" format="@INPUT_FORMATS@" name="read1" multiple="true" label="Read1" />
-                <param type="data" format="@INPUT_FORMATS@" name="read2" multiple="true" label="Read2" />
-                <param type="data" name="ref_fasta_history" multiple="true" label="FASTA file(s) of contigs" format="fasta" />
+                <param argument="-1" name="read1" type="data" format="@INPUT_FORMATS@" label="Forward FASTA/Q file for mapping" />
+                <param argument="-2" name="read2" type="data" format="@INPUT_FORMATS@" label="Reverse FASTA/Q file for mapping" />
             </when>
             <when value="paired_collection">
-                <param type="data_collection" collection_type="list:paired" format="@INPUT_FORMATS@" name="paired_reads" label="One or more pairs of forward and reverse possibly gzipped FASTA/Q files for mapping in order" />
-                <param type="data" name="ref_fasta_history" multiple="true" label="FASTA file(s) of contigs" format="fasta" />
-            </when>
-            <when value="single">
-                <param type="data" format="@INPUT_FORMATS@" multiple="true" name="single" label="Single Read" />
-                <param type="data" name="ref_fasta_history" multiple="true" label="FASTA file(s) of contigs" format="fasta" />
+                <expand macro="paired_reads"/>
             </when>
             <when value="interleaved">
-                <param type="data" format="@INPUT_FORMATS@" multiple="true" name="single" label="Interleaved" />
-                <param type="data" name="ref_fasta_history" multiple="true" label="FASTA file(s) of contigs" format="fasta" />
-            </when>
-            <when value="bam">
-                 <param type="data" format="bam" name="bam" multiple="true" label="BAM file(s)" help="BAM file(s). These must be reference sorted (e.g. with samtools sort) unless sharded is specified, in which case they must be read name sorted (e.g. with samtools sort -n). When specified, no read mapping algorithm is undertaken."/>
-                <param type="data" name="ref_fasta_history" optional="true" multiple="true" label="FASTA file(s) of contigs" format="fasta" />
+                <param argument="--interleaved" type="data" format="@INPUT_FORMATS@" label="Interleaved FASTA/Q files for mapping" />
             </when>
         </conditional>
-    </xml>     
-    <xml name="reads">
-        <conditional name="reads">
-            <param type="select" label="Read type" name="read_type">
-                <option value="single">Single ended</option>
-                <option value="paired">Paired end</option>
-                <option value="paired_collection" selected="true">Paired collection</option>
-                <option value="interleaved">Interleaved</option>
-                <option value="bam">BAM file(s)</option>
-            </param>
+    </xml>
+    <xml name="ref_or_genome">
+        <param name="ref_or_genome" type="select" label="Genome definition">
+            <option value="contigs" selected="true">From contigs (e.g. concatenated genomes or metagenome assembly)</option>
+            <option value="genomic">From FASTA files with each genome</option>
+        </param>
+    </xml>
+    <xml name="individual_assembly_reference">
+        <param argument="--reference" type="data" format="fasta" label="Contigs"/>
+    </xml>
+    <token name="@INDIVIDUAL_ASSEMBLY_READS@"><![CDATA[
+        #set $reads = $mapped.mode.read_type
+        #if $reads.type == 'single'
+            #set $fn = "single/" + re.sub('[^\s\w\-\\.]', '_', str($reads.single.element_identifier))
+            #silent $single_fp.append( $fn )
+ln -s '$reads.single' '$single_fp' &&
+        #else if $reads.type == 'paired'
+            #set $fn = "fw/" + re.sub('[^\s\w\-\\.]', '_', str($reads.read1.element_identifier))
+            #silent $fw_fp.append( $fn )
+ln -s '$reads.read1' '$fn' &&
+            #set $fn = "rv/" + re.sub('[^\s\w\-\\.]', '_', str($reads.read2.element_identifier))
+ln -s '$reads.read2' '$fn' &&
+            #silent $rv_fp.append( $fn )
+        #else if $reads.type == 'paired_collection'
+            #set $id = re.sub('[^\s\w\-\\.]', '_', str($reads.paired_reads.element_identifier))
+            #set $fn = "fw/" + $id
+            #silent $fw_fp.append( $fn )
+ln -s '$reads.paired_reads.forward' '$fn' &&
+            #set $fn = "rv/" + $id
+            #silent $rv_fp.append( $fn )
+ln -s '$mreads.paired_reads.reverse' '${fn}' &&
+        #else if $reads.type == 'interleaved'
+            #set $fn = "interl/" + re.sub('[^\s\w\-\\.]', '_', str($reads.interleaved.element_identifier))
+            #silent $interl_fp.append( $fn )
+ln -s '$reads.interleaved' '$fn' &&
+        #end if
+]]></token>
+    <token name="@INDIVIDUAL_ASSEMBLY_REF@"><![CDATA[
+        #set $fn = "ref/" + re.sub('[^\s\w\-\\.]', '_', str($ref.element_identifier))
+        #silent $ref_fp.append( $fn )
+ln -s '$ref' '${fn}' &&
+]]></token>
+    <token name="@GENOME_FOR_READS@"><![CDATA[
+            #if $mapped.mode.genome.genomic.source == 'history'
+                #for $i, $genome in enumerate($mapped.mode.genome.genomic.genome_fasta_files)
+                    #set $fn = re.sub('[^\s\w\-\\.]', '_', str($genome.element_identifier))
+                    #silent $genome_fp.append( $fn )
+ln -s '$genome' '$fn' &&
+                #end for
+            #else
+                #for $i, $genome in enumerate($mapped.mode.genome.genomic.genome_fasta_files)
+                    #set $fn = re.sub('[^\s\w\-\\.]', '_', str($genome.fields.path.element_identifier))
+                    #silent $genome_fp.append( $fn )
+ln -s '$genome' '$fn' &&
+                #end for
+            #end if
+]]></token>
+    <xml name="co_assembly_reads">
+        <conditional name="read_type">
+            <expand macro="read_type"/>
+            <when value="single">
+                <param argument="--single" type="data" format="@INPUT_FORMATS@" multiple="true" label="Single Read" />
+            </when>
             <when value="paired">
-                <param type="data" format="@INPUT_FORMATS@" name="read1" multiple="true" label="Read1" />
-                <param type="data" format="@INPUT_FORMATS@" name="read2" multiple="true" label="Read2" />
-                <expand macro="genome"/>
+                <param argument="-1" name="read1" type="data" format="@INPUT_FORMATS@" multiple="true" label="Forward FASTA/Q file(s) for mapping" />
+                <param argument="-2" name="read2" type="data" format="@INPUT_FORMATS@" multiple="true" label="Reverse FASTA/Q file(s) for mapping" />
             </when>
             <when value="paired_collection">
-                <param type="data_collection" collection_type="list:paired" format="@INPUT_FORMATS@" name="paired_reads" label="Collection of paired-reads" help="One or more pairs of forward and reverse possibly gzipped FASTA/Q files for mapping in order." />
-                <expand macro="genome"/>
-            </when>
-            <when value="single">
-                <param type="data" format="@INPUT_FORMATS@" multiple="true" name="single" label="Single Read" />
-                <expand macro="genome"/>
+                <expand macro="paired_reads"/>
             </when>
             <when value="interleaved">
-                <param type="data" format="@INPUT_FORMATS@" multiple="true" name="single" label="Interleaved" />
-                <expand macro="genome"/>
-            </when>
-            <when value="bam">
-                <param type="data" format="bam" name="bam" multiple="true" label="BAM file(s)" help="BAM file(s). These must be reference sorted (e.g. with samtools sort) unless sharded is specified, in which case they must be read name sorted (e.g. with samtools sort -n). When specified, no read mapping algorithm is undertaken."/>
-                <expand macro="genome_opt"/>
+                <param argument="--interleaved" type="data" format="@INPUT_FORMATS@" multiple="true" label="Interleaved FASTA/Q files(s) for mapping" />
             </when>
         </conditional>
     </xml>
-    <xml name="add_reads">
-        <section name="add_reads" title="Add an additional read">
-            <conditional name="extra_read">
-                <param type="select" label="Read type" name="read_type">
-                    <option value="none" selected="true">None</option>
-                    <option value="paired">Paired end</option>
-                    <option value="paired_collection">Paired collection</option>
-                    <option value="single">Single ended</option>
-                    <option value="interleaved">Interleaved</option>
-                    <option value="bam">BAM file(s)</option>
-                </param>
-                <when value="none">
-                </when>
-                <when value="paired">
-                    <param type="data" format="@INPUT_FORMATS@" name="read1" multiple="true" label="Read1" />
-                    <param type="data" format="@INPUT_FORMATS@" name="read2" multiple="true" label="Read2" />
-                </when>
-                <when value="paired_collection">
-                    <param type="data_collection" collection_type="list:paired" format="@INPUT_FORMATS@" name="paired_reads" label="One or more pairs of forward and reverse possibly gzipped FASTA/Q files for mapping in order" />
-                </when>
-                <when value="single">
-                    <param type="data" format="@INPUT_FORMATS@" name="single" multiple="true" label="Single read" />
-                </when>
-                <when value="interleaved">
-                    <param type="data" format="@INPUT_FORMATS@" multiple="true" name="single" label="Interleaved" />
-                </when>
-                <when value="bam">
-                    <param type="data" format="bam" name="bam" multiple="true" label="BAM file(s)" />
-                </when>
-            </conditional>
-        </section>
+    <xml name="co_assembly_reference">
+        <param argument="--reference" type="data" format="fasta" multiple="true" label="Contigs" />
+        <param argument="--sharded" type="boolean" truevalue="--sharded" falsevalue="" checked="false" label="Mapping reads to references separately as sharded BAMs?" />
+    </xml>
+    <token name="@CO_ASSEMBLY_READS@"><![CDATA[
+        #if $reads.type == 'single'
+            #for $i, $read in enumerate($reads.single)
+                #set $fn = "single/" + re.sub('[^\s\w\-\\.]', '_', str($read.element_identifier)) + "_single_" + str($i) + $extra
+                #silent $single_fp.append( $fn )
+ln -s '$read' '$fn' &&
+            #end for
+        #else if $reads.type == 'paired'
+            #for $i, $read in enumerate($reads.read1)
+                #set $id = re.sub('[^\s\w\-\\.]', '_', str($read.element_identifier))
+                #set $fn = "fw/" + $id + "_paired_" + str($i) + $extra
+                #silent $fw_fp.append( $fn )
+ln -s '$read' '$fn' &&
+            #end for
+            #for $i, $read in enumerate($reads.read2)
+                #set $id = re.sub('[^\s\w\-\\.]', '_', str($read.element_identifier))
+                #set $fn = "rv/" + $id + "_paired_" + str($i) + $extra
+                #silent $rv_fp.append( $fn )
+ln -s '$read' '$fn' &&
+            #end for
+        #else if $reads.type == 'paired_collection'
+            #for $i, $read in enumerate($reads.paired_reads)
+                #set $id = re.sub('[^\s\w\-\\.]', '_', str($read.element_identifier))
+                #set $fn = "fw/" + $id + "_paired_collection_" + str($i) + $extra
+                #silent $fw_fp.append( $fn )
+ln -s '$read.forward' '$fn' &&
+                #set $fn = "rv/" + $id + "_paired_collection_" + str($i) + $extra
+                #silent $rv_fp.append( $fn )
+ln -s '$read.reverse' '$fn' &&
+            #end for
+        #else if $reads.type == 'interleaved'
+            #for $i, $read in enumerate($reads.interleaved)
+                #set $id = re.sub('[^\s\w\-\\.]', '_', str($read.element_identifier))
+                #set $fn = "interl/" + $id + "_interleaved_" + str($i) + $extra
+                #silent $interl_fp.append( $fn )
+ln -s '$read' '$fn' &&
+            #end for
+        #end if
+    ]]></token>
+    <token name="@CO_ASSEMBLY_ALL_READS@"><![CDATA[
+        #set $reads = $mapped.mode.read_type
+        #set $extra = ''
+        @CO_ASSEMBLY_READS@
+        #for $j, $s in enumerate($mapped.mode.extra_reads)
+            #set $reads = $s.read_type
+            #set $extra = str($j)
+            @CO_ASSEMBLY_READS@
+        #end for
+    ]]></token>
+    <token name="@CO_ASSEMBLY_REF@"><![CDATA[
+        #for $i, $ref in enumerate($refs)
+            #set $fn = "ref/" + re.sub('[^\s\w\-\\.]', '_', str($ref.element_identifier)) + "_" + str($i)
+            #silent $ref_fp.append( $fn )
+ln -s '$ref' '${fn}' &&
+        #end for
+    ]]></token>
+    <xml name="sharded">
+        <param name="sharded" type="boolean" truevalue="--sharded" falsevalue="" checked="false" label="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." />
     </xml>
     <xml name="mapping">
-        <section name="mapping" title="Mapping options" expanded="false">
-            <param argument="--mapper" optional="true" type="select" label="Mapper" help="Underlying mapping software used. Default: minimap2-sr" >
-                <option value="minimap2-sr">minimap2 with '-x sr' option</option>
-                <option value="minimap2-ont">minimap2 with '-x map-ont' option</option>
-                <option value="minimap2-pb">minimap2 with '-x map-pb' option</option>
-                <option value="minimap2-no-preset">minimap2 with no '-x' option</option>
-                <option value="bwa-mem">BWA-MEM using default parameters</option>
-            </param>
-            <param argument="--min_read-aligned-length" type="integer" min="0" value="0" 
-                label="Min read aligned length" help="Exclude reads with smaller numbers of aligned bases. Default: 0" />
-            <param argument="--min_read-percent-identity" type="float" min="0" max="100" value="0" 
-                label="Min read percent identity" help="Exclude reads by overall percent identity e.g. 95 for 95%. Default: 0" />
-            <param argument="--min_read-aligned-percent" type="float" min="0" max="100" value="0" 
-                label="Min read aligned percentage" help="Exclude reads by percent aligned bases e.g. 95 means 95% 
-                    of the read's bases must be aligned. Default: 0" />
-            <param argument="--min_read-aligned-length-pair" type="integer" min="0" value="0" 
-                label="Min read aligned length pair" help="Exclude pairs with smaller numbers of aligned bases. 
-                    Implies --proper-pairs-only. Default: 0" />
-            <param argument="--min_read-percent-identity-pair" type="float" min="0" max="100" value="0" 
-                label="Min read percent identity pair" help="Exclude pairs by overall percent identity e.g. 95 for 95%. 
-                    Implies --proper-pairs-only. Default: 0" />
-            <param argument="--min_read-aligned-percent-pair" type="float" min="0" max="100" value="0" 
-                label="Min read aligned percentage pair" help="Exclude reads by percent aligned bases e.g. 95 means 95% of 
-                    the read's bases must be aligned. Implies --proper-pairs-only. Default: 0" />
-            <param argument="--proper-pairs-only" type="boolean" truevalue="--proper-pairs-only" falsevalue="" 
-                label="Require reads to be mapped as proper pairs" help="Default: not set"/>
-            <param argument="--exclude-supplementary" type="boolean" truevalue="--exclude-supplementary" falsevalue="" 
-                label="Exclude supplementary alignments" help="Default: not set"/>
-        </section>
+        <param argument="--mapper" type="select" label="Underlying mapping software used">
+            <option value="minimap2-sr"  selected="true">minimap2 with '-x sr' option</option>
+            <option value="minimap2-ont">minimap2 with '-x map-ont' option</option>
+            <option value="minimap2-pb">minimap2 with '-x map-pb' option</option>
+            <option value="minimap2-no-preset">minimap2 with no '-x' option</option>
+            <option value="bwa-mem">BWA-MEM using default parameters</option>
+        </param>
     </xml>
-    <xml name="coverage">
-        <section name="cov" title="Coverage calculation options" expanded="false">
-            <param name="relative_abundance" type="boolean" falsevalue="" truevalue="relative_abundance" label="Relative abundance (default)"/>
-            <param name="mean" type="boolean" falsevalue="" truevalue="mean" label="Mean"/>
-            <conditional name="cond_methods">
-                <param name="trimmed_mean" type="select" label="Trimmed mean">
-                    <option value="trimmed_mean">Yes</option>
+    <xml name="alignment">
+        <section name="alignment" title="Alignment thresholding" expanded="false">
+            <param argument="--min-read-aligned-length" type="integer" min="0" value="0" 
+                label="Minimum number of aligned bases" help="Reads with smaller numbers of aligned bases will be excluded" />
+            <param argument="--min-read-percent-identity" type="float" min="0" max="100" value="0" 
+                label="Minimum overall percent identity" help="Reads with lower overall percent identity will be excluded." />
+            <param argument="--min-read-aligned-percent" type="float" min="0" max="100" value="0" 
+                label="Minimum aligned base percent" help="Reads with lower percent aligned bases will be excluded" />
+            <conditional name="proper_pairs_only">
+                <param argument="--proper-pairs-only" type="select" label="Require reads to be mapped as proper pairs?">
+                    <option value="--proper-pairs-only">Yes</option>
                     <option value="" selected="true">No</option>
                 </param>
-                <when value="trimmed_mean">
-                    <param name="trim_min" type="integer" min="0" value="5" label="Trim min" help="Remove this smallest fraction of positions when calculating trimmed_mean default: 5"/>
-                    <param name="trim_max" type="integer" min="0" value="95" label="Trim max" help="Maximum fraction for trimmed_mean calculations default: 95"/>
+                <when value="--proper-pairs-only">
+                    <param argument="--min_read-aligned-length-pair" type="integer" min="0" value="0" 
+                        label="Minimum number of aligned bases for pairs" help="Pairs with smaller numbers of aligned bases will be excluded." />
+                    <param argument="--min-read-percent-identity-pair" type="float" min="0" max="100" value="0" 
+                        label="Minimum overall percent identity pair for pairs" help="Pairs by lower overall percent identity will be excluded" />
+                    <param argument="--min-read-aligned-percent-pair" type="float" min="0" max="100" value="0" 
+                        label="Minimum percent of read aligned bases for pair" help="Pairs with lower reads percent aligned bases will be excluded" />
                 </when>
                 <when value=""/>
             </conditional>
-            <param name="covered_bases" type="boolean" falsevalue="" truevalue="covered_bases" label="Covered bases"/>
-            <param name="covered_fraction" type="boolean" falsevalue="" truevalue="covered_fraction" label="Covered fraction"/>
-            <param name="variance" type="boolean" falsevalue="" truevalue="variance" label="Variance"/>
-            <param name="length" type="boolean" falsevalue="" truevalue="length" label="Length"/>
-            <param name="count" type="boolean" falsevalue="" truevalue="count" label="Count"/>
-            <param name="metabat" type="boolean" falsevalue="" truevalue="metabat" label="MetaBAT"/>
-            <param name="coverage_histogram" type="boolean" falsevalue="" truevalue="coverage_histogram" label="Coverage histogram"/>
-            <param name="reads_per_base" type="boolean" falsevalue="" truevalue="reads_per_base" label="Reads per base"/>
-            <param name="rpkm" type="boolean" falsevalue="" truevalue="rpkm" label="RPKM"/>
-            <param name="tpm" type="boolean" falsevalue="" truevalue="tpm" label="TPKM"/>
-            <param name="min_covered_fraction" type="integer" min="0" optional="true"
-                label="Min covered fraction" help="Genomes with less coverage than this reported as having zero coverage. Default: 10"/>
-            <param name="contig_end_exclusion" type="integer" min="0" optional="true"
-                label="Contig end exclusion" help="Exclude bases at the ends of reference sequences from calculation. Default: 75"/>
+            <param argument="--exclude-supplementary" type="boolean" truevalue="--exclude-supplementary" falsevalue="" checked="false"
+                label="Exclude supplementary alignments"/>
         </section>
     </xml>
-    <xml name="out">
-        <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>
-            <param name="no_zeros" type="boolean" truevalue="--no-zeros" falsevalue="" optional="true" label="Omit printing of genomes that have zero coverage" />
-            <param argument="--dereplication-output-cluster-definition" type="boolean" truevalue="--dereplication-output-cluster-definition" falsevalue="" label="Output a file of representative TAB member lines." />
-            <param argument="--dereplication-output-representative-fasta-directory-copy" type="boolean" truevalue="--dereplication-output-representative-fasta-directory-copy" falsevalue="" label="Output representative genomes" />
-        </section>
+    <xml name="cov_method_options">
+        <option value="trimmed_mean">trimmed_mean: Average number of aligned reads overlapping each position after removing the most deeply and shallow-ly covered positions. </option>
+        <option value="coverage_histogram">coverage_histogram: Histogram of coverage depths</option>
+        <option value="covered_bases">covered_bases: Number of bases covered by 1 or more reads</option>
+        <option value="variance">variance: Variance of coverage depths</option>
+        <option value="length">length: Length of each contig in base pairs</option>
+        <option value="count">count: Number of reads aligned toq each contig. Note that a single read may be aligned to multiple contigs with supplementary alignments</option>
+        <option value="metabat">metabat: ("MetaBAT adjusted coverage") Coverage as defined in Kang et al 2015</option>
+        <option value="reads_per_base">reads_per_base: Number of reads aligned divided by the length of the contig</option>
+        <option value="rpkm">rpkm: Reads mapped per kilobase of contig, per million mapped reads</option>
+        <option value="tpm">tpm: Transcripts Per Million as described in Li et al 2010</option>
+    </xml>
+    <xml name="coverage_params">
+        <param argument="--trim-min" type="integer" min="0" value="5" label="Smallest fraction of positions to remove when calculating" help="Only used with trimmed_mean method"/>
+        <param argument="--trim-max" type="integer" min="0" value="95" label="Maximum fraction of positions to remove when calculating" help="Only used with trimmed_mean method"/>
+        <param argument="--min-covered-fraction" type="integer" min="0" value="10" label="Minimum covered fraction" help="Genomes with less coverage than this reported as having zero coverage"/>
+        <param argument="--contig-end-exclusion" type="integer" min="0" value="75" label="Base to exclude at contig ends" help="Bases at the ends of reference sequences will be excluded from calculation"/>
+    </xml>
+    <xml name="output_format">
+        <param argument="--output-format" type="select" label="Shape of output">
+            <option value="dense" selected="true">Dense for species-by-site</option>
+            <option value="sparse">Sparse for long format</option>
+        </param>
     </xml>
     <xml name="citations">
         <citations>