🧬 pySIFTS
SIFTS PDB ↔ UniProt mapping, entity dissection, and an interactive sequence-coverage viewer — for any RCSB entry or local structure file.
From a PDB ID — or a local .cif / .pdb — to a residue-level
SIFTS mapping, per-chain coverage statistics, and a genome-browser-style viewer:
entity → sifts → view → all,
with every network artifact cached and every output deterministic.
Installation · Usage · Features · Commands · Artifacts · Viewer
If this project helps you, please consider giving it a Star ⭐. Thank you!
🚀 Features
- Entity dissection (
entity) — polymer entities, chains,kind(protein / nucleic acid / other), UniProt accessions, and chimeric-chain detection, from the RCSB REST API or a local file. - Residue-level SIFTS mapping (
sifts) — the authoritative 7-column PDB↔UniProt table, written as TSV alongside per-chain coverage statistics. - Full-length coordinates — UniProt FASTA anchors each track to the complete sequence, so residues the structure never resolved are visible as
unobserved, not silently dropped. SIFTS alone only lists structurally touched positions. - Interactive 2D viewer (
view) — per-chain track tabs over an all-chains overview strip; hover, wheel zoom, drag pan, click-to-pin, and keyboard navigation. Serve it locally or export it as one self-contained HTML file. - One-shot pipeline (
all) — all four artifacts for one entry in a single run; no server started. - Offline-friendly — RCSB JSON, SIFTS XML/TSV, and UniProt FASTA are cached;
--forcere-downloads on demand. - Framework-free front end — two
<canvas>elements plus plain DOM, no build step, no bundled runtime.
Prerequisites
Nothing to install beyond Python itself — all data comes from public REST endpoints.
| Source | Used for | Endpoint |
|---|---|---|
| RCSB PDB | entry metadata, polymer entities, chains, accessions | https://data.rcsb.org/rest/v1/core/… |
| EBI SIFTS | residue-level PDB ↔ UniProt mapping | https://www.ebi.ac.uk/pdbe/files/sifts/<pdb>.xml.gz |
| UniProt | full-length FASTA sequences | https://rest.uniprot.org/uniprotkb/<acc>.fasta |
A network connection is required on a cold cache only. Downloads are retried and written atomically; cached results are reused on every later run.
Installation
git clone https://github.com/MaybeBio/pySIFTS.git
cd pySIFTS
pip install -e .
Requires Python 3.9+. The static viewer assets (index.html, app.js,
style.css) ship inside the package — there is no separate download or build step.
Installing from PyPI (
pip install pySIFTS) is planned once the package is published.
Usage
❯ pySIFTS --help
Usage: pySIFTS [OPTIONS] COMMAND [ARGS]...
SIFTS PDB-to-UniProt mapping and sequence coverage viewer
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --version Show the version and exit. │
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ entity Dissect the polymer entities and chains of a PDB entry. │
│ sifts Write the SIFTS mapping and per-chain coverage statistics. │
│ view Serve the interactive sequence view, or export it as one HTML file. │
│ all Write all four artifacts for one entry (no server is started). │
╰──────────────────────────────────────────────────────────────────────────────╯
Quick start
# Four artifacts → ./pySIFTS_out/4ins/
pySIFTS all 4ins --out ./pySIFTS_out
# Explore the same entry in the browser
pySIFTS view 4ins
# Or ship a single HTML file — no server needed
pySIFTS view 4ins --html 4ins.html
flowchart LR
Q["PDB ID<br/>or local .cif / .pdb"] --> E["RCSB entry +<br/>polymer entities"]
Q --> S["SIFTS XML<br/>→ TSV rows"]
E --> J["entity.json"]
S --> T["tsv"]
S --> C["chains.csv<br/>per-chain stats"]
U["UniProt FASTA"] --> V["view.json"]
S --> V
V --> W["local server<br/>or single HTML"]
Commands
1️⃣ entity — dissect the structure
❯ pySIFTS entity 7w1m
┏━━━━━━┳━━━━━━━━┳━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ PDB ┃ Entity ┃ Asym ┃ Auth Asym ┃ UniProt ┃ Kind ┃ Chimeric ┃
┡━━━━━━╇━━━━━━━━╇━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ 7W1M │ 1 │ A │ A │ Q14683 │ protein │ no │
│ 7W1M │ 2 │ B │ B │ Q9UQE7 │ protein │ no │
│ 7W1M │ 3 │ C │ C │ O60216 │ protein │ no │
│ 7W1M │ 4 │ D │ D │ Q8WVM7 │ protein │ no │
│ 7W1M │ 5 │ E │ E │ Q6KC79 │ protein │ no │
│ 7W1M │ 6 │ F │ F │ │ nucleic_acid │ no │
│ 7W1M │ 7 │ G │ G │ │ nucleic_acid │ no │
│ 7W1M │ 8 │ H │ H │ P49711 │ protein │ no │
└──────┴────────┴──────┴───────────┴─────────┴──────────────┴──────────┘
--jsonprints the fullentity.jsonpayload instead of the table.--out DIRalso writes<DIR>/<pdb>/<pdb>.entity.json.- One row per (chain, accession) pair: a chimeric chain yields one row per accession, never a zipped approximation.
2️⃣ sifts — mapping + coverage statistics
❯ pySIFTS sifts 4ins --out ./pySIFTS_out
┏━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┓
┃ Chain ┃ UniProt ┃ Mapped ┃ Observed ┃ Missing ┃ Covered ┃
┡━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━┩
│ A │ P01315 │ 21 │ 21 │ 0 │ 88-108 │
│ B │ P01315 │ 30 │ 30 │ 0 │ 25-54 │
│ C │ P01315 │ 21 │ 21 │ 0 │ 88-108 │
│ D │ P01315 │ 30 │ 30 │ 0 │ 25-54 │
└───────┴─────────┴────────┴──────────┴─────────┴─────────┘
Writes two files alongside that table:
4ins/
├── 4ins.tsv # 7-column residue-level mapping, no header
└── 4ins.chains.csv # one row per (chain, UniProt) pair
The TSV columns, in order:
| # | Column | Meaning |
|---|---|---|
| 0 | PDB_ID |
entry ID, lowercase |
| 1 | PDB_chain |
author chain ID (auth_asym_id) |
| 2 | PDB_res |
three-letter residue name |
| 3 | PDB_pos |
PDB residue number, or null when unobserved |
| 4 | Uniprot_ID |
UniProt accession, lowercase |
| 5 | Uniprot_res |
one-letter amino acid |
| 6 | Uniprot_pos |
position on the full UniProt sequence |
chains.csv carries pdb_id, auth_asym_id, asym_id, entity_id, uniprot_id, kind, chimeric, mapped, observed, missing, covered_uni — where covered_uni
lists the observed UniProt ranges as a-b;c-d.
3️⃣ view — the interactive sequence view
# Serve on a random localhost port and open a browser
pySIFTS view 4ins
# Fixed port, no browser (e.g. on a remote host)
pySIFTS view 4ins --port 8765 --no-browser
# One self-contained file — assets inlined, no server
pySIFTS view 4ins --html 4ins.html
See The viewer for the interaction model.
4️⃣ all — everything at once
pySIFTS all 4ins --out ./pySIFTS_out --force
Runs entity → sifts → view payload in one pass and writes all four
artifacts. It never starts a server; use view --html when you also want the
standalone page.
📦 Artifacts
| File | Contents |
|---|---|
<pdb>.tsv |
7-column residue-level SIFTS mapping, no header |
<pdb>.entity.json |
RCSB entry and polymer-entity payloads, chains, accessions |
<pdb>.chains.csv |
One row per (chain, UniProt) pair with mapped/observed/missing/covered statistics |
<pdb>.view.json |
Viewer payload: per-chain tracks with a dense per-residue state array |
Output defaults to ./pySIFTS_out; files go to
<out>/<pdb_lower>/<pdb_lower>.<ext>. All writes are atomic (temp file +
os.replace), so an interrupted run never leaves a half-written artifact.
Residue states
Each protein track is dense over the full UniProt length (when the UniProt FASTA is available; otherwise it falls back to the SIFTS span and warns). Every position carries one of three states:
| State | Color | Meaning |
|---|---|---|
0 |
🟦 #2f6feb |
observed — in SIFTS and has PDB coordinates |
1 |
⬜ #d7dbe3 |
unobserved — in SIFTS but no coordinates |
2 |
◻️ #f7f8fa |
unmapped — absent from SIFTS entirely |
Non-protein tracks (DNA/RNA/other) render from the entity's own one-letter sequence and carry no per-residue state.
🖥️ The viewer
A genome-browser-style layout: chain tabs across the top, the active chain's tracks below, and a pinned all-chains overview strip at the bottom. A chimeric chain gets one track per UniProt accession, stacked; the overview strip always summarizes the whole chain.
| Interaction | Effect |
|---|---|
| Click a chain tab or strip row | Activate that chain |
| Drag a track | Pan the visible window |
| Wheel over a track | Zoom around the cursor (overview keeps the window in frame) |
| Hover a residue | Tooltip with PDB and UniProt position |
| Click a residue | Pin the selection; click again or press Esc to clear |
← / → |
Pan the active track by 25% of the window |
+ / - |
Zoom in / out by 2× |
Home |
Reset the active track to the full sequence |
3D seam
The 2D viewer is the only implemented view, but it emits two DOM events on
document so a future 3D panel can follow the selection without touching the
2D code:
new CustomEvent('pysifts:select', { detail: { authChain, authResnum, uniPos } })
new CustomEvent('pysifts:window', { detail: { authChain, uniStart, uniEnd } })
authResnum and uniPos may be null. In serve mode the structure bytes are
available at GET /api/structure when the query was a local file; otherwise
that route returns 404. HTML exports set structure to null and show a
static export · 3D disabled banner.
⚙️ Caching, options, and exit codes
Commands share these options (--force where listed):
| Option | Meaning |
|---|---|
--cache-dir DIR |
Cache location (default ~/.cache/pysifts) |
--quiet, -q |
Suppress warnings |
--force |
Bypass cached SIFTS XML/TSV and UniProt FASTA (sifts, view, all) |
RCSB entity JSON is cheap to reuse and is not affected by --force.
Exit codes: 0 success · 1 domain error (e.g. SIFTS mapping unavailable) ·
2 usage error.
Development
pip install -e . pytest
pytest # offline suite
pytest -m network # hits RCSB / EBI / UniProt (cold cache, ~45 s)
License
GPL-3.0-or-later. See LICENSE.
Metadata
Release files for pySIFTS 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysifts-0.1.0.tar.gz | 45.5 kB | Without provenance | Details for pysifts-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pysifts-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pysifts-0.1.0-py3-none-any.whl |
Total release size: 88.8 kB
Release files / pysifts-0.1.0.tar.gz
| Download URL | pysifts-0.1.0.tar.gz |
|---|---|
| Size | 45.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6dc7a75511b61c98c67dda45d30f7eca9d238866183f4a5e7f5258126039d8e7
|
|
BLAKE2b-256 checksum How to use checksums |
194effd84ea39eb0507ac2da9a0c757212f353da702f0d970d40ed36fa306b17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / pysifts-0.1.0-py3-none-any.whl
| Download URL | pysifts-0.1.0-py3-none-any.whl |
|---|---|
| Size | 43.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c08cf66a2fb84e13bddd3fbee0e70b752a721aeba86635093bcef649ece2d79e
|
|
BLAKE2b-256 checksum How to use checksums |
069872b311c0821d9832f3ca5f68137d0bc4d4d60ea4fca131825f82f587a40e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for pySIFTS 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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.