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.0

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.0
File Size Uploaded Provenance Actions
pxil-0.1.0.tar.gz 10.4 kB With provenance Details for pxil-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 18.7 kB

Release files / pxil-0.1.0.tar.gz

Download URL pxil-0.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4e524178df97fcbc417954e93e2b1ed5338cac0a19eb2b3d3eaaaa49ba389c29
BLAKE2b-256 checksum
How to use checksums
0f760e63a65e0b9b28395f31ea0878e769ec1b23503dbc6d661393c6cf5625d7
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 27, 2026.

Transparency log

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

Download URL pxil-0.1.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1eaf61ba609b4208154882d61f15c0a1fc364613e8ce610ee0519cbf8d716542
BLAKE2b-256 checksum
How to use checksums
cd181295ec2a008fad4a912fd8ab41787403bd1912d0024d0375cd308988676e
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 27, 2026.

Transparency log

Security for pxil 0.1.0

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.0.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 27, 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.0 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