Skip to content

SequenceViewer

DNA/RNA sequence display with annotations, translations, primers, cut sites, and interactive selection.

Demo

Usage

svelte
<script>
  import { SequenceViewer } from '@molbiohive/hatchlings';
</script>

<SequenceViewer data={seqData} width={700} height={500} />

Data Type — SequenceData

FieldTypeRequiredDescription
seqstringyesNucleotide sequence
partsPart[]yesFeatures and primers
cutSitesCutSite[]yesRestriction sites
translationsTranslation[]yesAmino acid translations
alphabetAlphabetno'dna' | 'rna' | 'protein'
topologystringno'linear' | 'circular'

Props

PropTypeDefaultDescription
dataSequenceDataPrimary data prop
widthnumber700Container width
heightnumber500Container height
charWidthnumber10Character pixel width
showAnnotationsbooleantrueShow feature annotations
showTranslationsbooleantrueShow amino acid translations
showNumbersbooleantrueShow position numbers
showComplementbooleantrueShow complement strand
colorBasesbooleanfalseColor bases by nucleotide
topologystring'linear'Sequence topology

Example — Constructing Data

ts
import type { SequenceData, Part, CutSite, Translation } from '@molbiohive/hatchlings';

// plasmidParts and plasmidCutSites are the same arrays used in PlasmidViewer
// (see the PlasmidViewer example for the full definitions)

const seqTranslations: Translation[] = [
  {
    start: 2533,
    end: 2686,
    strand: 1,
    aminoAcids: '...',  // translated from pUC19 sequence positions 2533–2686
    frame: 0,
  },
];

const sequenceData: SequenceData = {
  seq: 'ATGCGA...',  // 2686 bp pUC19 sequence (generated programmatically)
  parts: plasmidParts,
  cutSites: plasmidCutSites,
  translations: seqTranslations,
  topology: 'circular',
};

This is the data used in the demo above. See docs/data/plasmid.ts for the full source.

Primers with overhangs use bindingStart/bindingEnd to distinguish the binding region from the full oligo. See Data Interfaces for the complete Part definition.