<bmx-sequence-viewer>
A viewer for DNA, RNA and protein sequences, for research: plasmid maps, annotated sequences, restriction digests and alignments, opened in the page with nothing uploaded. Not for clinical use.
15 properties · 6 events · 15 methods · 4 parts
Example
Try it with your own files in confidence: they are opened by your browser, on your device. Nothing is uploaded, no copy reaches us or anyone else, and nothing is kept once you close this tab.
The sample is pBMX-demo, a made-up 4,600 bp cloning vector - not a real plasmid - with two genes, a T7 promoter, a multiple cloning site between M13 primer sites, and an origin. Choose a feature on the map or in the Features list; drag along the map to select; switch to Sequence for both strands and translations, or to Digest to cut it with the enzymes ticked (EcoRI, BamHI and HindIII to start). Find motifs with IUPAC letters, list open reading frames, add features and primers from a selection, and save GenBank, FASTA or the map as SVG. The alignment sample shows eight made-up isolates with consensus and conservation. For research use, not clinical.
Show markup
<bmx-sequence-viewer id="ex-seq" style="--bmx-sequence-viewer-height: 38rem"></bmx-sequence-viewer>
<p class="note">The sample is pBMX-demo, a made-up 4,600 bp cloning vector - not a real plasmid - with two genes, a T7 promoter, a multiple cloning site between M13 primer sites, and an origin. Choose a feature on the map or in the Features list; drag along the map to select; switch to Sequence for both strands and translations, or to Digest to cut it with the enzymes ticked (EcoRI, BamHI and HindIII to start). Find motifs with IUPAC letters, list open reading frames, add features and primers from a selection, and save GenBank, FASTA or the map as SVG. The alignment sample shows eight made-up isolates with consensus and conservation. For research use, not clinical.</p>
<div class="row" style="gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-block: 0.5rem 1.5rem">
<label>Open your own sequence <input type="file" id="ex-seq-file" accept=".gb,.gbk,.genbank,.ape,.embl,.fasta,.fa,.fna,.faa,.dna,.aln,.sto,.txt" /></label>
<button type="button" id="ex-seq-plasmid">Show the plasmid</button>
<button type="button" id="ex-seq-alignment">Show the alignment</button>
</div>
<p class="note" id="ex-seq-out" role="status"></p>
<script type="module">
await customElements.whenDefined('bmx-sequence-viewer');
const viewer = document.getElementById('ex-seq');
const out = document.getElementById('ex-seq-out');
viewer.addEventListener('bmxLoad', e => {
const { name, length, alphabet, topology, features, alignmentRows } = e.detail;
out.textContent = alignmentRows ? `An alignment of ${alignmentRows} sequences, ${length.toLocaleString()} columns.` : `${name}: ${length.toLocaleString()} ${alphabet === 'protein' ? 'aa' : 'bp'}, ${topology}, ${features} features.`;
});
viewer.addEventListener('bmxFeatureSelect', e => (out.textContent = e.detail ? `Chose ${e.detail.qualifiers.label?.[0] ?? e.detail.type}.` : ''));
viewer.addEventListener('bmxSelect', e => {
if (e.detail.length) out.textContent = `Selected ${e.detail.length.toLocaleString()} bp from ${(e.detail.start + 1).toLocaleString()}.`;
});
viewer.addEventListener('bmxSave', e => (out.textContent = `Saved ${e.detail.name}.`));
viewer.addEventListener('bmxError', e => (out.textContent = e.detail.message));
document.getElementById('ex-seq-file').addEventListener('change', e => {
if (e.target.files.length) viewer.open(e.target.files[0]);
});
document.getElementById('ex-seq-plasmid').addEventListener('click', () => viewer.loadSample('plasmid').then(() => (viewer.view = 'map')));
document.getElementById('ex-seq-alignment').addEventListener('click', () => viewer.loadSample('alignment'));
await viewer.loadSample('plasmid');
</script>
WHAT IT DOES
- Reads FASTA, GenBank, EMBL and SnapGene files (and ApE's, which are GenBank), several records to a file; alignments in Clustal, Stockholm and aligned FASTA; several unaligned sequences are aligned in the page.
- Circular (plasmid) and linear maps with features, restriction sites and open reading frames; the linear map zooms to any part.
- The sequence itself, with both strands, translations in three or six frames, features under it, cut positions, the selection and search hits; only the rows on screen are drawn, so a whole bacterial genome scrolls.
- Restriction sites of about ninety common enzymes (cutters once, twice or chosen), virtual digests on an agarose gel with ladders, and the fragments.
- Open reading frames on both strands with any NCBI genetic code; motif search with IUPAC letters and mismatches; the selection's length, GC, weight, melting temperature, translation and protein figures; features and primers added from the selection.
- Alignments with consensus, conservation, colour schemes and an identity table.
- Saves GenBank, FASTA and the map as SVG.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
compactBelow |
compact-below |
number |
760 |
Below this width (pixels) the panel goes under the view. |
complementStrand |
complement-strand |
boolean |
true |
Show the complementary strand under the sequence. |
enzymeSet |
enzyme-set |
BmxSequenceEnzymeSet |
'unique' |
Which enzymes' sites show. |
enzymes |
enzymes |
string[] | string |
[] |
Enzymes chosen (names, a list or comma-separated): shown with the "chosen" set, and used for digests. |
frames |
frames |
'none' | 'three' | 'six' |
'none' |
Translations under the sequence. |
geneticCode |
genetic-code |
number |
1 |
The NCBI genetic code for translations and ORFs. |
label |
label |
string |
— | The accessible name of the viewer. |
mapStyle |
map-style |
'auto' | 'circular' | 'linear' |
'auto' |
Circular or linear map ('auto': circular for circular molecules). |
minOrf |
min-orf |
number |
100 |
The shortest open reading frame, in codons (the stop included). |
noFiles |
no-files |
boolean |
false |
No opening of files (sequences come from src or the methods). |
readOnly |
read-only |
boolean |
false |
Look only: no adding or removing features. |
showOrfs |
show-orfs |
boolean |
false |
Show open reading frames on the map. |
src |
src |
string |
— | A file to open by address (FASTA, GenBank, EMBL, SnapGene, Clustal, Stockholm), or sample / sample:alignment. |
strings |
strings |
Partial<BmxSequenceViewerStrings> | string |
— | Replacements for any of the wording (an object, or its JSON). |
view |
view |
BmxSequenceView |
'map' |
What shows: the map, the sequence, a digest, or the alignment. |
Events
| Event | Detail | Description |
|---|---|---|
bmxChange |
{ readonly record: BmxSeqRecord; readonly change: "remove" | "add"; readonly feature: BmxSeqFeature; } |
Fired when features are added or removed. |
bmxError |
{ message: string; name?: string | undefined; } |
Fired when a file cannot be read. |
bmxFeatureSelect |
BmxSeqFeature | null |
Fired when a feature is chosen (or the choice cleared: null). |
bmxLoad |
BmxSequenceInfo |
Fired when a file has been read. |
bmxSave |
BmxSequenceSaveDetail |
Fired before a file is downloaded. Cancelable: cancel to keep the file yourself. |
bmxSelect |
BmxSequenceSelection & { readonly cursor: number; } |
Fired when the selection or cursor changes. |
Methods
| Method | Signature | Description |
|---|---|---|
addFeature |
addFeature(feature: { type?: string; start: number; end: number; strand?: 1 | -1; label?: string; qualifiers?: Record<string, string[]>; }) => Promise<string | null> |
Add a feature (not in read-only). Returns its id. |
download |
download(kind?: "genbank" | "fasta" | "svg" | "alignment") => Promise<void> |
Download GenBank, FASTA, the map as SVG, or the alignment as FASTA (unless bmxSave is cancelled). |
exportFasta |
exportFasta(selectionOnly?: boolean) => Promise<string> |
The record (or only the selection) as FASTA; with an alignment open, the alignment. |
exportGenBank |
exportGenBank() => Promise<string> |
The record as GenBank. |
exportSvg |
exportSvg() => Promise<string> |
The map as SVG (circular or linear as shown). |
find |
find(motif: string, mismatches?: number) => Promise<BmxSeqMotifHit[]> |
Find a motif (IUPAC letters on DNA, X on proteins) on both strands; returns the hits. |
getAlignment |
getAlignment() => Promise<BmxSeqAlignment | null> |
The open alignment (rows), if any. |
getInfo |
getInfo() => Promise<BmxSequenceInfo | null> |
What is open. |
getRecord |
getRecord() => Promise<BmxSeqRecord | null> |
The open record (a copy). |
getSelection |
getSelection() => Promise<BmxSequenceSelection & { readonly cursor: number; readonly sequence: string; }> |
The selection. |
loadSample |
loadSample(kind?: "plasmid" | "alignment") => Promise<BmxSequenceInfo | null> |
Open a built-in sample: a made-up plasmid ('plasmid') or a made-up alignment ('alignment'). |
open |
open(file: Blob | string | Partial<BmxSeqRecord>, name?: string) => Promise<BmxSequenceInfo | null> |
Open a file (File or Blob), its text, or a record object. |
removeFeature |
removeFeature(id: string) => Promise<boolean> |
Remove a feature by id (not in read-only). |
select |
select(start: number, end: number) => Promise<void> |
Select a range (zero-based, end not included; end < start crosses the origin of a circle). |
selectFeature |
selectFeature(id: string | null) => Promise<void> |
Choose a feature by id (null clears), selecting its range. |
CSS shadow parts
| Part | Description |
|---|---|
panel |
The side panel. |
status |
The status line. |
toolbar |
The toolbar. |
view |
The map, sequence, digest or alignment. |
CSS custom properties
| Property | Description |
|---|---|
--bmx-sequence-viewer-font |
The sequence's monospace font. |
--bmx-sequence-viewer-height |
The viewer's height. |
--bmx-sequence-viewer-hit |
Search hits' colour. |
--bmx-sequence-viewer-ident |
The identity table's colour. |
--bmx-sequence-viewer-panel-width |
The side panel's width. |
--bmx-sequence-viewer-radius |
The frame's corner radius. |
--bmx-sequence-viewer-selection |
The selection's colour. |
--bmx-sequence-viewer-site |
Restriction sites' colour. |