Veritas is a command-line tool for benchmarking pathogen genomic data generated by strategies guided by reference mapping. It supports comparing variants from VCF or FASTA (consensus) files against truth datasets and provides comprehensive performance metrics.
- Disclaimer
- Features
- Requirements
- Installation
- Commands
- Command Options
- Output Files
- Metrics Calculation
- Example Workflows
- Development Information
- Planned Functionalities
- Contributing
- Citation
- Authors
While Veritas allows benchmarking using a FASTA (consensus) as input query file, we strongly recommend using VCF files when possible, for two important reasons:
- Preserves original variant calls: The VCF file contains the exact variant calls produced by your original bioinformatics workflow.
- Avoids re-calling artifacts: When a FASTA file is provided as query, Veritas re-aligns it using GSAlign to generate a VCF. This VCF may differ from the original variant calls used to create the consensus sequence.
Gold-standard benchmark datasets are provided in the veritas_data repository, but Veritas is designed to be dataset-agnostic and can work with any user-provided files.
-
Dataset Management
- List available benchmark datasets from veritas_data repository
- Download datasets (supports both real SRA data and artificial Zenodo datasets)
- Automatic metadata handling
-
Variant Validation
- Compare query VCF against truth VCF using RTG vcfeval
- Support for FASTA consensus validation via GSAlign alignment
- Automatic sample name matching between query and truth datasets. It is a requirement for the rtg vcfeval tool to work.
-
Comprehensive Metrics
- Calculate precision, recall, and F1-score for SNVs and INDELs
- Separate variant categories (TP/FP/FN) for different genomic regions (primers, masked regions, low coverage)
- Export results in TSV format
-
Annotation Support
- Annotate variants with BED regions (primers, mask, low coverage)
- Track variants in specific genomic contexts
- Detailed variant classification (TP/FP/FN)
-
Utility Commands
- Convert FASTA to VCF using GSAlign
- Format reference genomes for RTG Tools
- Python >= 3.8
- RTG Tools (for vcfeval and reference formatting)
- GSAlign (for FASTA-to-VCF conversion)
- BCFtools (for VCF manipulation)
- parallel-fastq-dump (for SRA downloads, optional)
- seqkit (for FASTQ processing, optional)
- wget (for Zenodo downloads, optional)
# Clone the repository
git clone https://github.com/WallauBioinfo/veritas.git
cd veritas
micromamba env create -f env.yaml # or conda another environment manager
micromamba activate veritas
veritas --helpView all benchmark datasets available in the veritas_data repository with detailed metadata.
veritas list-datasetsOutput example:
┌─────────────────────────────────┬────────────────┬──────────────┬────────────────────────┬─────────┬──────────────┬──────────────┬─────────────┐
│ dataset │ dataset_version│ pathogen │ sequencing_technology │ layout │ dataset_type │ strategy │ read_length │
├─────────────────────────────────┼────────────────┼──────────────┼────────────────────────┼─────────┼──────────────┼──────────────┼─────────────┤
│ veritas/sars-cov-2/SEARCH-8113 │ v1.0.0 │ SARS-CoV-2 │ Illumina │ paired │ real │ amplicon │ 150 │
├─────────────────────────────────┼────────────────┼──────────────┼────────────────────────┼─────────┼──────────────┼──────────────┼─────────────┤
│ veritas/sars-cov-2/MSv3-Coinfec │ v1.0.0 │ SARS-CoV-2 │ Illumina │ paired │ artificial │ amplicon │ 250 │
└─────────────────────────────────┴────────────────┴──────────────┴────────────────────────┴─────────┴──────────────┴──────────────┴─────────────┘
Dataset Types:
- real: Real sequencing data downloaded from SRA (requires
parallel-fastq-dumpandseqkit) - artificial: Simulated data downloaded from Zenodo (requires
wget)
Download a specific benchmark dataset including all necessary files for validation.
veritas get-dataset \
--dataset-name veritas/sars-cov-2/SEARCH-8113 \
--output-dir datasetsWhat gets downloaded:
- Reference genome (
reference.fa) - Truth VCF (validated variant calls)
- Metadata (
metadata.yaml) with dataset information - FASTQ files:
- Real datasets: Downloaded from SRA and paired-end filtered
- Artificial datasets: Downloaded from Zenodo
- Optional files: primers.bed, mask.bed, low_cov.bed (if available)
Options:
| Option | Short | Description | Default |
|---|---|---|---|
--dataset-name |
-d |
Dataset name (e.g., veritas/sars-cov-2/SEARCH-8113) | Required |
--output-dir |
-o |
Directory to save dataset | veritas_datasets |
Example:
# Download to default directory
veritas get-dataset -d veritas/sars-cov-2/SEARCH-8113
# Download to custom directory
veritas get-dataset \
-d veritas/sars-cov-2/SEARCH-8113 \
-o my_datasetsOnce downloaded, the reference fasta file and fastq files can be used as input in your workflow. The primers.bed or primers.fasta can be used if your workflow has features to trim primer regions based on bed or fasta files. If a dataset has a mask.bed file, it can be used to mask regions of the reference genome that are not informative for variant calling or that can represents sequencing artifacts.
Your workflow will produce a consensus fasta file - or in a better scenario, a VCF file - that can be used as input in the validate command.
The validate command compares query variants against a truth VCF and calculates performance metrics.
veritas validate \
--dataset-dir datasets/veritas/sars-cov-2/SEARCH-8113 \
--query-vcf query.vcf.gz \
--output-dir validation_resultsThe --dataset-dir option automatically discovers:
- Truth VCF (
*.vcf.gz) - Reference FASTA (
reference.fa) - RTG reference SDF (
rtg_sdf/) - Primers BED (
primers.bed) - Mask BED (
mask.bed) - Low coverage BED (
low_cov.bed)
veritas validate \
--dataset-dir datasets/veritas/sars-cov-2/SEARCH-8113 \
--query-fasta consensus.fa \
--output-dir validation_resultsYou can still specify files individually if needed:
veritas validate \
--truth-vcf truth.vcf.gz \
--query-vcf query.vcf.gz \
--rtg-reference reference_sdf \
--output-dir validation_results \
--primerd-bed primers.bed \
--low-cov-truth-bed low_cov.bedWhen using --query-fasta, veritas will:
- Run GSAlign to align the consensus against the reference
- Convert the alignment to VCF format with the same sample name as the truth VCF
- Validate the VCF against the truth dataset
The convert command allows you to convert a FASTA consensus sequence to VCF format using GSAlign, without running validation. It is useful when you want to create an artificial dataset based on a consensus genome that differs from a reference.
veritas convert \
--reference reference.fa \
--query consensus.fa \
--sample MySample \
--output consensus.vcf.gzOptions:
| Option | Short | Description | Required |
|---|---|---|---|
--reference |
-r |
Reference FASTA file | Yes |
--query |
-q |
Query FASTA file | Yes |
--sample |
-s |
Sample name for VCF header | No (uses FASTA header or "SAMPLE") |
--output |
-o |
Output VCF file path | No (uses query filename) |
Example:
# Convert with automatic sample name from FASTA header
veritas convert -r NC_045512.2.fa -q consensus.fa
# Convert with custom sample name and output path
veritas convert \
-r NC_045512.2.fa \
-q my_sample.fa \
-s MySample \
-o results/my_sample.vcf.gzWhen a FASTA consensus is provided (via convert or validate --query-fasta), Veritas performs the following steps:
- Pairwise alignment: GSAlign aligns the consensus FASTA against the reference genome and produces a raw VCF.
- Header normalisation: Veritas patches the raw GSAlign VCF to add a standard
FILTER=<PASS>definition andFORMAT=<GT>field, which are required by RTG Tools. - Sample column injection: The sample name (taken from the truth VCF or provided via
--sample) is written into the VCF column header and each record. - Compression & indexing: The processed VCF is bgzipped and tabix-indexed, producing the final
.vcf.gzfile used in downstream validation.
Important
Understanding how ambiguous bases and gaps are handled is essential when using a FASTA consensus as input instead of a VCF.
| Character in consensus | How GSAlign treats it | Effect on metrics |
|---|---|---|
Point substitution (e.g., A→G) |
Called as an SNV | Counted in TP/FP/FN for the SNV category |
| Insertion (extra bases relative to reference) | Called as an INDEL | Counted in TP/FP/FN for the INDEL category |
Deletion (- in alignment) |
Called as an INDEL | Counted in TP/FP/FN for the INDEL category |
Ambiguous base N |
Not called as a variant | Positions masked as N are treated as missing data — they generate no FP, but any truth variant at that position becomes an FN |
Because N positions are silently skipped rather than called as mismatches, a consensus with large masked regions can appear to have a low FP rate while quietly accumulating FNs. For this reason, we strongly recommend using the original VCF from your workflow whenever possible (see Disclaimer).
The rtg-format command formats a reference FASTA file as an RTG SDF directory, required by RTG vcfeval. It is useful when you want to use a reference genome that is not provided in the veritas_data repository.
veritas rtg-format \
--reference reference.fa \
--output reference_sdfOptions:
| Option | Short | Description | Required |
|---|---|---|---|
--reference |
-r |
Reference FASTA file | Yes |
--output |
-o |
Output SDF directory name | Yes |
Example:
# Format reference for a dataset
veritas rtg-format \
-r datasets/sars-cov-2/SEARCH-8113/reference.fa \
-o datasets/sars-cov-2/SEARCH-8113/rtg_sdf
# Or use rtg directly
rtg format -o reference_sdf reference.fa| Option | Short | Description | Required |
|---|---|---|---|
--dataset-dir |
-d |
Dataset directory (auto-discovers files) | No (but recommended) |
--truth-vcf |
-t |
Truth VCF file (gzipped) | Yes (unless using --dataset-dir) |
--query-vcf |
-q |
Query VCF file (gzipped) | Either this or --query-fasta |
--query-fasta |
-f |
Query FASTA consensus file | Either this or --query-vcf |
--reference |
-r |
Reference FASTA | Conditional (unless using --dataset-dir) |
--rtg-reference |
RTG SDF reference directory | Yes (unless using --dataset-dir) | |
--output-dir |
-o |
Output directory | No (default: veritas_output) |
--primerd-bed |
-p |
BED file with primer regions | No (auto-discovered from --dataset-dir) |
--mask-bed |
-m |
BED file with masked regions | No (auto-discovered from --dataset-dir) |
--low-cov-truth-bed |
-lt |
BED file with low coverage in truth | No (auto-discovered from --dataset-dir) |
--low-cov-query-bed |
-lq |
BED file with low coverage in query | No |
After running validate, you'll find the following files in the output directory:
output_dir/
├── gsalign/ # GSAlign outputs (if using FASTA)
│ ├── alignment.fa # Aligned sequences
│ └── query.vcf.gz # Processed query VCF
│ └── query.vcf.gz.tbi # Index
├── rtg/ # RTG vcfeval working directory
│ ├── tp.vcf.gz # True positives
│ ├── fp.vcf.gz # False positives
│ ├── fn.vcf.gz # False negatives
│ └── summary.txt # RTG summary
├── truth_query.vcf.gz # Final annotated VCF with all variants
├── truth_query.vcf.gz.tbi # Index
└── metrics.tsv # Performance metrics
The metrics.tsv file contains precision, recall, and F1-score for SNVs and INDELs:
Category Region TP FP FN Precision Recall F1-Score
SNV ALL 95 5 2 0.950 0.979 0.964
INDEL ALL 18 2 3 0.900 0.857 0.878
SNV PRIMER BED 10 1 0
INDEL PRIMER BED 2 0 1
SNV LOW_COV_TRUTH BED 3 2 1
...
Region Types:
- ALL: All variants (no filtering)
- PRIMER BED: Variants within primer regions (if
--primerd-bedprovided) - MASK BED: Variants within masked regions (if
--mask-bedprovided) - LOW_COV_TRUTH BED: Variants in low coverage regions of truth (if
--low-cov-truth-bedprovided) - LOW_COV_QUERY BED: Variants in low coverage regions of query (if
--low-cov-query-bedprovided)
Each variant in the merged output VCF is tagged using RTG vcfeval results:
| Tag | Meaning |
|---|---|
| TP | True Positive — variant present in both truth and query |
| FP | False Positive — variant present only in query |
| FN | False Negative — variant present only in truth |
Variants are independently classified as SNV or INDEL:
- SNV (Single Nucleotide Variant):
len(REF) == len(ALT)— simple substitutions - INDEL (Insertion or Deletion):
len(REF) != len(ALT)— any length-changing variant
SNV and INDEL metrics are always reported separately, so a pipeline that calls substitutions well but misses indels (or vice versa) is visible in the output.
For each variant category (SNV / INDEL) and region, Veritas computes:
All three metrics return 0 whenever the denominator is zero (e.g., no variants in that category).
When BED files are provided, Veritas reports metrics both globally (ALL) and broken down by genomic context (primer regions, masked regions, low-coverage regions). A single variant can appear in multiple BED regions simultaneously. This allows you to:
- Identify whether FPs are concentrated in amplicon primer regions (a common artefact)
- Distinguish FNs in low-coverage areas from genuine pipeline failures
- Assess whether masked regions are inflating performance by excluding difficult sites
See FASTA-to-VCF Conversion Pipeline for a full table of how N, substitutions, insertions, and deletions are treated during conversion from a consensus FASTA to VCF before metric calculation.
# 1. List available datasets
veritas list-datasets
# 2. Download a benchmark dataset
veritas get-dataset \
-d veritas/sars-cov-2/SEARCH-8113 \
-o datasets
# 3. Run your workflow
<your_workflow> \
--reference datasets/veritas/sars-cov-2/SEARCH-8113/reference.fa \
--r1 datasets/veritas/sars-cov-2/SEARCH-8113/SEARCH-8113_R1.fastq.gz \
--r2 datasets/veritas/sars-cov-2/SEARCH-8113/SEARCH-8113_R2.fastq.gz \
--primers datasets/veritas/sars-cov-2/SEARCH-8113/primers.bed \
--output output_directory/results.vcf.gz
# 4. Validate your VCF
veritas validate \
-d datasets/veritas/sars-cov-2/SEARCH-8113 \
-q output_directory/results.vcf.gz \
-o validation_directory
# 5. Review results
cat validation_directory/metrics.tsv# Validate a FASTA consensus with a downloaded dataset
veritas validate \
-d datasets/veritas/sars-cov-2/SEARCH-8113 \
-f my_consensus.fa \
-o validation_directory# 1. Format your reference
veritas rtg-format -r my_reference.fa -o my_reference_sdf
# 2. Run validation with all custom files
veritas validate \
-t my_truth.vcf.gz \
-q my_query.vcf.gz \
-r my_reference.fa \
--rtg-reference my_reference_sdf \
-p primers.bed \
-m mask.bed \
-lt low_cov_truth.bed \
-o my_resultsveritas/
├── veritas/
│ ├── commands/
│ │ └── main.py # CLI commands
│ ├── __init__.py
│ ├── datasets.py # Dataset management
│ ├── logger.py # Logging configuration
│ ├── tools.py # Tools commands
│ └── validate.py # Validation logic
├── tests/
│ ├── conftest.py # Test fixtures
│ ├── test_validate.py # Unit tests
│ └── fixtures/ # Test data
├── setup.py
└── README.md
Before commiting, please format the code with black.
black .Veritas includes a comprehensive test suite using pytest.
# Run all tests
pytest tests/ -v
# Run specific test file
pytest tests/test_validate.py -v
# Run specific test class
pytest tests/test_metrics.py::TestCalcMetrics -vtests/
├── conftest.py # Pytest fixtures (temp dirs, sample files, etc.)
├── test_validate.py # Tests for validation functions (metrics, BED parsing)
├── test_datasets.py # Tests for dataset management (table formatting)
├── test_commands.py # Tests for CLI commands (help, argument validation)
├── test_metrics.py # Tests for metrics calculation and TSV export
├── fixtures/ # Test data files
└── README.md # Test documentation
- Some tests create temporary files automatically cleaned up after execution
- Tests requiring external tools (RTG, GSAlign) are skipped if tools not available
- All fixtures are defined in
conftest.py - See
tests/README.mdfor detailed testing documentation - This suite of tests were generated using Gemini 3 Pro
- Download datasets based on metadata, for example: all datasets for SARS-CoV-2, or all datasets generated using Illumina amplicon sequencing.
- Support the analysis and validation of structural variants (SVs), which is particularly important in the context of Mpox data.
- Generate genomic plots that highlight variants and their classifications (true positives, false positives, and false negatives).
Contributions are welcome! Please:
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
If you use Veritas in your research, please cite:
- RTG vcfeval: https://github.com/rtg-wasm/vcfeval
- GSAlign: https://github.com/GenomicsSoftwares/GSAlign
- bcfTools: https://github.com/samtools/bcftools
- seqkit: https://github.com/shenwei356/seqkit
- parallel-fastq-dump: https://github.com/ncbi/parallel-fastq-dump
- veritas: https://github.com/WallauBioinfo/veritas
Filipe Dezordi
- GitHub: @dezordi