Validators Module

Input validation and sanity checking

Validation module for variantcentrifuge.

This module provides functions to validate: - VCF files (existence, non-empty) - Phenotype files (existence, non-empty, required columns) - Mandatory parameters (reference, filters, fields) - IGV local FASTA and related files (existence, readability)

These validations ensure that all critical inputs and parameters are provided correctly before proceeding with the analysis.

variantcentrifuge.validators.validate_vcf_file(vcf_path, logger)[source]

Validate that the input VCF file exists, is non-empty, and is readable.

Parameters:
  • vcf_path (str or None) – Path to the VCF file to validate.

  • logger (logging.Logger) – Logger instance for logging errors and debug information.

Raises:

SystemExit – If the VCF file is missing or empty.

Return type:

None

variantcentrifuge.validators.validate_phenotype_file(phenotype_file, sample_col, value_col, logger)[source]

Validate phenotype file presence, non-empty status, and required columns.

Parameters:
  • phenotype_file (str or None) – Path to the phenotype file.

  • sample_col (str) – The expected column name for samples in the phenotype file.

  • value_col (str) – The expected column name for phenotype values in the phenotype file.

  • logger (logging.Logger) – Logger instance for logging errors and debug information.

Raises:

SystemExit – If the phenotype file is missing, empty, lacks the required columns, or contains no data rows.

Return type:

None

variantcentrifuge.validators.validate_mandatory_parameters(reference, filters, fields)[source]

Validate that mandatory parameters (reference, filters, fields) are provided.

Parameters:
  • reference (str or None) – Reference database parameter.

  • filters (str or None) – Filters for variant extraction.

  • fields (str or None) – Fields to extract from the VCF.

Raises:

SystemExit – If any of the mandatory parameters are missing.

Return type:

None

variantcentrifuge.validators.validate_igv_files(local_fasta, ideogram)[source]

Validate the existence and readability of files for IGV integration.

Parameters:
  • local_fasta (str or None) – Path to the local FASTA file. If provided, its index file is expected to be co-located with the same name plus ‘.fai’ extension (e.g., genome.fa.fai).

  • ideogram (str or None) – Path to the ideogram file.

Raises:

SystemExit – If any of the specified files do not exist or are not readable.

Return type:

None