Skip to main content

convert_genome (Python)

Python wrapper for the SauersML/convert_genome CLI. Convert direct-to-consumer dumps (23andMe, AncestryDNA, MyHeritage, deCODEme) and standard VCF/BCF into compliant VCF, BCF, or PLINK 1.9 binary — with build detection, sex inference, liftover, and panel harmonisation, all controllable from kwargs.

from convert_genome import convert, OutputFormat

result = convert(
    input="23andme.txt",
    output="out.vcf",
    format=OutputFormat.VCF,
    assembly="hg38",
    standardize=True,
)

result.statistics.emitted_records       # int
result.sample.sex_inferred              # bool
result.build_detection.detected_build   # 'GRCh37' / 'GRCh38' / ...
result.report_path                      # path to <stem>_report.json
result.output_paths                     # files that actually exist on disk
result.yield_rate                       # emitted / total

The wrapper runs the Rust binary, parses the sidecar <stem>_report.json into typed frozen dataclasses, and returns a single ConversionResult.

Install

pip install convert_genome
# the Rust binary:
cargo install convert_genome

Binary located via binary= or PATH. No env-var indirection — if the binary isn't on PATH, pass binary= explicitly. Missing binary → ConvertGenomeBinaryNotFound with the suggested install command.

Shortcuts: skip every auto-discovery step

The CLI will download/auto-detect things it doesn't need to. Pass them in directly:

convert(
    input="raw.txt",
    output="out.vcf",
    reference="/cache/hg38.fa",         # skip FASTA download
    reference_fai="/cache/hg38.fa.fai", # skip .fai indexing
    input_build="hg19",                  # skip build detection
    assembly="GRCh38",                   # target build (still does liftover)
    panel="/cache/1kg_panel.vcf",        # supply harmonisation panel
    sex="female",                        # skip sex inference
    standardize=True,
)

sex is lenient: passing "unknown" or "indeterminate" (e.g. when chaining out of infer_sex) silently omits the --sex flag and lets the CLI run its own inference.

Builder

Converter is a frozen dataclass; every with_* returns a new instance, so branching is safe.

from convert_genome import Converter, Sex, OutputFormat

plan = (
    Converter(input="raw.txt", output_dir="out/", format=OutputFormat.PLINK)
        .with_assembly("GRCh38")
        .with_reference("/cache/hg38.fa", "/cache/hg38.fa.fai")
        .with_panel("/data/1kg_panel.vcf.gz")
        .with_standardize()
        .with_sex(Sex.MALE)
)

print(plan.argv())   # exact argv that would be passed to the CLI
result = plan.run()

Enums

InputFormat.AUTO / .DTC / .VCF / .BCF
OutputFormat.VCF / .BCF / .PLINK
Sex.MALE / .FEMALE
Assembly.GRCH37 / .GRCH38     # plus a `.parse()` classmethod that
                              # accepts 'hg19' / 'hg38' / 'build38' / ...

Output

The Rust tool writes <stem>_report.json alongside the main output. The wrapper loads it into ConversionResult, with sub-dataclasses for each section:

result.input         # InputInfo (path, format, origin)
result.output        # OutputInfo (path, format)
result.reference     # ReferenceInfo (path, origin, assembly)
result.panel         # PanelInfo | None
result.sample        # SampleInfo (id, sex, sex_inferred)
result.build_detection  # BuildDetection | None (detected_build, match rates)
result.statistics    # Statistics (total / emitted / variant / ... records)
result.report_path   # path to the JSON sidecar
result.output_paths  # tuple[Path] — files that actually exist on disk

For PLINK output, output_paths includes the .bed/.bim/.fam trio. For output_dir with a panel, it includes panel.vcf. Non-existent paths are filtered out automatically.

Errors

  • ConvertGenomeBinaryNotFound — CLI not installed / not on PATH.
  • InvalidConfig — argument combination rejected before launching (e.g. missing input file, conflicting output/output_dir).
  • ConvertGenomeFailed — CLI exited non-zero. The exception carries stdout, stderr, returncode.
  • ReportNotFound — CLI ran clean but didn't write a JSON sidecar.

All subclass ConvertGenomeError.

Metadata

Release files for convert-genome 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for convert-genome 0.3.7
File Size Uploaded
convert_genome-0.3.7.tar.gz 273.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for convert-genome 0.3.7
File
convert_genome-0.3.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
convert_genome-0.3.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
convert_genome-0.3.7-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
convert_genome-0.3.7-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 19.0 MB

Release files / convert_genome-0.3.7.tar.gz

Download URL convert_genome-0.3.7.tar.gz
Size 273.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ea0132caa5cd59f28cb31b994acd86b6113631386a731a94e420a138d0d5a48c
BLAKE2b-256 checksum
How to use checksums
ebbe1779a4d81c3d924bb77604c2c63eb163f81f5b685324e0ba2022fae83f48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / convert_genome-0.3.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL convert_genome-0.3.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.8 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
6b79d53ed6469d1fce76b1f0c61847b9ed5ae82f914da95a44b606bd8ada46b9
BLAKE2b-256 checksum
How to use checksums
76ae72419f721fb75bc763c42e5627c4c7bd33fd398298957eb4cea04fbf80fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / convert_genome-0.3.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL convert_genome-0.3.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.0 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d83306013e179fb6387f0a4c50e22dea1bf94afc43eb5bbc0083c0a49bb0a014
BLAKE2b-256 checksum
How to use checksums
5e637ad7318376a5adb4cd1e008166f9d411053d701a6cfafb29625cbb474cbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / convert_genome-0.3.7-cp39-abi3-macosx_11_0_arm64.whl

Download URL convert_genome-0.3.7-cp39-abi3-macosx_11_0_arm64.whl
Size 4.6 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b471784443452944b14402d3ec3d4da0d3ff81f83d27bf2eef72cde47e7f9a8e
BLAKE2b-256 checksum
How to use checksums
c89575211d9d07d2f5f3c6fb346c16f6674e6cfcecbdccf3f761242656926029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / convert_genome-0.3.7-cp39-abi3-macosx_10_12_x86_64.whl

Download URL convert_genome-0.3.7-cp39-abi3-macosx_10_12_x86_64.whl
Size 4.3 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
da5bc2123c551c3fa3eebe86cb1a9fd3908370c6b926f7dd20a090e39bd53362
BLAKE2b-256 checksum
How to use checksums
9cd8e76fd2d563cd7643cef437b676ab0c4a864f9d1fc13d34b1b1800cb0ddc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

0.3.8

5 release files

This release

0.3.7 This release

5 release files

0.3.6

5 release files

0.3.5

5 release files

0.3.4

5 release files

0.3.3

5 release files

0.3.2

5 release files

0.3.1

5 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page