diff bcftools_norm.xml @ 26:051e5060b390 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bcftools commit f6efda26965eb73c9107d367fd5ffdf246ed0dbc
author iuc
date Tue, 02 Dec 2025 07:55:48 +0000
parents 36b301c20b95
children
line wrap: on
line diff
--- a/bcftools_norm.xml	Sun Aug 18 09:37:43 2024 +0000
+++ b/bcftools_norm.xml	Tue Dec 02 07:55:48 2025 +0000
@@ -4,30 +4,16 @@
         <token name="@EXECUTABLE@">norm</token>
         <import>macros.xml</import>
     </macros>
-    <expand macro="bio_tools" />
+    <expand macro="bio_tools"/>
     <expand macro="requirements">
         <expand macro="samtools_requirement"/>
-        <!-- gawk only required for current bcftools norm bug workaround
-        Remove once fixed (see command section below -->
-        <requirement type="package" version="5.0.1">gawk</requirement>
     </expand>
-    <expand macro="version_command" />
+    <expand macro="version_command"/>
     <command detect_errors="aggressive"><![CDATA[
-@PREPARE_ENV@
 @PREPARE_INPUT_FILE@
 #set $section = $reference_source
 @PREPARE_FASTA_REF@
 
-## The next two lines are a workaround for a bug in bcftools norm up to version
-## 1.9, which caused indel normalization to be case-sensitive
-## see:
-## https://github.com/samtools/bcftools/commit/65b211da1f5cdbf1c7c11eb610481a736fa88bda
-## https://github.com/samtools/bcftools/commit/77b0a27a156803e382d60651ff94ea0bd95fad0f
-## With the next release of bcftools, this should be fixed and, at that point,
-## the time-consuming on-the-fly uppercasing should be removed again.
-awk '{ if ($0 !~ />/) {print toupper($0)} else {print $0} }' '$input_fa_ref' > ref_upper.fa &&
-#set $input_fa_ref = 'ref_upper.fa'
-
 #set $section = $sec_restrict
 @PREPARE_TARGETS_FILE@
 @PREPARE_REGIONS_FILE@
@@ -41,7 +27,7 @@
 #if $rm_dup:
   --rm-dup "$rm_dup"
 #end if
-$atomize
+$atomization
 #if $old_rec_tag
   --old-rec-tag '$old_rec_tag'
 #end if
@@ -51,10 +37,16 @@
 #if $multiallelics.mode == '+':
   ${multiallelics.strict_filter}
 #end if
-
 #if $sec_default.site_win:
   --site-win ${sec_default.site_win}
 #end if
+--sort ${sec_default.sort}
+#if str($sec_filter_norm.include):
+  --include '${sec_filter_norm.include}'
+#end if
+#if str($sec_filter_norm.exclude):
+  --exclude '${sec_filter_norm.exclude}'
+#end if
 
 #set $section = $sec_restrict
 @REGIONS@
@@ -69,34 +61,30 @@
 ]]>
     </command>
     <inputs>
-        <expand macro="macro_input" />
-        <expand macro="macro_fasta_ref" />
-        <param name="check_ref" type="select" display="radio"
-        label="When any REF allele does not match the reference genome base"
-        help="Warnings about REF mismatches will be emitted to the standard
-        error (stderr) stream, and it is recommended to check there for
-        problems if you choose not to exit with an error immediately upon
-        encountering a mismatch.">
+        <expand macro="macro_input"/>
+        <expand macro="macro_fasta_ref"/>
+        <param name="check_ref" type="select" display="radio" label="When any REF allele does not match the reference genome base" help="Warnings about REF mismatches will be emitted to the standard error (stderr) stream, and it is recommended to check there for problems if you choose not to exit with an error immediately upon encountering a mismatch.">
             <option value="w">ignore the problem (-w)</option>
             <option value="wx">exclude the variant record from the output (-wx)</option>
             <option value="ws">fix the variant record using the reference genome information (-ws)</option>
             <option value="e">exit with an error (-e)</option>
         </param>
-        <param argument="--atomize" type="boolean" truevalue="--atomize" falsevalue="" checked="false" 
-            label="Atomize" help="Decompose complex variants (e.g. MNVs become consecutive SNVs)" />
-        <param argument="--do-not-normalize" name="normalize_indels" type="boolean" truevalue="" falsevalue="--do-not-normalize" checked="false"
-        label="Left-align and normalize indels?" />
+        <param name="atomization" type="select" display="radio" label="Atomize" help="Decompose complex variants (e.g. MNVs become consecutive SNVs)">
+            <option value="">Do not atomize</option>
+            <option value="--atomize">Atomize and use * ALT allele for proper genotype representation (--atomize)</option>
+            <option value="--atomize --atom-overlaps .">Atomize and accept missing genotype information (legacy behavior; --atomize --atom-overlaps .)</option>
+        </param>
+        <param argument="--do-not-normalize" name="normalize_indels" type="boolean" truevalue="" falsevalue="--do-not-normalize" checked="false" label="Left-align and normalize indels?"/>
         <param argument="--old-rec-tag" type="text" value="" optional="true" label="Annotate modified records with INFO/STR indicating the original variant">
             <sanitizer invalid_char="">
                 <valid initial="string.letters,string.digits">
-                    <add value="_" />
-                    <add value="/" />
+                    <add value="_"/>
+                    <add value="/"/>
                 </valid>
             </sanitizer>
             <validator type="regex">[0-9a-zA-Z_/]+</validator>
         </param>
-        <param name="rm_dup" type="select" display="radio"
-        label="Perform deduplication for the folowing types of variant records">
+        <param name="rm_dup" type="select" display="radio" label="Perform deduplication for the folowing types of variant records">
             <option value="">do not deduplicate any records</option>
             <option value="snps">snps</option>
             <option value="indels">indels</option>
@@ -106,142 +94,141 @@
         <conditional name="multiallelics">
             <param name="mode" type="select" label="~multiallelics">
                 <option value="">preserve multiallelic/biallelic sites</option>
-                <option value="-">split multiallelic sites into biallelic records (-)</option> 
-                <option value="+">join biallelic sites into multiallelic records (+)</option> 
+                <option value="-">split multiallelic sites into biallelic records (-)</option>
+                <option value="+">join biallelic sites into multiallelic records (+)</option>
             </param>
-            <when value="" />
+            <when value=""/>
             <when value="-">
-                <param name="multiallelic_types" type="select" display="radio"
-                label="split the following variant types">
+                <param name="multiallelic_types" type="select" display="radio" label="split the following variant types">
                     <option value="snps">SNPs</option>
                     <option value="indels">indels</option>
                     <option value="both" selected="true">both</option>
                 </param>
             </when>
             <when value="+">
-                <param name="multiallelic_types" type="select" display="radio"
-                label="merge the following variant types">
+                <param name="multiallelic_types" type="select" display="radio" label="Merge the following variant types">
                     <option value="snps">SNPs</option>
                     <option value="indels">indels</option>
                     <option value="both" selected="true">SNPs and indels, but keep variants of the two types separate (both)</option>
                     <option value="any">SNPs and indels, and merge variant records of different types (any)</option>
                 </param>
-                <param name="strict_filter" type="boolean" truevalue="--strict-filter" falsevalue=""
-                label="Strict Filter"
-                help="merged site is PASS only if all sites being merged PASS" />
+                <param name="strict_filter" type="boolean" truevalue="--strict-filter" falsevalue="" label="Strict Filter" help="merged site is PASS only if all sites being merged PASS"/>
             </when>
         </conditional>
         <section name="sec_restrict" expanded="false" title="Restrict all operations to">
-            <expand macro="macro_restrict" type="region" label_type="Region" />
-            <expand macro="macro_restrict" type="target" label_type="Target">
-                <expand macro="macro_invert_targets" />
-            </expand>
+            <expand macro="macro_region_restrict"/>
+            <expand macro="macro_target_restrict"/>
+        </section>
+        <section name="sec_default" expanded="false" title="Other Options">
+            <param name="site_win" type="integer" label="Site Window" value="1000" optional="True" help="(-w, --site-win) Buffer for sorting lines which changed position during realignment"/>
+            <param argument="--sort" type="select" label="Sort normalized allele order" help="Select the sort order for output records after normalization.">
+                <option value="pos" selected="true">Chromosome then position (pos)</option>
+                <option value="lex">Lexicographical allele order (lex)</option>
+            </param>
         </section>
-
-        <section name="sec_default" expanded="false" title="Other Options">
-            <param name="site_win" type="integer" label="Site Window" value="1000" optional="True" 
-                   help="(-w, --site-win) Buffer for sorting lines which changed position during realignment" />
+        <section name="sec_filter_norm" expanded="false" title="Normalize only selected records">
+            <param name="include" type="text" optional="true" label="Include (normalize only matching records)" help="Expression evaluated before normalization to select records to normalize">
+                <expand macro="macro_include_exclude_validate_sanitize"/>
+            </param>
+            <param name="exclude" type="text" optional="true" label="Exclude (skip normalization for matching records)" help="Expression evaluated before normalization to skip records">
+                <expand macro="macro_include_exclude_validate_sanitize"/>
+            </param>
         </section>
-        <expand macro="macro_select_output_type" />
+        <expand macro="macro_select_output_type"/>
     </inputs>
     <outputs>
         <expand macro="macro_vcf_output"/>
     </outputs>
     <tests>
         <test>
-            <param name="input_file" ftype="vcf" value="norm.vcf" />
-            <expand macro="test_using_reference" ref="norm.fa" />
-            <param name="normalize_indels" value="true" />
-            <param name="output_type" value="v" />
+            <param name="input_file" ftype="vcf" value="norm.vcf"/>
+            <expand macro="test_using_reference" ref="norm.fa"/>
+            <param name="normalize_indels" value="true"/>
+            <param name="output_type" value="v"/>
             <output name="output_file">
                 <assert_contents>
-                    <has_text text="T,TAACCCTA" />
-                    <not_has_text text="TAA,TAACCCTAAA" />
+                    <has_text text="T,TAACCCTA"/>
+                    <not_has_text text="TAA,TAACCCTAAA"/>
                 </assert_contents>
             </output>
         </test>
-
         <test>
-            <param name="input_file" ftype="vcf" dbkey="?" value="norm.vcf" />
-            <expand macro="test_using_reference" select_from="cached" ref="norm" />
-            <param name="normalize_indels" value="true" />
-            <param name="output_type" value="v" />
+            <param name="input_file" ftype="vcf" dbkey="?" value="norm.vcf"/>
+            <expand macro="test_using_reference" select_from="cached" ref="norm"/>
+            <param name="normalize_indels" value="true"/>
+            <param name="output_type" value="v"/>
             <output name="output_file">
                 <assert_contents>
-                    <has_text text="T,TAACCCTA" />
-                    <not_has_text text="TAA,TAACCCTAAA" />
+                    <has_text text="T,TAACCCTA"/>
+                    <not_has_text text="TAA,TAACCCTAAA"/>
                 </assert_contents>
             </output>
         </test>
-
         <test>
-            <param name="input_file" ftype="vcf" value="norm.split.vcf" />
-            <expand macro="test_using_reference" ref="norm.fa" />
+            <param name="input_file" ftype="vcf" value="norm.split.vcf"/>
+            <expand macro="test_using_reference" ref="norm.fa"/>
             <conditional name="multiallelics">
-                <param name="mode" value="-" />
+                <param name="mode" value="-"/>
             </conditional>
-            <param name="output_type" value="v" />
+            <param name="output_type" value="v"/>
             <output name="output_file">
                 <assert_contents>
-                    <not_has_text text="TAA,TAACCCTAAA" />
+                    <not_has_text text="TAA,TAACCCTAAA"/>
                     <has_text_matching expression="1\t105\t.\tTAAACCCTAAA\tTAA\t"/>
                     <has_text_matching expression="1\t105\t.\tTAAACCCTAAA\tTAACCCTAAA\t"/>
                 </assert_contents>
             </output>
         </test>
-
         <test>
-            <param name="input_file" ftype="vcf" value="norm.split.vcf" />
-            <expand macro="test_using_reference" ref="norm.fa" />
-            <param name="normalize_indels" value="true" />
+            <param name="input_file" ftype="vcf" value="norm.split.vcf"/>
+            <expand macro="test_using_reference" ref="norm.fa"/>
+            <param name="normalize_indels" value="true"/>
             <conditional name="multiallelics">
-                <param name="mode" value="-" />
+                <param name="mode" value="-"/>
             </conditional>
-            <param name="output_type" value="v" />
+            <param name="output_type" value="v"/>
             <output name="output_file">
                 <assert_contents>
-                    <not_has_text text="TAA,TAACCCTAAA" />
+                    <not_has_text text="TAA,TAACCCTAAA"/>
                     <has_text_matching expression="1\t105\t.\tTAAACCCTA\tT\t"/>
                     <has_text_matching expression="1\t105\t.\tTA\tT\t"/>
                 </assert_contents>
             </output>
         </test>
-
         <test>
-            <param name="input_file" ftype="vcf" value="norm.merge.vcf" />
-            <expand macro="test_using_reference" ref="norm.fa" />
+            <param name="input_file" ftype="vcf" value="norm.merge.vcf"/>
+            <expand macro="test_using_reference" ref="norm.fa"/>
             <conditional name="multiallelics">
-                <param name="mode" value="+" />
+                <param name="mode" value="+"/>
             </conditional>
-            <param name="output_type" value="v" />
+            <param name="output_type" value="v"/>
             <output name="output_file">
                 <assert_contents>
-                    <has_text text="TAA,TAACCCTAAA" />
+                    <has_text text="TAA,TAACCCTAAA"/>
                     <has_text_matching expression="2\t114\t.\tTC\tTTCC,TTC\t999\tFAIL"/>
                 </assert_contents>
             </output>
         </test>
         <test>
-            <param name="input_file" ftype="vcf" value="norm.merge.vcf" />
-            <expand macro="test_using_reference" ref="norm.fa" />
+            <param name="input_file" ftype="vcf" value="norm.merge.vcf"/>
+            <expand macro="test_using_reference" ref="norm.fa"/>
             <conditional name="multiallelics">
-                <param name="mode" value="+" />
-                <param name="strict_filter" value="true" />
+                <param name="mode" value="+"/>
+                <param name="strict_filter" value="true"/>
             </conditional>
-            <param name="output_type" value="v" />
+            <param name="output_type" value="v"/>
             <output name="output_file">
                 <assert_contents>
-                    <has_text text="TAA,TAACCCTAAA" />
+                    <has_text text="TAA,TAACCCTAAA"/>
                     <has_text_matching expression="2\t114\t.\tTC\tTTCC,TTC\t999\tPASS"/>
                 </assert_contents>
             </output>
         </test>
-
         <test>
-            <param name="input_file" ftype="vcf" value="norm.setref.vcf" />
-            <expand macro="test_using_reference" ref="norm.fa" />
-            <param name="check_ref" value="ws" />
-            <param name="output_type" value="v" />
+            <param name="input_file" ftype="vcf" value="norm.setref.vcf"/>
+            <expand macro="test_using_reference" ref="norm.fa"/>
+            <param name="check_ref" value="ws"/>
+            <param name="output_type" value="v"/>
             <output name="output_file">
                 <assert_contents>
                     <has_text_matching expression="2\t101\t.\tA\tc\t999\tPASS"/>
@@ -249,45 +236,71 @@
                 </assert_contents>
             </output>
         </test>
-        
         <!-- Test atomize option -->
         <test>
-            <param name="input_file" ftype="vcf" value="norm.split.vcf" />
-            <expand macro="test_using_reference" ref="norm.fa" />
-            <param name="normalize_indels" value="true" />
+            <param name="input_file" ftype="vcf" value="norm.split.vcf"/>
+            <expand macro="test_using_reference" ref="norm.fa"/>
+            <param name="normalize_indels" value="true"/>
             <conditional name="multiallelics">
-                <param name="mode" value="-" />
+                <param name="mode" value="-snps"/>
             </conditional>
-            <param name="atomize" value="true"/>
-            <param name="output_type" value="v" />
+            <param name="atomization" value="--atomize --atom-overlaps ."/>
+            <param name="output_type" value="v"/>
             <output name="output_file">
                 <assert_contents>
-                    <not_has_text text="TAA,TAACCCTAAA" />
+                    <not_has_text text="TAA,TAACCCTAAA"/>
                     <has_text_matching expression="1\t105\t.\tTAAACCCTA\tT\t"/>
                     <has_text_matching expression="1\t105\t.\tTA\tT\t"/>
                 </assert_contents>
             </output>
             <assert_command>
-                <has_text text="--atomize" />
+                <has_text text="--atomize --atom-overlaps ."/>
             </assert_command>
         </test>
         <!-- Test region overlap options -->
         <test>
-            <param name="input_file" ftype="vcf" dbkey="?" value="norm.vcf" />
-            <expand macro="test_using_reference" select_from="cached" ref="norm" />
-            <param name="normalize_indels" value="true" />
-            <param name="output_type" value="v" />
+            <param name="input_file" ftype="vcf" dbkey="?" value="norm.vcf"/>
+            <expand macro="test_using_reference" select_from="cached" ref="norm"/>
+            <param name="normalize_indels" value="true"/>
+            <param name="output_type" value="v"/>
             <section name="sec_restrict">
-                <param name="regions_overlap" value="1"/>
+                <conditional name="regions">
+                    <param name="regions_src" value="regions" />
+                    <repeat name="region_specs">
+                        <param name="chrom" value="1" />
+                    </repeat>
+                </conditional>
             </section>
             <output name="output_file">
                 <assert_contents>
-                    <has_text text="T,TAACCCTA" />
-                    <not_has_text text="TAA,TAACCCTAAA" />
+                    <has_text text="T,TAACCCTA"/>
+                    <not_has_text text="TAA,TAACCCTAAA"/>
                 </assert_contents>
             </output>
             <assert_command>
-                <has_text text="--regions-overlap" />
+                <has_text text="--regions-overlap"/>
+            </assert_command>
+        </test>
+        <!-- Test normalization filters and sort -->
+        <test>
+            <param name="input_file" ftype="vcf" value="norm.vcf"/>
+            <expand macro="test_using_reference" ref="norm.fa"/>
+            <param name="normalize_indels" value="true"/>
+            <section name="sec_default">
+                <param name="sort" value="lex"/>
+            </section>
+            <section name="sec_filter_norm">
+                <param name="include" value="QUAL&gt;10"/>
+            </section>
+            <param name="output_type" value="v"/>
+            <output name="output_file">
+                <assert_contents>
+                    <has_text text="T,TAACCCTA"/>
+                </assert_contents>
+            </output>
+            <assert_command>
+                <has_text text="--sort lex"/>
+                <has_text text="--include 'QUAL&gt;10'"/>
             </assert_command>
         </test>
     </tests>
@@ -304,8 +317,8 @@
 
 @BCFTOOLS_MANPAGE@#@EXECUTABLE@
 
-@BCFTOOLS_WIKI@
+@BCFTOOLS_HOWTOS@
 ]]>
     </help>
-    <expand macro="citations" />
+    <expand macro="citations"/>
 </tool>