Skip to main content

pxil: sequences as pixels

pxil is a small, permissive file format for one sequence as a picture: a gene, a transcript, a protein or any other string of symbols, one pixel per residue, row after row like lines of text.

A pxil file is a PNG image. Its pixel values are the residues, its metadata gives the alphabet, length and row width, and its palette colours them, so the same file opens in any image software and reads back as the exact sequence. That makes pxil handy for quick analysis, comparison and sharing of single sequences. It is not meant for keeping genomes: that is what gpxil, the genome pixel image format, is for.

The Gpxil browser downloads genes, transcripts and proteins as pxil files:

File What it holds
TP53_ENSG00000141510.gene.pxil.png the gene's genomic sequence, 5′ to 3′, introns and soft-masked repeats included
TP53-201_ENST00000269305.transcript.pxil.png the transcript's spliced sequence, 5′ to 3′
TP53-201_ENSP00000269305.protein.pxil.png the protein, one pixel per amino acid

These three files are in examples/.

The format in brief

  • A PNG, 8-bit indexed colour. Each pixel is one residue; its palette index is the residue's position in the file's alphabet.
  • Residues fill rows of width pixels; the rest of the last row is index 0.
  • An iTXt chunk called pxil holds JSON metadata: the format version, kind (gene, transcript, protein or sequence), alphabet, length and width, and optionally identifiers, coordinates, a SHA-256 of the sequence and anything else useful.
  • Two standard alphabets: DNA uses gpxil's reference codes (-ACMGRSVTWYHKDBN-acmgrsvtwyhkdbn, lower case for soft-masked repeats); protein uses -ACDEFGHIKLMNPQRSTVWYUOBZJX*. Any other alphabet of up to 256 symbols is allowed.
  • Files are named <label>.<kind>.pxil.png, with the database identifier in the label. The .png ending means they open as pictures anywhere.

The full description is SPEC.md, also as a PDF, pxil-spec.pdf.

Reading and writing pxil files in Python

pxil.py is a single module that needs only Pillow:

pip install pxil
import pxil

sequence, meta = pxil.read("examples/TP53-201_ENSP00000269305.protein.pxil.png")
print(meta["id"], len(sequence), sequence[:10])   # ENSP00000269305 394 MEEPQSDPSV

pxil.write("my.transcript.pxil.png", "ATGGAGGAGCCGCAGTCAGATCC", kind="transcript", id="my-1")

From the command line, pxil (or python -m pxil) prints pxil files as FASTA, or their metadata:

pxil examples/*.pxil.png
pxil examples/*.protein.pxil.png -o proteins.fa
pxil --info examples/TP53-201_ENST00000269305.transcript.pxil.png

Each sequence is named by its id, name and kind (>ENSP00000269305 TP53-201 protein). A person's own version of a sequence, such as gpxil2pxil makes from a genome, has the person and the haplotype joined to its id (>ENSP00000269305_HG002-hap1 TP53-201 protein), so the reference's and each haplotype's sequences keep names of their own in one FASTA file, ready for an alignment program.

Without the module, any PNG reader will do: read the palette indices, keep the first length, and look each up in alphabet (see SPEC.md, section 8).

Tests

pip install pillow pytest
python -m pytest tests

To release a version: set it in pyproject.toml and in pxil.py's __version__, merge, and publish a GitHub release tagged with the version (v0.1.0). The workflow release.yml then tests the module, builds it and publishes it to PyPI by trusted publishing.

Licence

Copyright © 2026 Chronomic Medicine Group, Department of Genomic Medicine, University of Cambridge. Released under the MIT licence.

Metadata

Release files for pxil 0.1.1

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

Source distribution (sdist)

Source distribution for pxil 0.1.1
File Size Uploaded Provenance Actions
pxil-0.1.1.tar.gz 10.7 kB With provenance Details for pxil-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pxil 0.1.1
File Interpreter ABI Platform Actions
pxil-0.1.1-py3-none-any.whl Python 3 none any Details for pxil-0.1.1-py3-none-any.whl

Total release size: 19.2 kB

Release files / pxil-0.1.1.tar.gz

Download URL pxil-0.1.1.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
185d650d4b58033ca2c3c113fd8e963cff03c300348787b014c4769198e9097c
BLAKE2b-256 checksum
How to use checksums
c8503f0333db99f13eb9816439c6e8af9d6d2dd2c45ffd8c0b757bf5c1ed28e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / pxil-0.1.1-py3-none-any.whl

Download URL pxil-0.1.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e8615c35727f44f11fdf0664a0c509f4f68e9fd4548a629e3aa954c9e8cf531
BLAKE2b-256 checksum
How to use checksums
3d80e1ba5851e17ef99d1d252c5442bf7556dccbbb4bb4823582cfd3f95b3745
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for pxil 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pxil-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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