diff MethylDackel.xml @ 9:d6787bab7b11 draft default tip

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/methyldackel commit c1027a3f78bca2fd8a53f076ef718ea5adbf4a8a"
author bgruening
date Sat, 05 Jun 2021 09:18:31 +0000
parents 15df15127c18
children
line wrap: on
line diff
--- a/MethylDackel.xml	Fri Aug 24 17:15:24 2018 -0400
+++ b/MethylDackel.xml	Sat Jun 05 09:18:31 2021 +0000
@@ -1,8 +1,10 @@
-<tool id="pileometh" name="MethylDackel" version="0.3.0.1">
+<tool id="pileometh" name="MethylDackel" version="@TOOL_VERSION@+@GALAXY_TOOL_VERSION@" profile="20.01">
     <description>A tool for processing bisulfite sequencing alignments</description>
-    <requirements>
-        <requirement type="package" version="0.3.0">methyldackel</requirement>
-    </requirements>
+    <macros>
+        <import>macros.xml</import>
+    </macros>
+    <expand macro="edam_ontology"/>
+    <expand macro="requirements"/>
     <version_command><![CDATA[MethylDackel --version]]></version_command>
     <command detect_errors="aggressive"><![CDATA[
         #if $reference_source.reference_source_selector == "cached":
@@ -11,73 +13,80 @@
             ln -s $reference_source.ref_file reference.fasta &&
         #end if
 
+       ln -s '$input_sortedAlignBAM' ./infile.bam &&
+       ln -s '${input_sortedAlignBAM.metadata.bam_index}' infile.bai &&
+
         MethylDackel
             $main_task.task
 
             -@ \${GALAXY_SLOTS:-4}
-            #if $main_task.task == "extract":
+            #if $main_task.task == 'extract':
                 -o output
                 $main_task.mergeContext
-                #if str($main_task.OT).strip() != "":
+                #if str($main_task.OT).strip() != '':
                     --OT $main_task.OT
                 #end if
-                #if str($main_task.OB).strip() != "":
+                #if str($main_task.OB).strip() != '':
                     --OB $main_task.OB
                 #end if
-                #if str($main_task.CTOT).strip() != "":
+                #if str($main_task.CTOT).strip() != '':
                     --CTOT $main_task.CTOT
                 #end if
-                #if str($main_task.CTOB).strip() != "":
+                #if str($main_task.CTOB).strip() != '':
                     --CTOB $main_task.CTOB
                 #end if
+                #if str($main_task.mappability_options.mappability_status) == 'True':
+                    -M '${main_task.mappability_options.mappability}'
+                    --mappabilityThreshold $main_task.mappability_options.mappabilityThreshold
+                    --minMappableBases $main_task.mappability_options.minMappableBases            
+                #end if
+            #end if
+            #if $advanced_options.mbias_regionString:
+                -r $advanced_options.mbias_regionString
+            #end if
+            #if $regionBed_options.regionBed_status == 'True':
+                -l '$regionBed_options.regionBed'
+                $regionBed_options.keepStrand
+            #end if
+            $advanced_options.keepDupes
+            $advanced_options.keepSingleton
+            $advanced_options.keepDiscordant
+            -q $advanced_options.min_mapq
+            -p $advanced_options.min_phred
+            #if $advanced_options.methylation_metrics
+                #for $context_methylation in $advanced_options.methylation_metrics:
+                    $context_methylation
+                #end for
+            #end if
+            #if $main_task.task == 'extract':
+                --minOppositeDepth $advanced_options.minOppositeDepth
+                --maxVariantFrac $advanced_options.maxVariantFrac
+                -d $advanced_options.min_pbdepth
+                --ignoreFlags $advanced_options.ignoreFlags
+                --requireFlags $advanced_options.requireFlags
+                #if $main_task.extract_outputs
+                    $main_task.extract_outputs
+                #end if
+                #if str($advanced_options.nOT).strip() != '':
+                    --nOT $advanced_options.nOT
+                #end if
+                #if str($advanced_options.nOB).strip() != '':
+                    --nOB $advanced_options.nOB
+                #end if
+                #if str($advanced_options.nCTOT).strip() != '':
+                    --nCTOT $advanced_options.nCTOT
+                #end if
+                #if str($advanced_options.nCTOB).strip() != '':
+                    --nCTOB $advanced_options.nCTOB
+                #end if
             #end if
 
-            #if $advanced_options.options=="yes":
-                #if $advanced_options.mbias_regionString:
-                    -r $advanced_options.mbias_regionString
-                #end if
-                #if $advanced_options.regionBed:
-                    -l '$advanced_options.regionBed'
-                #end if
-                $advanced_options.keepDupes
-                $advanced_options.keepSingleton
-                $advanced_options.keepDiscordant
-                -q $advanced_options.min_mapq
-                -p $advanced_options.min_phred
-                -D $advanced_options.max_pbdepth
-                #if $main_task.task == "extract":
-                    --minOppositeDepth $advanced_options.minOppositeDepth
-                    --maxVariantFrac $advanced_options.maxVariantFrac
-                    -d $advanced_options.min_pbdepth
-                    --ignoreFlags $advanced_options.ignoreFlags
-                    --requireFlags $advanced_options.requireFlags
-                    $advanced_options.fraction
-                    $advanced_options.counts
-                    $advanced_options.methylKit
-                    $advanced_options.logit
-                    #if str($advanced_options.nOT).strip() != "":
-                        --nOT $advanced_options.nOT
-                    #end if
-                    #if str($advanced_options.nOB).strip() != "":
-                        --nOB $advanced_options.nOB
-                    #end if
-                    #if str($advanced_options.nCTOT).strip() != "":
-                        --nCTOT $advanced_options.nCTOT
-                    #end if
-                    #if str($advanced_options.nCTOB).strip() != "":
-                        --nCTOB $advanced_options.nCTOB
-                    #end if
-                #end if
-                $advanced_options.CHG
-                $advanced_options.CHH
-                $advanced_options.noCpG
-            #end if
 
             reference.fasta
 
-            $input_sortedAlignBAM
+            ./infile.bam
 
-            #if $main_task.task == "mbias":
+            #if $main_task.task == 'mbias':
                 out_mbias $main_task.tsv > out_mbias.tsv &&
                 touch out_mbias_OT.svg &&
                 touch out_mbias_OB.svg &&
@@ -101,301 +110,487 @@
                 <param name="ref_file" type="data" format="fasta" label="Use the folloing dataset as the reference sequence" help="REFERENCE_SEQUENCE; You can upload a FASTA sequence to the history and use it as reference" />
             </when>
         </conditional>
-
-        <param name="input_sortedAlignBAM" multiple="False" type="data" format="bam" label="sorted_alignments.bam"/>
+        <param name="input_sortedAlignBAM" multiple="False" type="data" format="bam" label="Sorted BAM file"/>
+        <conditional name="regionBed_options">
+                <param name="regionBed_status" type="select" label="Use a BED file of regions for inclusion">
+                    <option value="True">Enabled</option>
+                    <option value="False" selected="True">Disabled</option>
+                </param>
+                <when value="True">
+                    <param name="regionBed" type="data" format='bed' label="BED file of regions for inclusion"/>
+                    <param argument="--keepStrand" type="boolean" truevalue="--keepStrand" falsevalue="" checked="False" label="Use the strand column" help="If a BED file is specified, then this option will cause the strand column (column 6) to be utilized, if present. Thus, if a region has a '+' in this column, then only metrics from the top strand will be output. " />
+                </when>
+                <when value="False">
+                </when>
+            </conditional>
         <conditional name="main_task">
             <param name="task" type="select" label="What do you want to do?" >
-                 <option value="extract">Extract methylation metrics from an alignment file in BAM/CRAM format</option>
-                 <option value="mbias">Determine the position-dependent methylation bias in a dataset, producing diagnostic SVG images</option>
+                <option value="extract">Extract methylation metrics from an alignment file in BAM/CRAM format (extract)</option>
+                <option value="mbias">Determine the position-dependent methylation bias in a dataset, producing diagnostic SVG images (mbias)</option>
             </param>
             <when value="extract">
-                <param name="mergeContext" type="boolean" checked="false" truevalue="--mergeContext" falsevalue=""
-                label="Merge per-Cytosine metrics from CpG and CHG contexts into per-CPG or per-CHG metrics" help="(--mergeContext)" />
-                <param name="OT" type="text" value="" label="Original top strand bounds (comma-separated, no spaces)"
-                    help="Inclusion bounds for methylation calls from reads/pairs
-                          origination from the original top strand. Suggested values can
-                          be obtained from the MBias program. Each integer represents a
-                          1-based position on a read. For example --OT A,B,C,D
-                          translates to, 'Include calls at positions from A through B
-                          on read #1 and C through D on read #2'. If a 0 is used a any
-                          position then that is translated to mean start/end of the
-                          alignment, as appropriate. For example, --OT 5,0,0,0 would
-                          include all but the first 4 bases on read #1. Users are
-                          strongly advised to consult a methylation bias plot, for
+                <conditional name="mappability_options">
+                    <param name="mappability_status" type="select" label="Provide a bigWig file containing mappability data" >
+                        <option value="True">Enabled</option>
+                        <option value="False" selected="True">Disabled</option>
+                    </param>
+                    <when value="True">
+                        <param argument="--mappability" type="data" format="bigwig" label="A bigWig file containing mappability data for filtering reads." help="Given a bigWig of Bismap mappability data (using the -M option), MethylDackel can also filter out reads with a mappability score which is too low to support methylation calling. "/>
+                        <param argument="--mappabilityThreshold" type="float" min="0" max="1" value="0.01" label="Mappability threshold" help="If a bigWig file is provided, this sets the threshold mappability value above which a base is considered mappable (default 0.01)." />
+                        <param argument="--minMappableBases" type="integer" value="15" label="Minimum mappable bases" help="If a bigWig file is provided, this sets the number of mappable bases needed for a read to be considered mappable (default 15)." />
+                    </when>
+                    <when value="False">
+                    </when>
+                </conditional>
+                <param argument="--mergeContext" type="boolean" checked="false" truevalue="--mergeContext" falsevalue="" label="Merge per-Cytosine metrics" help="Merge per-Cytosine metrics from CpG and CHG contexts into per-CPG or per-CHG metrics"/>
+                <param argument="--OT" type="text" value="" label="Original top strand bounds (comma-separated, no spaces)"
+                    help="Inclusion bounds for methylation calls from reads/pairs origination from the original top strand. Suggested values can
+                          be obtained from the MBias program. Each integer represents a 1-based position on a read. For example --OT A,B,C,D
+                          translates to, 'Include calls at positions from A through B on read #1 and C through D on read #2'. If a 0 is used a any
+                          position then that is translated to mean start/end of the alignment, as appropriate. For example, --OT 5,0,0,0 would
+                          include all but the first 4 bases on read #1. Users are strongly advised to consult a methylation bias plot, for
                           example by using the MBias program." />
-                <param name="OB" type="text" value="" label="Original bottom strand bounds (comma-separated, no spaces)" />
-                <param name="CTOT" type="text" value="" label="Complementary to the original bottom strand bounds (comma-separated, no spaces)" />
-                <param name="CTOB" type="text" value="" label="Complementary to the original bottom strand bounds (comma-separated, no spaces)" />
+                <param argument="--OB" type="text" value="" label="Original bottom strand bounds (comma-separated, no spaces)" />
+                <param argument="--CTOT" type="text" value="" label="Complementary to the original bottom strand bounds (comma-separated, no spaces)" />
+                <param argument="--CTOB" type="text" value="" label="Complementary to the original bottom strand bounds (comma-separated, no spaces)" 
+                    help="As with --OT, but for the original bottom, complementary to the original top, and complementary to the original bottom
+                          strands, respectively."/>
+                <param name="extract_outputs" type="select" label="Output options">
+                    <option value="" selected="True">CpG context methylation metrics</option>
+                    <option value="--fraction">CpG methylation fractions (--fraction)</option>
+                    <option value="--counts">CpG methylation counts (--counts)</option>
+                    <option value="--logit">CpG logit transformed methylation fraction (--logit)</option>
+                    <option value="--methylKit">CpG context in methylKit format (--methylKit)</option>
+                    <option value="--cytosine_report">Generate an exhaustive cytosine report (--cytosine_report)</option>
+                </param>
             </when>
             <when value="mbias">
                 <param name="tsv" type="boolean" truevalue="--txt" falsevalue=""
-                       label="output tab separated mbias metrics"/>
+                       label="Output tab separated mbias metrics" help="It can be imported into R or another program for manual plotting and analysis. Note that coordinates are 1-based."/>
             </when>
         </conditional>
-        <conditional name="advanced_options">
-            <param name="options" type="select" label="Advanced options">
-                <option value="">Hide advanced options</option>
-                <option value="yes">Display advanced options</option>
-            </param>
-            <when value="yes">
-                <param name="mbias_regionString" type="text" value="" label="Region string in which to extract methylation (e.g. chr1:1-100)"/>
-                <param name="regionBed" type="data" optional="true" format='bed' label="Bed file of regions for inclusion"/>
-                <param name="keepDupes" type="boolean" checked="false" truevalue="--keepDupes" falsevalue=""
-                    label="By default, any alignment marked as a duplicate is ignored. This option causes them to be incorporated" />
-                <param name="keepSingleton" type="boolean" checked="false" truevalue="--keepSingleton" falsevalue=""
-                    label="By default, if only one read in a pair aligns (a singleton) then it's ignored." />
-                <param name="keepDiscordant" type="boolean" checked="false" truevalue="--keepDiscordant" falsevalue=""
-                    label="By default, paired-end alignments with the properly-paired bit unset in the FLAG field are ignored. Note that the definition of concordant and discordant is based on your aligner settings." />
-                <param name="min_mapq" type="integer" value="10" label="Minimum MAPQ threshold to include an alignment (default 10)"/>
-                <param name="min_phred" type="integer" value="5" label="Minimum Phred threshold to include a base (default 5). This must be >0."/>
-                <param name="max_pbdepth" type="integer" value="2000" label="Maximum per-base depth (default 2000)"/>
-                <param name="min_pbdepth" type="integer" value="1" min="1" label="Minimum per-base depth"
-                    help="Minimum per-base depth for reporting output. If you use --mergeContext (above), then this applies to the merged CpG/CHG (default 1). (-d)" />
-
-                <param name="ignoreFlags" type="integer" value="3840" label="Ignore certain alignments"
-                    help="By deault, any alignment marked as secondary (bit 0x100), failing QC (bit 0x200), a PCR/optical duplicate (0x400) or supplemental (0x800) is ignored. This equates to a value of 0xF00 or 3840 in decimal. If you would like to change that, you can specify a new value here." />
-                <param name="requireFlags" type="integer" value="0" label="Require alignment flags"
-                    help="Require each alignment to have all bits in this value present, or else the alignment is ignored. This is equivalent to the -f option in samtools. The default is 0, which includes all alignments." />
-                <param name="minOppositeDepth" type="integer" value="0" min="0" label="Minimum depth for variant avoidance"
-                    help="The minimum depth on the strand opposite of a C required to flag the position as possibly being a SNP. The default is 0 (ignore possible SNPs). Setting this to a value above 0 will cause the position to be ignored if a given fraction of non-G bases are present on the opposite strand and the overall coverage there is at least what is specified here." />
-                <param name="maxVariantFrac" type="float" value="1.0" min="0.0" max="1.0" label="Maximum tolerated variant fraction"
-                    help="If the depth on the strand opposite of a C is at least that specified by 'Minimum depth for variant avoidance', and the fraction of non-G bases exceeds this value, then methylation extraction is skipped for this position." />
+        <section name="advanced_options" title='Advanced options' expanded='false'>
+            <param name="mbias_regionString" type="text" value="" label="Region string in which to extract methylation (e.g. chr1:1-100)"/>
 
-                <param name="fraction" type="boolean" checked="false" truevalue="--fraction" falsevalue=""
-                    label="Extract fractional methylation (only) at each position. This is mutually exclusive with --counts, --logit, and --methylKit" />
-                <param name="counts" type="boolean" checked="false" truevalue="--counts" falsevalue=""
-                    label="Extract base counts (only) at each position. This is mutually exclusive with --fraction, --logit, and --methylKit" />
-                <param name="logit" type="boolean" checked="false" truevalue="--logit" falsevalue=""
-                    label="Extract logit(M/(M+U)) (only) at each position. This is mutually exclusive with --counts, --fraction, and --methylKit" />
-                <param name="methylKit" type="boolean" checked="false" truevalue="--methylKit" falsevalue=""
-                    label="Output in the format required by methylKit. This is mutually exclusive with --counts, --fraction, and --logit" />
-
-                <param name="noCpG" type="boolean" checked="false" truevalue="--noCpG" falsevalue=""
-                    label="Do not output CpG context methylation metrics" />
-                <param name="CHG" type="boolean" checked="false" truevalue="--CHG" falsevalue=""
-                    label="Output CHG context methylation metrics" />
-                <param name="CHH" type="boolean" checked="false" truevalue="--CHH" falsevalue=""
-                    label="Output CHH context methylation metrics" />
-
-                <param name="nOT" type="text" value="" label="Original top strand absolute bounds (comma-separated, no spaces)"
-                    help="Like --OT, but always exclude INT bases from a given end
-                          from inclusion,regardless of the length of an alignment. This
-                          is useful in cases where reads may have already been trimmed
-                          to different lengths, but still none-the-less contain a
-                          certain length bias at one or more ends." />
-                <param name="nOB" type="text" value="" label="Original bottom strand absolute bounds (comma-separated, no spaces)" />
-                <param name="nCTOT" type="text" value="" label="Complementary to the original bottom strand absolute bounds (comma-separated, no spaces)" />
-                <param name="nCTOB" type="text" value="" label="Complementary to the original bottom strand absolute bounds (comma-separated, no spaces)" />
-            </when>
-            <when value=""/>
-        </conditional>
+            <param argument="--keepDupes" type="boolean" checked="false" truevalue="--keepDupes" falsevalue=""
+                label="Keep duplicated alignments" help="By default, any alignment marked as a duplicate is ignored. This option causes them to be incorporated." />
+            <param argument="--keepSingleton" type="boolean" checked="false" truevalue="--keepSingleton" falsevalue=""
+                label="Keep singletons" help="By default, if only one read in a pair aligns (a singleton) then it's ignored." />
+            <param argument="--keepDiscordant" type="boolean" checked="false" truevalue="--keepDiscordant" falsevalue=""
+                label="Keep discordant alignmetns" help="By default, paired-end alignments with the properly-paired bit unset in the FLAG field are ignored. Note that the definition of concordant and discordant is based on your aligner settings." />
+            <param name="min_mapq" argument="-q" type="integer" value="10" label="Minimum MAPQ threshold" help="Minimum MAPQ threshold to include an alignment (default 10)"/>
+            <param name="min_phred" argument="-p" type="integer" value="5" label="Minimum Phred threshold" help="Minimum Phred threshold to include a base (default 5). This must be >0."/>
+            <param name="min_pbdepth" argument="-d" type="integer" value="1" min="1" label="Minimum per-base depth"
+                help="Minimum per-base depth for reporting output. If you use --mergeContext, then this applies to the merged CpG/CHG (default 1)." />
+            <param argument="--ignoreFlags" type="integer" value="3840" label="Ignore certain alignments"
+                help="By deault, any alignment marked as secondary (bit 0x100), failing QC (bit 0x200), a PCR/optical duplicate (0x400) or supplemental (0x800) is ignored. This equates to a value of 0xF00 or 3840 in decimal. If you would like to change that, you can specify a new value here." />
+            <param argument="--requireFlags" type="integer" value="0" label="Require alignment flags"
+                help="Require each alignment to have all bits in this value present, or else the alignment is ignored. This is equivalent to the -f option in samtools. The default is 0, which includes all alignments." />
+            <param argument="--minOppositeDepth" type="integer" value="0" min="0" label="Minimum depth for variant avoidance"
+                help="The minimum depth on the strand opposite of a C required to flag the position as possibly being a SNP. The default is 0 (ignore possible SNPs). Setting this to a value above 0 will cause the position to be ignored if a given fraction of non-G bases are present on the opposite strand and the overall coverage there is at least what is specified here." />
+            <param argument="--maxVariantFrac" type="float" value="1.0" min="0.0" max="1.0" label="Maximum tolerated variant fraction"
+                help="If the depth on the strand opposite of a C is at least that specified by 'Minimum depth for variant avoidance', and the fraction of non-G bases exceeds this value, then methylation extraction is skipped for this position." />
+            <param argument="--nOT" type="text" value="" label="Original top strand absolute bounds (comma-separated, no spaces)"
+                help="Like --OT, but always exclude INT bases from a given end from inclusion,regardless of the length of an alignment. This
+                        is useful in cases where reads may have already been trimmed to different lengths, but still none-the-less contain a
+                        certain length bias at one or more ends." />
+            <param argument="--nOB" type="text" value="" label="Original bottom strand absolute bounds (comma-separated, no spaces)" />
+            <param argument="--nCTOT" type="text" value="" label="Complementary to the original bottom strand absolute bounds (comma-separated, no spaces)" />
+            <param argument="--nCTOB" type="text" value="" label="Complementary to the original bottom strand absolute bounds (comma-separated, no spaces)" 
+                help="As with --nOT, but for the original bottom complementary to the original top, and complementary to the
+                        original bottom strands, respectively."/>
+            <param name="methylation_metrics" type="select" multiple="True" optional="True" display="checkboxes" label="Context methylation metrics options">
+                <option value="--CHG">Output CHG context methylation metrics (--CHG)</option>
+                <option value="--CHH">Output CHH context methylation metrics (--CHH)</option>
+            </param>
+        </section>
     </inputs>
     <outputs>
             <data  name="outFileExtractCpG" format="bedgraph" from_work_dir="output_CpG.bedGraph" 
-                label="${tool.name} on ${on_string}">
+            label="${tool.name} on ${on_string}: CpG metylation levels">
                 <filter>main_task['task']  == "extract"</filter>
-                <filter>not advanced_options['logit']</filter>
-                <filter>not advanced_options['methylKit']</filter>
-                <filter>not advanced_options['counts']</filter>
-                <filter>not advanced_options['fraction']</filter>
-                <filter>not advanced_options['noCpG']</filter>
+                <filter>not main_task['extract_outputs']</filter>
             </data>
             <data  name="outFileExtractCpGLogit" format="bedgraph" from_work_dir="output_CpG.logit.bedGraph" 
-                label="${tool.name} on ${on_string} (logit)">
-                <filter>main_task['task']  == "extract" and advanced_options['logit']</filter>
+                label="${tool.name} on ${on_string}: logit CpG">
+                <filter>main_task['task']  == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--logit" in main_task['extract_outputs']</filter>
             </data>
-            <data  name="outFileExtractCpGMethylKit" format="text" from_work_dir="output_CpG.methylKit" 
-                label="${tool.name} on ${on_string} (MethylKit)">
-                <filter>main_task['task']  == "extract" and advanced_options['methylKit']</filter>
+            <data  name="outFileExtractCpGMethylKit" format="txt" from_work_dir="output_CpG.methylKit" 
+                label="${tool.name} on ${on_string}: methylKit CpG">
+                <filter>main_task['task']  == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--methylKit" in main_task['extract_outputs']</filter>
             </data>
             <data  name="outFileExtractCpGCounts" format="bedgraph" from_work_dir="output_CpG.counts.bedGraph" 
-                label="${tool.name} on ${on_string} (counts)">
-                <filter>main_task['task']  == "extract" and advanced_options['counts']</filter>
+                label="${tool.name} on ${on_string}: counts">
+                <filter>main_task['task']  == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--counts" in main_task['extract_outputs']</filter>
+            </data>
+            <data  name="outFileCytosineReport" format="txt" from_work_dir="output.cytosine_report.txt" 
+                label="${tool.name} on ${on_string}: cytosine report">
+                <filter>main_task['task']  == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--cytosine_report" in main_task['extract_outputs']</filter>
             </data>
             <data  name="outFileExtractCpGFraction" format="bedgraph" from_work_dir="output_CpG.meth.bedGraph" 
-                label="${tool.name} on ${on_string} (fraction)">
-                <filter>main_task['task']  == "extract" and advanced_options['fraction']</filter>
+                label="${tool.name} on ${on_string}: fraction CpG">
+                <filter>main_task['task']  == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--fraction" in main_task['extract_outputs']</filter>
             </data>
             <data  name="outFileExtractCHG" format="bedgraph" from_work_dir="output_CHG.bedGraph" 
-                label="${tool.name} on ${on_string} (CHG)">
-                <filter>main_task['task'] == 'extract'</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHG']</filter>
-                <filter>not advanced_options['logit']</filter>
-                <filter>not advanced_options['methylKit']</filter>
-                <filter>not advanced_options['counts']</filter>
-                <filter>not advanced_options['fraction']</filter>
+                label="${tool.name} on ${on_string}: CHG methylation levels">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>not main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHG" in advanced_options['methylation_metrics']</filter>
             </data>
+             
             <data  name="outFileExtractCHGLogit" format="bedgraph" from_work_dir="output_CHG.logit.bedGraph" 
-                label="${tool.name} on ${on_string} (CHG logit)">
-                <filter>main_task['task']  == "extract" and advanced_options['logit']</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHG']</filter>
+                label="${tool.name} on ${on_string}: logit CHG">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--logit" in main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHG" in advanced_options['methylation_metrics']</filter>
             </data>
-            <data  name="outFileExtractCHGMethylKit" format="text" from_work_dir="output_CHG.methylKit" 
-                label="${tool.name} on ${on_string} (CHG MethylKit)">
-                <filter>main_task['task']  == "extract" and advanced_options['methylKit']</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHG']</filter>
+            
+            <data  name="outFileExtractCHGMethylKit" format="txt" from_work_dir="output_CHG.methylKit" 
+                label="${tool.name} on ${on_string}: methylKit CHG">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--methylKit" in main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHG" in advanced_options['methylation_metrics']</filter>
             </data>
             <data  name="outFileExtractCHGCounts" format="bedgraph" from_work_dir="output_CHG.counts.bedGraph" 
-                label="${tool.name} on ${on_string} (CHG counts)">
-                <filter>main_task['task']  == "extract" and advanced_options['counts']</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHG']</filter>
+                label="${tool.name} on ${on_string}: counts CHG">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--counts" in main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHG" in advanced_options['methylation_metrics']</filter>
             </data>
             <data  name="outFileExtractCHGFraction" format="bedgraph" from_work_dir="output_CHG.meth.bedGraph" 
-                label="${tool.name} on ${on_string} (CHG fraction)">
-                <filter>main_task['task']  == "extract" and advanced_options['fraction']</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHG']</filter>
+                label="${tool.name} on ${on_string}: fraction CHG">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--fraction" in main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHG" in advanced_options['methylation_metrics']</filter>
             </data>
             <data  name="outFileExtractCHH" format="bedgraph" from_work_dir="output_CHH.bedGraph" 
-                label="${tool.name} on ${on_string} (CHH)">
-                <filter>main_task['task']  == 'extract'</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHH']</filter>
-                <filter>not advanced_options['logit']</filter>
-                <filter>not advanced_options['methylKit']</filter>
-                <filter>not advanced_options['counts']</filter>
-                <filter>not advanced_options['fraction']</filter>
+                label="${tool.name} on ${on_string}: CHH metylation levels">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>not main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHH" in advanced_options['methylation_metrics']</filter>
             </data>
             <data  name="outFileExtractCHHLogit" format="bedgraph" from_work_dir="output_CHH.logit.bedGraph" 
-                label="${tool.name} on ${on_string} (CHH logit)">
-                <filter>main_task['task']  == "extract" and advanced_options['logit']</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHH']</filter>
+                label="${tool.name} on ${on_string}: logit CHH">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--logit" in main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHH" in advanced_options['methylation_metrics']</filter>
             </data>
-            <data  name="outFileExtractCHHMethylKit" format="text" from_work_dir="output_CHH.methylKit" 
-                label="${tool.name} on ${on_string} (CHH MethylKit)">
-                <filter>main_task['task']  == "extract" and advanced_options['methylKit']</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHH']</filter>
+    
+            <data  name="outFileExtractCHHMethylKit" format="txt" from_work_dir="output_CHH.methylKit" 
+                label="${tool.name} on ${on_string}: methylKit CHH">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--methylKit" in main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHH" in advanced_options['methylation_metrics']</filter>
             </data>
             <data  name="outFileExtractCHHCounts" format="bedgraph" from_work_dir="output_CHH.counts.bedGraph" 
-                label="${tool.name} on ${on_string} (CHH counts)">
-                <filter>main_task['task']  == "extract" and advanced_options['counts']</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHH']</filter>
+                label="${tool.name} on ${on_string}: counts CHH">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--counts" in main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHH" in advanced_options['methylation_metrics']</filter>
             </data>
             <data  name="outFileExtractCHHFraction" format="bedgraph" from_work_dir="output_CHH.meth.bedGraph" 
-                label="${tool.name} on ${on_string} (CHH fraction)">
-                <filter>main_task['task']  == "extract" and advanced_options['fraction']</filter>
-                <filter>advanced_options['options'] == "yes"</filter>
-                <filter>advanced_options['CHH']</filter>
+                label="${tool.name} on ${on_string}: fraction CHH">
+                <filter>main_task['task'] == "extract"</filter>
+                <filter>main_task['extract_outputs'] and "--fraction" in main_task['extract_outputs']</filter>
+                <filter>advanced_options['methylation_metrics'] and "--CHH" in advanced_options['methylation_metrics']</filter>         
             </data>
             <data  name="outFileMbiasTSV" format="tabular" from_work_dir="out_mbias.tsv"
-                label="${tool.name} on ${on_string} (methylation bias, tsv)">
+                label="${tool.name} on ${on_string}: methylation bias (tsv)">
                 <filter>main_task['task']  == 'mbias'</filter>
                 <filter>main_task['tsv']</filter>
             </data>
+
             <data  name="outFileMbiasCpGOT" format="svg" from_work_dir="out_mbias_OT.svg"
-                label="${tool.name} on ${on_string} (methylation bias, original top strand)">
+                label="${tool.name} on ${on_string}: methylation bias (original top strand)">
                 <filter>main_task['task']  == 'mbias'</filter>
             </data>
             <data  name="outFileMbiasCpGOB" format="svg" from_work_dir="out_mbias_OB.svg"
-                label="${tool.name} on ${on_string} (methylation bias, original bottom strand)">
+                label="${tool.name} on ${on_string}: methylation bias (original bottom strand)">
                 <filter>main_task['task']  == 'mbias'</filter>
             </data>
             <data  name="outFileMbiasCpGCTOT" format="svg" from_work_dir="out_mbias_CTOT.svg"
-                label="${tool.name} on ${on_string} (methylation bias, complementary to the original top strand)">
+                label="${tool.name} on ${on_string}: methylation bias (complementary to the original top strand)">
                 <filter>main_task['task']  == 'mbias'</filter>
             </data>
             <data  name="outFileMbiasCpGCTOB" format="svg" from_work_dir="out_mbias_CTOB.svg"
-                label="${tool.name} on ${on_string} (methylation bias, complementary to the original bottom strand)">
+                label="${tool.name} on ${on_string}: methylation bias (complementary to the original bottom strand)">
                 <filter>main_task['task']  == 'mbias'</filter>
             </data>
     </outputs>
     <tests>
-        <test>
-            <param name="task" value="extract" />
-            <param name="min_mapq" value="2" />
+        <test expect_num_outputs="1">
+            <param name="reference_source_selector" value="history" />
+            <param name="ref_file" value="cg100.fa" ftype="fasta" />
+            <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+            </conditional>
+            <section name="advanced_options">
+                <param name="min_mapq" value="2" />
+            </section>
+            <output name="outFileExtractCpG" ftype="bedgraph">
+                <assert_contents>
+                     <has_size value="1016"/>
+                </assert_contents>
+            </output> 
+        </test>
+        
+        <test expect_num_outputs="4">
             <param name="reference_source_selector" value="history" />
             <param name="ref_file" value="cg100.fa" ftype="fasta" />
             <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
-            <param name="mergeContext" value="false"/>
-            <param name="options" value="yes"/>
-            <output name="outFileExtractCpG" file="test_1.bedGraph" ftype="bedgraph" compare="diff"/>
+            <conditional name="main_task">
+                <param name="task" value="mbias" />
+            </conditional>
+            <section name="advanced_options">
+                <param name="min_mapq" value="2" />
+            </section>
+            <output name="outFileMbiasCpGOT" ftype="svg">
+                 <assert_contents>
+                     <has_size value="14614"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileMbiasCpGOB" ftype="svg">
+                <assert_contents>
+                     <has_size value="0"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileMbiasCpGCTOT" ftype="svg">
+                <assert_contents>
+                     <has_size value="0"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileMbiasCpGCTOB" ftype="svg">
+                <assert_contents>
+                     <has_size value="0"/>
+                </assert_contents>
+            </output> 
         </test>
-        <test>
-            <param name="task" value="mbias" />
-            <param name="min_mapq" value="2" />
-            <param name="options" value="yes"/>
+        <test expect_num_outputs="2">
             <param name="reference_source_selector" value="history" />
             <param name="ref_file" value="cg100.fa" ftype="fasta" />
             <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
-            <output name="outFileMbiasCpGOT" file="test_2_output.svg" ftype="svg" compare="diff"/>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+                <param name="mergeContext" value="false"/>
+            </conditional>
+            <section name="advanced_options">
+                <param name="min_mapq" value="2" />
+                <param name="methylation_metrics" value="--CHH"/>
+            </section>
+            <output name="outFileExtractCpG" ftype="bedgraph">
+                <assert_contents>
+                     <has_size value="1016"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileExtractCHH" ftype="bedgraph">
+                <assert_contents>
+                     <has_size value="86"/>
+                </assert_contents>
+            </output> 
         </test>
-        <test>
-            <param name="task" value="extract" />
-            <param name="min_mapq" value="2" />
-            <param name="options" value="yes"/>
-            <param name="CHH" value="True"/>
+        <test expect_num_outputs="1">
             <param name="reference_source_selector" value="history" />
             <param name="ref_file" value="cg100.fa" ftype="fasta" />
             <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
-            <param name="mergeContext" value="false"/>
-            <param name="options" value="yes"/>
-            <output name="outFileExtractCpG" file="test_1.bedGraph" ftype="bedgraph" compare="diff"/>
-            <output name="outFileExtractCHH" file="test_2.bedGraph" ftype="bedgraph" compare="diff"/>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+                <param name="extract_outputs" value="--fraction" />
+            </conditional>
+            <section name="advanced_options">       
+                <param name="min_mapq" value="2" />
+            </section>
+            <output name="outFileExtractCpGFraction" ftype="bedgraph">
+                <assert_contents>
+                     <has_size value="1067"/>
+                </assert_contents>
+            </output> 
         </test>
-        <test>
-            <param name="task" value="extract" />
-            <param name="min_mapq" value="2" />
+        <test expect_num_outputs="1">
+            <param name="reference_source_selector" value="history" />
+            <param name="ref_file" value="cg100.fa" ftype="fasta" />
+            <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+                <param name="extract_outputs" value="--logit" />
+            </conditional>
+            <section name="advanced_options">       
+                <param name="min_mapq" value="2" />
+            </section>
+            <output name="outFileExtractCpGLogit" ftype="bedgraph">
+                <assert_contents>
+                     <has_size value="845"/>
+                </assert_contents>
+            </output> 
+        </test>
+        <test expect_num_outputs="1">
+            <param name="reference_source_selector" value="history" />
+            <param name="ref_file" value="cg100.fa" ftype="fasta" />
+            <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+                <param name="extract_outputs" value="--methylKit" />
+            </conditional>
+            <section name="advanced_options">
+                <param name="min_mapq" value="2" />
+            </section>
+            <output name="outFileExtractCpGMethylKit" ftype="txt">
+                <assert_contents>
+                     <has_size value="1763"/>
+                </assert_contents>
+            </output> 
+
+        </test>
+        
+        <test expect_num_outputs="5">
             <param name="reference_source_selector" value="history" />
             <param name="ref_file" value="cg100.fa" ftype="fasta" />
             <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
-            <param name="options" value="yes"/>
-            <param name="fraction" value="true" />
-            <output name="outFileExtractCpGFraction" file="test_3.bedGraph" ftype="bedgraph" compare="diff"/>
+            <conditional name="main_task">
+                <param name="task" value="mbias" />
+                <param name="tsv" value="--txt"/>
+            </conditional>
+            <section name="advanced_options">
+                <param name="min_mapq" value="2" />
+            </section>
+            <output name="outFileMbiasTSV" ftype="tabular">
+                <assert_contents>
+                     <has_size value="1213"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileMbiasCpGOT" ftype="svg">
+                 <assert_contents>
+                     <has_size value="14614"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileMbiasCpGOB"  ftype="svg">
+                 <assert_contents>
+                     <has_size value="0"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileMbiasCpGCTOT"  ftype="svg">
+                 <assert_contents>
+                     <has_size value="0"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileMbiasCpGCTOB" ftype="svg">
+                 <assert_contents>
+                     <has_size value="0"/>
+                </assert_contents>
+            </output> 
         </test>
-        <test>
-            <param name="task" value="extract" />
-            <param name="min_mapq" value="2" />
+        
+        <test expect_num_outputs="2">
             <param name="reference_source_selector" value="history" />
             <param name="ref_file" value="cg100.fa" ftype="fasta" />
             <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
-            <param name="options" value="yes"/>
-            <param name="logit" value="true" />
-            <output name="outFileExtractCpGLogit" file="test_4.bedGraph" ftype="bedgraph" compare="diff"/>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+                <param name="extract_outputs" value="--methylKit" />
+            </conditional>
+            <section name="advanced_options">
+                <param name="min_mapq" value="2" />
+                <param name="methylation_metrics" value="--CHG"/>
+            </section>
+            <output name="outFileExtractCpGMethylKit" ftype="txt">
+                 <assert_contents>
+                     <has_size value="1763"/>
+                </assert_contents>
+            </output> 
+            <output name="outFileExtractCHGMethylKit" ftype="txt">
+                 <assert_contents>
+                     <has_size value="45"/>
+                </assert_contents>
+            </output> 
         </test>
-        <test>
-            <param name="task" value="extract" />
-            <param name="min_mapq" value="2" />
+        <!--Test regionBed option-->
+        <test expect_num_outputs="1">
             <param name="reference_source_selector" value="history" />
             <param name="ref_file" value="cg100.fa" ftype="fasta" />
             <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
-            <param name="options" value="yes"/>
-            <param name="methylKit" value="true" />
-            <output name="outFileExtractCpGMethylKit" file="test_5.methylKit" ftype="text" compare="diff"/>
+            <conditional name="regionBed_options">
+                <param name="regionBed_status" value="True"/>
+                <param name="regionBed" ftype="bed" value="cg100.bed"/>
+            </conditional>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+            </conditional>
+            <section name="advanced_options">
+                <param name="min_mapq" value="2" />
+            </section>
+            <output name="outFileExtractCpG" ftype="bedgraph" >
+                <assert_contents>
+                     <has_size value="846"/>
+                </assert_contents>
+            </output> 
         </test>
-        <test>
-            <param name="task" value="mbias" />
-            <param name="min_mapq" value="2" />
-            <param name="options" value="yes"/>
-            <param name="tsv" value="--txt"/>
+
+        <!--Test keepStrand parameter-->
+        <test expect_num_outputs="1">
             <param name="reference_source_selector" value="history" />
             <param name="ref_file" value="cg100.fa" ftype="fasta" />
             <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
-            <output name="outFileMbiasTSV" file="test7_output.tsv" ftype="tabular" compare="diff"/>
+            <conditional name="regionBed_options">
+                <param name="regionBed_status" value="True"/>
+                <param name="regionBed" ftype="bed" value="cg100.bed"/>
+                <param name="keepStrand" value="True"/>
+            </conditional>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+            </conditional>
+            <section name="advanced_options">
+                <param name="min_mapq" value="2" />
+            </section>
+            <output name="outFileExtractCpG" ftype="bedgraph">
+                <assert_contents>
+                     <has_size value="846"/>
+                </assert_contents>
+            </output> 
         </test>
-        <test>
-            <param name="task" value="mbias" />
-            <param name="min_mapq" value="2" />
-            <param name="options" value="yes"/>
-            <param name="regionBed" ftype="bed" value="cg100.bed"/>
-            <param name="tsv" value="--txt"/>
+
+        <!-- Test mapability options-->
+        <test expect_num_outputs="1">
             <param name="reference_source_selector" value="history" />
             <param name="ref_file" value="cg100.fa" ftype="fasta" />
             <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
-            <output name="outFileMbiasTSV" file="test8_output.tsv" ftype="tabular" compare="diff"/>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+                <conditional name="mappability_options">
+                    <param name="mappability_status" value="True"/>
+                    <param name="mappability" value="mappability.bigwig" ftype="bigwig"/>
+                    <param name="mappabilityThreshold" value="0.1"/>
+                    <param name="minMappableBases" value="15"/>
+                </conditional>
+            </conditional>
+            <output name="outFileExtractCpG" ftype="bedgraph">
+                <assert_contents>
+                     <has_size value="66"/>
+                </assert_contents>
+            </output> 
+        </test>
+        <!-- Test cytosine report-->
+        <test expect_num_outputs="1">
+            <param name="reference_source_selector" value="history" />
+            <param name="ref_file" value="cg100.fa" ftype="fasta" />
+            <param name="input_sortedAlignBAM" value="cg_aln.bam" ftype="bam"/>
+            <conditional name="main_task">
+                <param name="task" value="extract" />
+                <param name="extract_outputs" value="--cytosine_report" />
+            </conditional>
+            <output name="outFileExtractCpG" ftype="txt">
+                <assert_contents>
+                     <has_size value="2147"/>
+                </assert_contents>
+            </output> 
         </test>
     </tests>
     <help><![CDATA[
 
-.. image:: $PATH_TO_IMAGES/MethylDackelLogo.png
-   :align: left
-
 **What it does**
 
 MethylDackel (formerly named PileOMeth, which was a temporary name derived due to it using a PILEup to extract METHylation metrics) will process a coordinate-sorted and indexed BAM or CRAM file containing some form of BS-seq alignments and extract per-base methylation metrics from them. MethylDackel requires an indexed fasta file containing the reference genome as well.
@@ -450,9 +645,7 @@
 In an ideal experiment, we expect that the probability of observing a methylated C is constant across the length of any given read. In practice, however, there are often increases/decreases in observed methylation rate at the ends of reads and/or more global changes. These are termed methylation bias and including such regions in the extracted methylation metrics will result in noisier and less accurate data. For this reason, users are strongly encouraged to make a methylation bias plot.
 
 That command will create a methylation bias (mbias for short) plot for each of the strands for which there are valid alignments.
-The resulting mbias graphs are in SVG format and can be viewed in most modern web browsers:
-
-.. image:: $PATH_TO_IMAGES/example.svg
+The resulting mbias graphs are in SVG format and can be viewed in most modern web browsers.
 
 
 If you have paired-end data, both reads in the pair will be shown separately, as is the case above. The program will suggest regions for inclusion ("--OT 2,0,0,98" above) and mark them on the plot, if applicable. The format of this output is described in MethylDackel extract -h. These suggestions should not be accepted blindly; users are strongly encouraged to have a look for themselves and tweak the actual bounds as appropriate. The lines indicate the average methylation percentage at a given position and the shaded regions the 99.9% confidence interval around it. This is useful in gauging how many methylation calls a given position has relative to its neighbors. Note the spike in methylation at the end of read #2 and the corresponding dip at the beginning of read #1. This is common and these regions can be ignored with the suggested trimming bounds. Note also that the numbers refer to the first and last base that should be included during methylation extraction, not the last and first base to ignore!.
@@ -490,6 +683,5 @@
 
 .. _MethylDackel: https://github.com/dpryan79/MethylDackel
     ]]></help>
-    <citations>
-    </citations>
+    <expand macro="citations"/>
 </tool>