Skip to main content

ISCN 2024 karyotype validation — parser, rule engine, and types. Pure Python, zero runtime dependencies.

Project description

iscn-authenticator

ISCN 2024 karyotype validation — parser, rule engine, and AST types. Pure Python, zero runtime dependencies, supports Python 3.10–3.13.

Validates karyotype strings against the 2024 International System for Human Cytogenomic Nomenclature (ISCN) and returns a structured AST alongside any rule violations.

Install

pip install iscn-authenticator

Quick start

from iscn_authenticator import is_valid_karyotype, validate_karyotype

is_valid_karyotype("46,XX")                              # True
is_valid_karyotype("47,XY,+21")                          # True
is_valid_karyotype("46,XX,t(9;22)(q34;q11.2)")           # True
is_valid_karyotype("47,XY,+21[8]/46,XY[12]")             # True (mosaic)
is_valid_karyotype("garbage")                            # False

result = validate_karyotype("46,XX,del(5)(q13q33)")
# result.valid   -> True
# result.errors  -> []
# result.parsed  -> KaryotypeAST(...)

API surface

  • validate_karyotype(s: str) -> ValidationResult — full validation, returns {valid, errors, parsed}.
  • is_valid_karyotype(s: str) -> bool — boolean convenience wrapper.
  • KaryotypeAST, Abnormality, Breakpoint, CellLine — dataclasses describing the parsed structure.
  • ParseError — raised by the parser on malformed syntax; validate_karyotype catches it and surfaces it through errors.

Supported nomenclature

ISCN 2024 grammar covered:

  • Numerical aberrations: +21, -X, ...
  • Structural rearrangements: del, dup, inv, t (translocation), ins (insertion).
  • Specialized rearrangements: i (isochromosome), idic (isodicentric), der (derivative), dic (dicentric), r (ring), rob (Robertsonian), trp (triplication).
  • Marker chromosomes: mar.
  • Uncertainty (?), inheritance suffixes (mat, pat, dn), mosaicism (cell lines split on /).

ISCN 2024 reference

Implementation tracks the 2024 edition of the International System for Human Cytogenomic Nomenclature. See the ISCN publication.

Cross-implementation parity

A TypeScript port (@iscn/core) lives in the iscn-authenticator monorepo under packages/core/, and consumes the same fixture corpus shipped in this repo at fixtures/validity.json. Parity is enforced via CI in both repos.

Contributing

git clone https://github.com/nuin/iscn-authenticator-py.git
cd iscn-authenticator-py
pip install pre-commit ruff
pre-commit install
python3 -m unittest discover tests

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iscn_authenticator-0.2.0.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iscn_authenticator-0.2.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file iscn_authenticator-0.2.0.tar.gz.

File metadata

  • Download URL: iscn_authenticator-0.2.0.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for iscn_authenticator-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1e2fd4bfd5a6bc5295b8e7142b2330968c320d4965c6e2f990a46b3cccac6be6
MD5 aae6b12589e73e754af97f501e6f2ddb
BLAKE2b-256 de240e4bd0ef7ec1d4b9b547601597f58b1e4b87a60cab6537a29716350c1940

See more details on using hashes here.

Provenance

The following attestation bundles were made for iscn_authenticator-0.2.0.tar.gz:

Publisher: publish-pypi.yml on nuin/iscn-authenticator-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iscn_authenticator-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for iscn_authenticator-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0a7e8f05e32761fb9538296e926f1ff7013ff1d5d8f8cb9d1800456031e5391
MD5 3461cb90d56e495bd2b983cb451fdd2b
BLAKE2b-256 37143cb7d89f5ad7fc12deddd9d25392e4f749676c84c02d97af798c10f2c4fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for iscn_authenticator-0.2.0-py3-none-any.whl:

Publisher: publish-pypi.yml on nuin/iscn-authenticator-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page