diff --git a/tools/bcftools/bcftools_annotate.xml b/tools/bcftools/bcftools_annotate.xml
index 0f91e11076f..33e072c4a59 100644
--- a/tools/bcftools/bcftools_annotate.xml
+++ b/tools/bcftools/bcftools_annotate.xml
@@ -41,7 +41,7 @@
#set $annotation_hdr = $section.annofile.header_file
#elif $section.annofile.header_lines:
#set $annotation_hdr = 'annotation.hdr'
- grep '^\#\#INFO' '${hdr_file}' > $annotation_hdr &&
+ grep '^\#\#' '${hdr_file}' > $annotation_hdr &&
#end if
#end if
#set $section = $sec_restrict
@@ -50,7 +50,11 @@ bcftools @EXECUTABLE@
@PREPARE_REGIONS_FILE@
#set $section = $sec_annofile
-@COLUMNS@
+#if $section.columns_file:
+ --columns-file '$section.columns_file'
+#else:
+ @COLUMNS@
+#end if
#if $annotation_file:
--annotations '${annotation_file}'
#end if
@@ -109,13 +113,15 @@ ${section.keep_sites}
+
@@ -447,15 +453,73 @@ $sec_annofile.annofile.header_lines.__str__.strip()#slurp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
^(\w+,\w+)?$
-
+
+ ^([0-9]+(,[0-9]+)*)?$
+
@@ -183,17 +189,16 @@ For example: --prior-freqs REF_AN,REF_AC
-
+
-
+
-
-
-
+
+
@@ -427,6 +432,35 @@ For example: --prior-freqs REF_AN,REF_AC
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -217,7 +217,7 @@ $masking_options.snvs.mark_snv
-
+
diff --git a/tools/bcftools/bcftools_convert_from_vcf.xml b/tools/bcftools/bcftools_convert_from_vcf.xml
index e0ed6115690..6b730b75d5a 100644
--- a/tools/bcftools/bcftools_convert_from_vcf.xml
+++ b/tools/bcftools/bcftools_convert_from_vcf.xml
@@ -66,7 +66,7 @@ $convert.vcf_ids $convert.haploid2diploid
@SAMPLE_SEX@
#if $keep_duplicates
- --keep-duplicates $keep_duplicates
+ $keep_duplicates
#end if
## VCF input section
diff --git a/tools/bcftools/bcftools_convert_to_vcf.xml b/tools/bcftools/bcftools_convert_to_vcf.xml
index 056c549d184..908928163eb 100644
--- a/tools/bcftools/bcftools_convert_to_vcf.xml
+++ b/tools/bcftools/bcftools_convert_to_vcf.xml
@@ -1,6 +1,6 @@
- Converts other formats to VCF/BCFk
+ Converts other formats to VCF/BCF
convert
macros.xml
diff --git a/tools/bcftools/bcftools_csq.xml b/tools/bcftools/bcftools_csq.xml
index 84496114073..2712d6effd7 100644
--- a/tools/bcftools/bcftools_csq.xml
+++ b/tools/bcftools/bcftools_csq.xml
@@ -46,12 +46,18 @@ $sec_csq_opts.local_csq
#if $sec_csq_opts.greedy
--greedy '$sec_csq_opts.greedy'
#end if
+#if $sec_csq_opts.csq_format:
+ --format '$sec_csq_opts.csq_format'
+#end if
## GFF options section
$sec_gff_opts.force
#if str($sec_gff_opts.unify_chr_names)
--unify-chr-names '$sec_gff_opts.unify_chr_names'
#end if
+#if $sec_gff_opts.allow:
+ --allow '$sec_gff_opts.allow'
+#end if
## Subset section
#set $section = $sec_subset
@@ -129,10 +135,34 @@ $sec_gff_opts.force
+
+ cds_position: Position in the coding sequence and CDS length.
+- exon: Exon number and the number of exons in the transcript.
+- exon_position: Position within the exon and exon length.
+ ]]>
+
+
+
+
+
+ mif: Skip records without FASTA reference (missing-in-FASTA).
+- mig: Skip contigs without GFF annotations (missing-in-GFF).
+- cds-oop: Skip transcripts with phase errors (CDS-out-of-phase).
+- ref-mm: Skip records with REF mismatch in VCF and FASTA (ref-mismatch).
+ ]]>
+
+
+
+
+
@@ -246,6 +276,36 @@ $sec_gff_opts.force
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- ^\d+(:[a-zA-Z,]+)?$
+
+ ^\d+(:[a-zA-Z,]+)?$
@@ -375,6 +375,36 @@ bcftools @EXECUTABLE@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
gtcheck
macros.xml
+
+
+
+
+
+
+
+
+
+ value.strip() and value[0] not in "^," and ",," not in value
+
+
+
+
+
+
+
+
+
+
+
+
+ bool(value) and len(value.split(",")) % 2 == 0 and all(s.strip() for s in value.split(","))
+
+
+
@@ -14,18 +45,20 @@
@PREPARE_REGIONS_FILE@
#set $section = $sec_default
#set $genotypes_vcf = None
-#if $section.genotypes:
- #if $section.genotypes.is_of_type('vcf')
- #set $genotypes_vcf = 'genotypes.vcf.gz'
- bgzip -c '$section.genotypes' > $genotypes_vcf &&
- bcftools index $genotypes_vcf &&
- #elif $section.genotypes.is_of_type('bcf')
- #set $genotypes_vcf = 'genotypes.bcf'
- ln -s '$section.genotypes' $genotypes_vcf &&
- #if $section.genotypes.metadata.bcf_index:
- ln -s $section.genotypes.metadata.bcf_index ${genotypes_vcf}.csi &&
- #else
+#if $section.comparison_mode.mode == 'reference':
+ #if $section.comparison_mode.genotypes:
+ #if $section.comparison_mode.genotypes.is_of_type('vcf')
+ #set $genotypes_vcf = 'genotypes.vcf.gz'
+ bgzip -c '$section.comparison_mode.genotypes' > $genotypes_vcf &&
bcftools index $genotypes_vcf &&
+ #elif $section.comparison_mode.genotypes.is_of_type('bcf')
+ #set $genotypes_vcf = 'genotypes.bcf'
+ ln -s '$section.comparison_mode.genotypes' $genotypes_vcf &&
+ #if $section.comparison_mode.genotypes.metadata.bcf_index:
+ ln -s $section.comparison_mode.genotypes.metadata.bcf_index ${genotypes_vcf}.csi &&
+ #else
+ bcftools index $genotypes_vcf &&
+ #end if
#end if
#end if
#end if
@@ -37,29 +70,56 @@ bcftools @EXECUTABLE@
#if $genotypes_vcf:
--genotypes $genotypes_vcf
+ ${section.comparison_mode.homs_only}
#end if
-#if $section.genotypes:
- --genotypes '${section.genotypes}'
+#if $section.comparison_mode.use_tag:
+ --use '${str($section.comparison_mode.use_tag).replace("_", ",")}'
#end if
-${section.all_sites}
-
-${section.homs_only}
-
-#if $section.plot:
- --plot '${section.plot}'
-#end if
-
-#if $section.query_sample:
- --query-sample '${section.query_sample}'
-#end if
-
-#if $section.target_sample:
- --target-sample '${section.target_sample}'
+#if $section.analysis_type.analysis_mode == 'discordance':
+ #if $section.analysis_type.pairs_src.pairs_type == 'file':
+ --pairs-file '${section.analysis_type.pairs_src.pairs_file}'
+ #elif $section.analysis_type.pairs_src.pairs_type == 'text':
+ #set $pairs_list = ','.join(s.strip() for s in str($section.analysis_type.pairs_src.pairs).split(',') if s.strip())
+ --pairs '$pairs_list'
+ #else:
+ #if $section.analysis_type.pairs_src.qry_samples.how == 'list':
+ --samples 'qry:${section.analysis_type.pairs_src.qry_samples.samples_list}'
+ #elif $section.analysis_type.pairs_src.qry_samples.how == 'file':
+ --samples-file 'qry:${section.analysis_type.pairs_src.qry_samples.samples_file}'
+ #end if
+ #if $section.analysis_type.pairs_src.gt_samples.how == 'list':
+ --samples 'gt:${section.analysis_type.pairs_src.gt_samples.samples_list}'
+ #elif $section.analysis_type.pairs_src.gt_samples.how == 'file':
+ --samples-file 'gt:${section.analysis_type.pairs_src.gt_samples.samples_file}'
+ #elif $section.analysis_type.pairs_src.gt_samples.how == 'all_in_file':
+ --samples 'gt:-'
+ #end if
+ #if $section.analysis_type.pairs_src.matches_output.selector == 'score':
+ --n-matches $section.analysis_type.pairs_src.matches_output.top_n
+ #elif $section.analysis_type.pairs_src.matches_output.selector == 'hwe':
+ --n-matches -${section.analysis_type.pairs_src.matches_output.top_n}
+ #end if
+ #end if
+ #if str($section.analysis_type.error_probability) != '':
+ --error-probability $section.analysis_type.error_probability
+ #end if
+ ${section.analysis_type.no_HWE_prob}
+ ${section.analysis_type.keep_refs}
+#elif $section.analysis_type.analysis_mode == 'distinctive':
+ --distinctive-sites ${section.analysis_type.distinctive_sites.num}
+ #if $section.analysis_type.pairs_src.pairs_type == 'file':
+ --pairs-file '${section.analysis_type.pairs_src.pairs_file}'
+ #else:
+ #set $pairs_list = ','.join(s.strip() for s in str($section.analysis_type.pairs_src.pairs).split(',') if s.strip())
+ --pairs '$pairs_list'
+ #end if
#end if
#set $section = $sec_restrict
+@INCLUDE@
+@EXCLUDE@
@REGIONS@
@TARGETS@
@@ -74,15 +134,118 @@ ${section.homs_only}
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -103,15 +266,58 @@ ${section.homs_only}
bcftools @EXECUTABLE@
=====================================
-Check sample identity. With no -g BCF given, multi-sample cross-check is performed.
+Check sample identity and detect potential sample swaps or contamination.
+
+The tool can operate in two primary comparison modes:
+
+* **Cross-check within input dataset (default):** Performs all pairwise comparisons between samples in a single VCF/BCF file.
+* **Against a reference genotypes dataset (``-g``):** Compares each sample from the query dataset against all or selected samples in a reference genotype dataset.
+
+Analysis Types
+--------------
+
+1. **Check sample identity / discordance:**
+ Evaluates pairwise genotype discordance and HWE (Hardy-Weinberg Equilibrium) probability across samples.
+
+ * **Discordance score:** Measures genotype differences. When using GT-vs-GT comparisons without error modeling (``-E 0``), this corresponds to the number of mismatching genotypes. Using FORMAT/PL likelihoods or genotype qualities, it reflects an error-weighted discordance score. Lower values indicate better genetic matches.
+ * **Average -log P(HWE):** Measures the average negative log probability of HWE at matching sites. Rare genotype matches are much more informative than common ones; samples with similar discordance can be stratified by this score (higher score = observed concordance is less likely to occur by chance).
+ * **Pairwise filtering:** Comparisons can be evaluated for all sample combinations or restricted using a sample pairs file (``-P``) or text list (``-p``).
+ * **Sample selection:** Samples can be filtered for query (``qry:``) and reference (``gt:``) datasets using sample lists or files (``-s`` / ``-S``). In cross-check mode (without ``-g``), restricting only ``qry:`` while leaving ``gt:`` at **Default** compares the selected query samples only against themselves (producing no ``DCv2`` rows when only one query sample is selected). To compare specific query sample(s) against every sample in the input file, select **All samples in file (-s gt:-)** for target samples.
+ * **Top matches (``--n-matches``):** Output can report unlimited matches or only the top N best matches sorted by discordance or HWE probability.
+
+2. **Find distinctive sites (``--distinctive-sites``):**
+ Identifies the minimal set of informative variant sites that can distinguish between a specified fraction or number of sample pairs. Requires defining sample pairs (``-p`` or ``-P``). Outputs both discordance pairs and ``DS`` (Distinctive Sites) lines detailing chromosomal positions and distinguishing power.
+
+Output Format
+-------------
+
+The output is a tab-delimited table containing lines prefixed with:
+
+* **DCv2:** Pairwise discordance statistics containing:
+
+ 1. Record type (``DCv2``)
+ 2. Query Sample
+ 3. Genotyped Sample
+ 4. Discordance score
+ 5. Average -log P(HWE)
+ 6. Number of sites compared
+ 7. Number of matching genotypes
+
+* **DS (when distinctive sites mode is active):** Distinctive site records containing:
+
+ 1. Record type (``DS``)
+ 2. Chromosome
+ 3. Position
+ 4. Number of distinguished sample pairs
+ 5. Cumulative distinct pairs
@REGIONS_HELP@
@TARGETS_HELP@
+@EXPRESSIONS_HELP@
@BCFTOOLS_MANPAGE@#@EXECUTABLE@
@BCFTOOLS_HOWTOS@
-
]]>
diff --git a/tools/bcftools/bcftools_merge.xml b/tools/bcftools/bcftools_merge.xml
index 076b185383e..0eefcb6b6a0 100644
--- a/tools/bcftools/bcftools_merge.xml
+++ b/tools/bcftools/bcftools_merge.xml
@@ -20,6 +20,7 @@ ${section.print_header}
#if $section.use_header:
--use-header '${section.use_header}'
#end if
+@NO_VERSION@
## Merge section
#set $section = $sec_merge
@@ -33,8 +34,21 @@ ${section.missing_to_ref}
--gvcf '${section.gvcf.ref_file}'
#end if
-#if $section.info_rules:
- --info-rules '${section.info_rules}'
+#if str($section.info_rules.info_rules_selector) == "none":
+ --info-rules '-'
+#elif str($section.info_rules.info_rules_selector) == "custom":
+ #set $rules_list = []
+ #for $r in $section.info_rules.rules:
+ #set $tags = str($r.tag).strip().split(',')
+ #for $t in $tags:
+ #if $t.strip():
+ #silent $rules_list.append($t.strip() + ':' + str($r.method))
+ #end if
+ #end for
+ #end for
+ #if $rules_list:
+ --info-rules '#echo ",".join($rules_list)#'
+ #end if
#end if
#if $section.local_alleles > 0:
@@ -47,15 +61,27 @@ ${section.missing_to_ref}
#else:
--merge '${section.merge}'
#end if
- ${section.no_index}
+#elif str($section.unobserved) != "none":
+ --merge 'both,${section.unobserved}'
#end if
-#if $section.missing_rules:
- --missing-rules '${section.missing_rules}'
+#if str($section.missing_rules.missing_rules_selector) == "none":
+ --missing-rules '-'
+#elif str($section.missing_rules.missing_rules_selector) == "custom":
+ #set $m_rules_list = []
+ #for $r in $section.missing_rules.rules:
+ #set $tags = str($r.tag).strip().split(',')
+ #for $t in $tags:
+ #if $t.strip():
+ #silent $m_rules_list.append($t.strip() + ':' + str($r.replacement))
+ #end if
+ #end for
+ #end for
+ #if $m_rules_list:
+ --missing-rules '#echo ",".join($m_rules_list)#'
+ #end if
#end if
-@NO_VERSION@
-
## Restrict section
#set $section = $sec_restrict
@APPLY_FILTERS@
@@ -76,19 +102,34 @@ ${section.missing_to_ref}
-
-
-
-
-
-
-
-
-
-
+
+ None: No new multiallelic records are created; separate records are output instead.
+- Snps: Allow multiallelic SNP records.
+- Indels: Allow multiallelic indel records.
+- Both: Both SNP and indel records can be multiallelic (default).
+- Snp-ins-del: Allow multiallelic SNVs, insertions, deletions, but don't mix them.
+- All: Allow any variant records to be merged together (e.g. SNVs with indels).
+- Exact: Allow multiallelic records only when REF and ALT alleles match exactly.
+- Id: Merge records matching on the ID column.
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -101,32 +142,66 @@ ${section.missing_to_ref}
-
-
+
+
+
+
+
+
+
+
+
+
+
+ ^\s*[A-Za-z_][A-Za-z0-9_.]*(\s*,\s*[A-Za-z_][A-Za-z0-9_.]*)*\s*$
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ^\s*[A-Za-z_][A-Za-z0-9_.]*(\s*,\s*[A-Za-z_][A-Za-z0-9_.]*)*\s*$
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
@@ -193,7 +268,13 @@ ${section.missing_to_ref}
-
-
-
-
-
-
-
-
+
@@ -256,8 +322,13 @@ ${section.missing_to_ref}
-
-
+
+
+
+
+
+
+
@@ -265,6 +336,7 @@ ${section.missing_to_ref}
-
-
@@ -254,6 +252,25 @@ The number of overlapping sites for the sliding buffer. The default overlap is s
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
diff --git a/tools/bcftools/macros.xml b/tools/bcftools/macros.xml
index f59ac5dcd63..299aa4265b0 100644
--- a/tools/bcftools/macros.xml
+++ b/tools/bcftools/macros.xml
@@ -1,6 +1,6 @@
- 1.24
- 2
+ 1.25
+ 0
24.1
@@ -10,15 +10,15 @@
bcftools
- htslib
+ htslib
- samtools
+ samtools
- matplotlib
+ matplotlib
bcftools --version-only
@@ -178,12 +178,34 @@ $vcfs_list_file
#end if
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-#if 'estimate_AF' in $section and $section.estimate_AF:
- --estimate-AF "${section.estimate_AF}"
+#if 'estimate_AF' in $section and $section.estimate_AF.estimate_AF_src == 'all':
+ --estimate-AF '${section.estimate_AF.estimate_AF_tag},-'
+#elif 'estimate_AF' in $section and $section.estimate_AF.estimate_AF_src == 'file':
+ --estimate-AF '${section.estimate_AF.estimate_AF_tag},${section.estimate_AF.estimate_AF_file}'
#end if
@@ -277,6 +299,12 @@ $vcfs_list_file
help="inverts the query/filtering applied by the targets" />
+
+
+
+
@@ -366,7 +394,9 @@ $vcfs_list_file
-
+
+
+
@@ -393,11 +423,13 @@ $vcfs_list_file
#if $section.conditional_soft_filter.masks.masks_src == 'masks':
#set $intervals = $section.conditional_soft_filter.masks.mask_specs
@PARSE_INTERVALS@
- --mask '$intervals_spec'
+ --mask '${section.conditional_soft_filter.masks.invert_masks}$intervals_spec'
#elif $section.conditional_soft_filter.masks.masks_src == 'masks_file':
- --mask-file '$section.conditional_soft_filter.masks.masks_file'
+ --mask-file '${section.conditional_soft_filter.masks.invert_masks}${section.conditional_soft_filter.masks.masks_file}'
+ #end if
+ #if 'masks_overlap' in $section.conditional_soft_filter.masks:
+ --mask-overlap $section.conditional_soft_filter.masks.masks_overlap
#end if
- --mask-overlap $section.conditional_soft_filter.masks_overlap
#end if
#end if
diff --git a/tools/bcftools/test-data/annotate_columns.txt b/tools/bcftools/test-data/annotate_columns.txt
new file mode 100644
index 00000000000..b1d237c9057
--- /dev/null
+++ b/tools/bcftools/test-data/annotate_columns.txt
@@ -0,0 +1,9 @@
+CHROM
+POS
+REF
+ALT
+ID
+QUAL
+INFO/T_INT
+INFO/T_FLOAT
+INDEL
diff --git a/tools/bcftools/test-data/mpileup.groups b/tools/bcftools/test-data/mpileup.groups
new file mode 100644
index 00000000000..68e4a95d87f
--- /dev/null
+++ b/tools/bcftools/test-data/mpileup.groups
@@ -0,0 +1,4 @@
+HG00100 F
+HG00101 M
+HG00102 F
+HG99999 M