gpf.tools package

Submodules

gpf.tools.dae2vcf module

gpf.tools.dae2vcf.main(argv: list[str] | None = None, grr: GenomicResourceRepo | None = None) None[source]

Convert transmitted DAE variants into VCF file format.

gpf.tools.dae2vcf.parse_cli_arguments(argv: list[str]) Namespace[source]

Create CLI parser.

gpf.tools.dataset_helpers module

class gpf.tools.dataset_helpers.DatasetHelpers(gpf_instance: GPFInstance | None = None)[source]

Bases: object

Helper class for work with studies in impala genotype storage.

disable_study_config(dataset_id: str, *, dry_run: bool | None = None) None[source]

Disable dataset.

find_genotype_data_config(dataset_id: str) Box | None[source]

Find and return configuration of a dataset.

find_genotype_data_config_file(dataset_id: str) str | None[source]

Find and return config filename for a dataset.

get_genotype_storage(dataset_id: str) GenotypeStorage | None[source]

Find the genotype storage that stores a dataset.

remove_study_config(dataset_id: str) None[source]

Remove study config for a dataset.

rename_study_config(dataset_id: str, new_id: str, config_content: dict[str, Any], *, dry_run: bool | None = None) None[source]

Rename study config for a dataset.

gpf.tools.denovo2vcf module

gpf.tools.denovo2vcf.main(argv: list[str] | None = None, grr: GenomicResourceRepo | None = None) None[source]

Liftover de Novo variants tool main function.

gpf.tools.denovo2vcf.parse_cli_arguments(argv: list[str]) Namespace[source]

Create CLI parser.

gpf.tools.draw_pedigree module

Tool to draw pedigrees defined in a file.

gpf.tools.draw_pedigree.build_families_report(families: FamiliesData) FamiliesReport[source]

Build a family report based on affected status.

gpf.tools.draw_pedigree.build_family_layout(family: Family) list[Layout][source]
gpf.tools.draw_pedigree.draw_families(families: FamiliesData) Generator[Figure, None, None][source]

Draw families.

gpf.tools.draw_pedigree.draw_families_report(families: FamiliesData) Generator[Figure, None, None][source]

Draw families from families report.

gpf.tools.draw_pedigree.draw_pedigree(layout: list[Layout], title: str, *, show_family: bool = True, tags: set[str] | None = None) Figure[source]

Draw a pedigree layout.

gpf.tools.draw_pedigree.main(argv: list[str] | None = None) None[source]

Run the CLI for draw_pedigree tool.

gpf.tools.families_withdrawal_common module

Shared helpers for the families-withdrawal CLI tools.

Two purpose-specific tools build on this module:

  • families_withdrawal_genotypes rewrites the pedigree Parquet file of a duckdb_parquet genotype study via DuckDB (the family-variant files are left untouched; withdrawn families become inaccessible at query time).

  • families_withdrawal_phenotypes removes families from a phenotype study via SQL DELETE.

Both back up every file they modify by default. A backup is an in-place sibling named <stem>.<stamp>.<ext>.bak where <stamp> is a single UTC timestamp shared across every file modified in one run. To restore a backup manually, move (or copy) it back over the original, e.g.:

mv pedigree.20260625T143000Z.parquet.bak pedigree.parquet
cp test_pheno.20260625T143000Z.db.bak test_pheno.db

The terminal .bak suffix keeps backups out of the *.parquet scan, so a study can be processed repeatedly without re-processing prior backups.

gpf.tools.families_withdrawal_common.backup_path(path: Path, stamp: str) Path[source]

Return the <stem>.<stamp>.<ext>.bak sibling of path.

stem is the filename without its final extension and ext is the final suffix (without the leading dot). The terminal .bak keeps the backup out of any *.parquet glob scan.

gpf.tools.families_withdrawal_common.build_arg_parser(description: str) ArgumentParser[source]

Build the argument parser shared by both families-withdrawal tools.

gpf.tools.families_withdrawal_common.make_run_stamp() str[source]

Return a single UTC stamp for one run, e.g. 20260625T143000Z.

gpf.tools.families_withdrawal_common.require_study_kind(gpf_instance: GPFInstance, study_id: str, *, kind: Literal['genotypes', 'phenotypes']) None[source]

Validate that study_id is of the expected kind.

Exits with code 1 if the study is of the other kind (pointing at the matching tool) or if it is unknown to the instance entirely.

gpf.tools.families_withdrawal_common.resolve_family_ids(args: Namespace) set[str][source]

Resolve family IDs from positional args and/or --families-file.

Exits with code 1 if neither source supplies any IDs.

gpf.tools.families_withdrawal_genotypes module

CLI tool to withdraw families from a duckdb_parquet genotype study.

Only the study’s pedigree Parquet file is rewritten (via DuckDB), dropping every row whose family ID is one of the requested families. The family-variant Parquet files are deliberately left untouched: at query time a family-variant row whose family is absent from the pedigree is simply skipped, so the withdrawn families’ variants become inaccessible without rewriting the (large) variant files. Summary-variant frequencies/counts and cached artifacts (common reports, denovo gene sets, family counts) are NOT recomputed — regenerate them with the dedicated tools (e.g. generate_common_report) if needed.

By default the pedigree is backed up first, as an in-place sibling named <stem>.<stamp>.<ext>.bak, e.g. pedigree.20260625T143000Z.parquet.bak. Pass --no-backup to skip the backup, or --dry-run to report the intended row changes without touching any file. To restore a backup manually, move it back over the original:

mv pedigree.20260625T143000Z.parquet.bak pedigree.parquet
gpf.tools.families_withdrawal_genotypes.main(argv: list[str] | None = None, *, gpf_instance: GPFInstance | None = None) None[source]

Remove families from a duckdb_parquet genotype study.

gpf.tools.families_withdrawal_phenotypes module

CLI tool to withdraw families from a phenotype study.

The phenotype PhenoDb is updated via SQL DELETE of every person, instrument-value row, and family record belonging to the requested families.

By default the database file is backed up first, as an in-place sibling named <stem>.<stamp>.<ext>.bak (one shared UTC stamp per run), e.g. test_pheno.20260625T143000Z.db.bak. Pass --no-backup to skip the backup, or --dry-run to report the intended row changes without touching the database. To restore a backup manually, copy it back over the original:

cp test_pheno.20260625T143000Z.db.bak test_pheno.db
gpf.tools.families_withdrawal_phenotypes.main(argv: list[str] | None = None, *, gpf_instance: GPFInstance | None = None) None[source]

Remove families from a phenotype study.

gpf.tools.generate_common_report module

gpf.tools.generate_common_report.main(argv: list[str] | None = None, *, gpf_instance: GPFInstance | None = None) None[source]

Command line tool to generate dataset statistics.

gpf.tools.generate_denovo_gene_sets module

gpf.tools.generate_denovo_gene_sets.main(argv: list[str] | None = None, *, gpf_instance: GPFInstance | None = None) None[source]

Generate denovo gene sets CLI.

gpf.tools.gpf_convert_study_config module

gpf.tools.gpf_convert_study_config.load_study_config(study_config_filename: str) dict[source]

Load study config.

gpf.tools.gpf_convert_study_config.main(gpf_instance: GPFInstance | None = None, argv: list[str] | None = None) None[source]

Convert GPF genotype data configuration to YAML.

gpf.tools.gpf_validation_runner module

class gpf.tools.gpf_validation_runner.AbstractRunner(expectations: dict[str, Any], gpf_instance: GPFInstance)[source]

Bases: object

The base class for test runners.

counter(status: TestStatus) int[source]
property error_case_count: int
property failed_case_count: int
property passed_case_count: int
class gpf.tools.gpf_validation_runner.BaseGenotypeBrowserRunner(expectations: dict[str, Any], gpf_instance: GPFInstance)[source]

Bases: AbstractRunner

Base class for Genotype Browser Runners.

class gpf.tools.gpf_validation_runner.GenotypeBrowserRunner(expectations: dict[str, Any], gpf_instance: GPFInstance, *, detailed_reporting: bool, skip_columns: set)[source]

Bases: BaseGenotypeBrowserRunner

Run Genotype Browser tests.

run() None[source]

Run tests.

store_results(dirname: str) None[source]

Store results.

class gpf.tools.gpf_validation_runner.MainRunner(gpf_instance: GPFInstance, outfilename: str, *, detailed_reporting: bool, skip_columns: list[Any])[source]

Bases: object

Main runner.

static collect_expectations(expectations: str) Iterator[dict[str, Any]][source]

Collect expectations.

counter(status: TestStatus) int[source]
property errors_case_count: int
property failed_case_count: int
main(expectations_iterator: Iterator[Any]) None[source]

Entry point for this runner.

make_validation_runner(expectations: dict[str, Any]) GenotypeBrowserRunner[source]

Create a validation runner.

property passed_case_count: int
static store_junit_results(runners: list[AbstractRunner], outfilename: str) None[source]

Store junit results.

store_results(expectations_iterator: Iterator[dict[str, Any]], dirname: str) None[source]
summary() None[source]

Print a summary of the test results.

class gpf.tools.gpf_validation_runner.TestResult(expectation: dict[str, Any] | None = None, case: dict[str, Any] | None = None, test_for: str | None = None, params: dict[str, Any] | None = None, result: str | None = None)[source]

Bases: object

Encapsulate the result of a test.

to_xml_element() Element[source]

Convert to an XML element.

class gpf.tools.gpf_validation_runner.TestStatus(*values)[source]

Bases: Enum

ERROR = 4
FAIL = 2
NOTSET = 0
PASSED = 1
class gpf.tools.gpf_validation_runner.TestSuite(study: str, target: str, name: str)[source]

Bases: object

A collection of tests.

append(case: TestResult) None[source]
cases: list[TestResult]
to_xml_element() Element[source]

Convert to an XML element.

gpf.tools.gpf_validation_runner.main(argv: list[str] | None = None) None[source]

Entry point for the runner script.

gpf.tools.liftover_tools module

class gpf.tools.liftover_tools.CNVLiftoverTool[source]

Bases: LiftoverTool

CNV liftover tool class.

build_cli_arguments_parser() ArgumentParser[source]

Create CLI parser.

liftover_variants(region: Region | None = None) None[source]

Liftover CNV variants method.

class gpf.tools.liftover_tools.DaeLiftoverTool[source]

Bases: LiftoverTool

DAE liftover tool class.

build_cli_arguments_parser() ArgumentParser[source]

Create CLI parser.

liftover_variants(region: Region | None = None) None[source]

Liftover CNV variants method.

class gpf.tools.liftover_tools.DenovoLiftoverTool[source]

Bases: LiftoverTool

Denovo liftover tool class.

build_cli_arguments_parser() ArgumentParser[source]

Create CLI parser.

liftover_variants(region: Region | None = None) None[source]

Liftover CNV variants method.

class gpf.tools.liftover_tools.LiftoverTool(description: str, default_output: str)[source]

Bases: ABC

Liftover tools base class.

build_cli_arguments_parser() ArgumentParser[source]

Create CLI parser.

build_liftover_pipeline(grr: GenomicResourceRepo) AnnotationPipeline[source]

Build liftover annotator based on the selected mode.

abstractmethod liftover_variants(region: Region | None = None) None[source]

Liftover variants abstract method.

run(argv: list[str] | None = None, grr: GenomicResourceRepo | None = None) None[source]

Liftover tool main function.

class gpf.tools.liftover_tools.VCFLiftoverTool[source]

Bases: LiftoverTool

VCF liftover tool class.

build_cli_arguments_parser() ArgumentParser[source]

Create CLI parser.

liftover_variants(region: Region | None = None) None[source]

Liftover CNV variants method.

static report_variant(variant: tuple[str, int, str, list[str]] | None) str[source]

Report variant.

static report_vcf_variant(vcf_variant: VariantRecord) str[source]

Report VCF variant.

gpf.tools.liftover_tools.cnv_liftover_main(argv: list[str] | None = None, grr: GenomicResourceRepo | None = None) None[source]

CNV liftover tool main function.

gpf.tools.liftover_tools.dae_liftover_main(argv: list[str] | None = None, grr: GenomicResourceRepo | None = None) None[source]

DAE liftover tool main function.

gpf.tools.liftover_tools.denovo_liftover_main(argv: list[str] | None = None, grr: GenomicResourceRepo | None = None) None[source]

Denovo liftover tool main function.

gpf.tools.liftover_tools.vcf_liftover_main(argv: list[str] | None = None, grr: GenomicResourceRepo | None = None) None[source]

VCF liftover tool main function.

gpf.tools.ped2ped module

Tool to convert pedigree file into cannonical GPF pedigree file.

gpf.tools.ped2ped.main(argv: list[str] | None = None) None[source]

Transform a pedigree file into cannonical GPF pedigree.

It should be called from the command line.

gpf.tools.reannotate_instance module

class gpf.tools.reannotate_instance.ReannotateInstanceTool(raw_args: list[str] | None = None, *, gpf_instance: GPFInstance | None = None)[source]

Bases: object

Annotation tool to reannotate the configured GPF instance

get_argument_parser() ArgumentParser[source]

Construct and configure argument parser.

run() None[source]

Run the tool.

gpf.tools.reannotate_instance.cli(raw_args: list[str] | None = None) None[source]

Entry point method for instance reannotation tool.

gpf.tools.simple_study_import module

gpf.tools.simple_study_import.build_import_project(args: Namespace, gpf_instance: GPFInstance) ImportProject[source]

Build an import project based on the CLI arguments.

gpf.tools.simple_study_import.cli_arguments(dae_config: Box, argv: list[str] | None = None) Namespace[source]

Create and return CLI arguments parser.

gpf.tools.simple_study_import.main(argv: list[str] | None = None, gpf_instance: GPFInstance | None = None) None[source]

Run the simple study import procedure.

gpf.tools.vcf2tsv module

gpf.tools.vcf2tsv.main(argv: list[str] | None = None, grr: GenomicResourceRepo | None = None) None[source]

Liftover de Novo variants tool main function.

gpf.tools.vcf2tsv.parse_cli_arguments(argv: list[str]) Namespace[source]

Create CLI parser.

gpf.tools.verify_parquet module

Tool to verify file-level structural integrity of parquet files.

class gpf.tools.verify_parquet.FileResult(path: str, ok: bool, error_class: str | None = None, message: str | None = None, row_group: int | None = None)[source]

Bases: object

Outcome of verifying a single parquet file.

error_class: str | None = None
message: str | None = None
ok: bool
path: str
row_group: int | None = None
gpf.tools.verify_parquet.main(argv: list[str] | None = None) int[source]

CLI entry point. Returns process exit code.

gpf.tools.verify_parquet.verify_parquet_file(path: str, *, deep: bool = False) FileResult[source]

Verify file-level structural integrity of a single parquet file.

Default check opens the file and parses footer + row-group metadata. deep=True additionally decodes every row group, catching data-page corruption that the metadata pass cannot see.

Module contents