Skip to content

Tutorial

This is the guided, end-to-end path: start from nothing and finish with a working viewer that shows the full UniProt annotation for a protein plus your own track, recoloured to match your site. It’s one continuous example on a single protein: P05067, amyloid precursor protein, the reference accession used throughout these docs.

Each step ends with a Try it live link that opens the exact setup in the playground, so you can see it render and edit it without leaving the browser. When you want the full detail behind a step, follow the links to the how-to guides.

The quickest way to follow along is the Starter Kit: a no-build template repository you can copy and open straight in the browser. You can also work in your own page served by any static file server or your app’s dev server, or use the playground for the config-only steps. No build tooling is required.

Step 1: Add the component and point it at an accession

Section titled “Step 1: Add the component and point it at an accession”

<protvista-uniprot> is a web component: a custom element that works in any page with no bundler or framework. Load it once and drop the tag in with an accession:

<script type="module" src="./protvista-uniprot.mjs"></script>
<protvista-uniprot accession="P05067"></protvista-uniprot>

protvista-uniprot.mjs is the component’s built ES-module bundle. Until 5.0 is published to npm, build it from source and copy it next to your page:

Terminal window
git clone https://github.com/ebi-webcomponents/protvista
cd protvista
yarn install && yarn build
# then copy dist/protvista-uniprot.mjs next to your HTML page

That single attribute gives you the full default UniProt viewer for the protein: domains, variants, binding sites, structure coverage, AlphaFold confidence, and more. No config required.

Embed the viewer covers both ways to load the component and every attribute (config-src, notooltip, nostructure, …).

Now bring your own annotations. A features track can read a CSV file directly: point data: at the file and the .csv extension picks the parser for you: no adapter: needed.

Say your lab has flagged some hotspot regions. Put them in a CSV with the feature-record columns type,start,end,description,score:

type,start,end,description,score
DOMAIN,18,289,Extracellular domain (custom re-annotation),0.95
BINDING,132,140,Predicted heparin-binding site,0.87
REGION,290,340,Acidic-rich linker region,0.6
MUTAGEN,614,614,Lab-observed loss-of-function point mutation,0.75

Then describe a viewer that shows just that file as one standalone track (a rows: entry with data: and no tracks: needs no group wrapper):

accession: P05067
rows:
- id: hotspots
label: Hotspots
kind: features
data: ./hotspots.csv
description: Hotspot regions identified by our lab's pipeline

Save the config as my-config.yaml next to hotspots.csv and point the element at it:

<protvista-uniprot config-src="./my-config.yaml"></protvista-uniprot>

Load your own data covers the full feature record and the TSV, JSON, and BED formats.

Step 3: Layer it onto the full UniProt viewer

Section titled “Step 3: Layer it onto the full UniProt viewer”

A standalone track is a viewer of its own. More often you want your track on top of everything UniProt already provides. Instead of rebuilding the default viewer, extends it: you inherit all its sources, groups, and themes, and declare only your addition.

The custom data can be simpler here — the default viewer supplies the rest:

type,start,end,description,score
DOMAIN,18,289,Custom re-annotation of the extracellular domain,0.9
BINDING,614,614,Lab-observed candidate binding residue,0.72
accession: P05067
extends: /src/default-config.yaml
rows:
- id: MY_LAB
label: My lab
tracks:
- id: hotspots
kind: features
data: ./hotspots.csv
description: Hotspot regions identified by our lab's pipeline, layered on top of the canonical UniProt viewer

That’s the whole config: the full canonical viewer, with a My lab group added at the end.

Finally, make it yours. There are two levers, no rebuild required.

No code: from the config. A theme: block recolours the viewer chrome directly, so an author who doesn’t write CSS can still brand the viewer. labelColor sets the row-label panel; the optional accentColor sets focus rings and the datatable’s active-row marker:

theme:
labelColor: '#e8f5e9'
accentColor: '#2e7d32'

From your page’s CSS. For full control, <protvista-uniprot> exposes --protvista-* design tokens and ::part hooks — set them in ordinary CSS on the page:

protvista-uniprot {
--protvista-color-accent: #7b2d8e;
--protvista-group-label-bg: #efe6f5;
}

Theme the viewer lists every token and the datatable ::part hooks.

You went from an empty page to a viewer that shows the full UniProt annotation for a protein, adds your own track from a CSV, and matches your site’s colours.

Where to go next:

Licensed under CC BY 4.0.