Skip to content

geno_lewm.deploy.import_.sequencing

sequencing

Sequencing.com-style WGS JSON importer.

parse_sequencing_json

parse_sequencing_json(path: str | Path) -> tuple[VcfVariant, ...]

Parse a Sequencing.com-style JSON variant array into VCF records.

Source code in geno_lewm/deploy/import_/sequencing.py
def parse_sequencing_json(path: str | Path) -> tuple[VcfVariant, ...]:
    """Parse a Sequencing.com-style JSON variant array into VCF records."""
    src = Path(path)
    try:
        payload = json.loads(src.read_text(encoding="utf-8"))
    except json.JSONDecodeError as exc:
        raise VcfParseError(
            "Sequencing.com JSON is not valid JSON",
            details={"path": str(src), "line": exc.lineno, "column": exc.colno},
        ) from exc
    except OSError as exc:
        raise VcfParseError(
            "could not read Sequencing.com JSON",
            details={"path": str(src), "error": str(exc)},
        ) from exc

    rows = _variant_rows(payload)
    return tuple(_row_to_variant(row, index=index) for index, row in enumerate(rows, start=1))

convert_sequencing_json_to_vcf

convert_sequencing_json_to_vcf(input_path: str | Path, output_path: str | Path, *, sample_id: str = 'sample') -> VcfConversionSummary

Convert Sequencing.com-style WGS JSON to a local VCF file.

Source code in geno_lewm/deploy/import_/sequencing.py
def convert_sequencing_json_to_vcf(
    input_path: str | Path,
    output_path: str | Path,
    *,
    sample_id: str = "sample",
) -> VcfConversionSummary:
    """Convert Sequencing.com-style WGS JSON to a local VCF file."""
    variants = parse_sequencing_json(input_path)
    path = write_vcf_variants(variants, output_path, sample_id=sample_id)
    return VcfConversionSummary(
        output_path=path,
        records_written=len(variants),
        ref_calls_skipped=0,
        no_calls_skipped=0,
    )