3.10.7 • Published 1 month ago

seqviz v3.10.7

Weekly downloads
84
License
MIT
Repository
github
Last release
1 month ago

SeqViz is a DNA, RNA, and protein sequence viewer.

Used By

Table of Contents

Demo

You can see a demo at tools.latticeautomation.com/seqviz. The source is in /demo.

Features

Linear and Circular Sequence Viewers

  • Annotations, primers, and highlights with names and colors
  • Amino acid translations
  • Enzyme cut sites
  • Searching with mismatches and highlighting

Sequence and Element Selection

  • Selecting a range on the viewer(s), or clicking an annotation, translation, primer, cutSite, or searchResult, highlights the selection and passes it to the onSelection() callback.

Usage

Installation

npm

npm install seqviz

CDN

<script src="https://unpkg.com/seqviz"></script>

Instantiation

React

import { SeqViz } from "seqviz";

export default () => (
  <SeqViz
    name="J23100"
    seq="TTGACGGCTAGCTCAGTCCTAGGTACAGTGCTAGC"
    annotations={[{ name: "promoter", start: 0, end: 34, direction: 1, color: "blue" }]}
  />
);

Non-React

More details are in the Viewer without React section.

<script>
  window.seqviz
    .Viewer("root", {
      name: "L09136",
      seq: "tcgcgcgtttcggtgatgacggtgaaaacctctgacacatgca",
      style: { height: "100vh", width: "100vw" },
    })
    .render();
</script>

Props

All the following are usable as props for the React component (seqviz.SeqViz) or as options for the plain JS implementation (seqviz.Viewer()).

Required

seq (='')

A sequence to render. Can be a DNA, RNA, or amino acid sequence.

File or Accession

These props are @deprecated and may be removed in a future major release. We recommend parsing sequence files outside of SeqViz with the seqparse package.

  • file is a FASTA, GenBank, SnapGene, JBEI, or SBOL file (string | File)
  • accession is an NCBI accession-ID (string)

For example:

import seqparse from "seqparse";

export default () => {
  const [seq, setSeq] = useState({ name: "", seq: "", annotations: [] });

  // fetch and parse a sequence from NCBI: https://www.ncbi.nlm.nih.gov/nuccore/MN623123.1
  useEffect(async () => setSeq(await seqparse("MN623123.1")));

  return <SeqViz name={seq.name} seq={seq.seq} annotations={seq.annotations} />;
};

Optional

viewer (='both')

The type and orientation of the sequence viewers. One of "linear" | "circular" | "both" | "both_flip". both means the circular viewer fills the left side of SeqViz, and the linear viewer fills the right. both_flip is the opposite: the linear viewer is on the left, and the circular viewer is on the right.

name (='')

The name of the sequence/plasmid. Shown at the center of the circular viewer.

annotations (=[])

An array of Annotations to render. Each Annotation requires 0-based start (inclusive) and end (exclusive) indexes. names are rendered on top of the annotations. Set the annotation's direction to 1 for forward arrows and -1 for reverse arrows.

annotations = [
  { start: 0, end: 22, name: "Strong promoter", direction: 1 }, // [0, 22)
  { start: 23, end: 273, name: "GFP" },
  { start: 300, end: 325, name: "Weak promoter", direction: -1, color: "#FAA887" },
];

In the example above, the "Strong promoter" would span the first to twenty-second base pair.

primers (=[])

An array of Primers to render. Each Primer requires 0-based start (inclusive) and end (exclusive) indexes. names are rendered on top of the primers. Set the primer's direction to 1 for forward primer and -1 for reverse primer.

primers = [
  { start: 33, end: 53, name: "LacZ Foward Primer", direction: 1 },
  { start: 3098, end: 3128, name: "LacZ Reverse Primer", direction: -1, color: "#FAA887" },
];

In the example above, the forward and reverse primers of LacZ are define by the direction parameter. Notice that color could be used optionally.

translations (=[])

An array of translations: sequence ranges to translate and render as amino acids sequences. Requires 0-based start (inclusive) and end (exclusive) indexes relative the DNA sequence. A direction is required: 1 (FWD) or -1 (REV). It will also render a handle to select the entire range. A color is optional for the handle. If the empry string ("") is provided as the name, the handle will not be rendered.

translations = [
  { start: 0, end: 90, direction: 1, name: "ORF 1", color: "#FAA887" }, // [0, 90)
  { start: 191, end: 522, direction: -1, name: "" },
];

enzymes (=[])

An array of restriction enzymes to show recognition sites for. A list of pre-defined enzymes in src/enzymes.ts can be referenced by name. Example:

enzymes = [
  "EcoRI",
  "PstI",
  {
    name: "Cas9",
    rseq: "NGG", // recognition sequence
    fcut: 0, // cut index on FWD strand, relative to start of rseq
    rcut: 1, // cut index on REV strand, relative to start of rseq
    color: "#D7E5F0", // color to highlight recognition site with
    // (optional) only show recognition sites between 100th and 250th index [100, 250)
    range: {
      start: 100,
      end: 250,
    },
  },
];

highlights (=[])

Ranges of sequence to highlight. A default color from colors is used if none is provided.

highlights = [
  { start: 36, end: 66, color: "magenta" },
  { start: 70, end: 80 },
];

zoom (={ linear: 50 })

How zoomed the viewer(s) should be 0-100. Key'ed by viewer type, but only linear is supported.

colors (=[])

An array of colors to use for annotations, translations, and highlights. Defaults are in src/colors.ts.

bpColors (={})

An object mapping base pairs to their color. The key/bp is either a nucleotide type or 0-based index. Example:

bpColors = { A: "#FF0000", T: "blue", 12: "#00FFFF" };

style (={})

Style for seqviz's outer container div. Empty by default. Useful for setting the height and width of the viewer if the element around seqviz lacks one. For example:

style = { height: "100vh", width: "100vw" };

selection (={})

This (optional) selection prop is useful if you want to externally manage and set the selection state:

selection = {
  start: 133,
  end: 457,
  clockwise: true,
};

onSelection (=(_: Selection) => {})

A callback executed after selection events. It accepts a single Selection type argument.

This occurs after drag/drop selections and clicks. It will have meta on annotation, translation, enzyme, highlight or search elements if one was selected. The example below shows an annotation selection:

{
  "end": 457,
  "length": 324,
  "name": "lacZ fragment",
  "start": 133,
  "type": "ANNOTATION",
}

search (={})

Sequence search parameters. Takes a query sequence and the maximum allowable mismatch for a match (default: 0). Matches are highlighted.

search = { query: "aatggtctc", mismatch: 1 };

Searching supports wildcard symbols, e.g. { query: "AANAA" }. All symbols supported are in src/sequence.ts.

onSearch (=(_: Range) => {})

A callback executed after a search event. This is called once on initial render and every time the sequence changes thereafter. An example of search results is below:

[
  {
    start: 728,
    end: 733,
    direction: 1,
    index: 0,
  },
  {
    start: 1788,
    end: 1793,
    direction: -1,
    index: 1,
  },
];

copyEvent (=(e: KeyboardEvent) => e.key === "c" && (e.metaKey || e.ctrlKey))

A function returning whether to copy the viewer(s) current selection during a keyboard event. The default method copies sequence after any ctrl+c or meta+c keyboard events.

selectAllEvent (=(e: KeyboardEvent) => e.key === "a" && (e.metaKey || e.ctrlKey))

A function returning whether to select the whole sequence during a keyboard event. The default method select whole sequence after any ctrl+a or meta+a keyboard events.

showComplement (=true)

Whether to show the complement sequence.

rotateOnScroll (=true)

By default, the circular viewer rotates when scrolling over the viewer. That can be disabled with rotateOnScroll: false.

disableExternalFonts (=false)

If true, SeqViz will not download fonts from external sites. By default the library will attempt to download "Roboto Mono:300,400,500" after first mount.

refs (={ circular: undefined, linear: undefined })

See: custom viewer positioning

Custom Viewer Positioning

This makes use of the children and refs props to allow custom rendering of the sequence viewers. For example, to render the linear viewer above the circular viewer:

import { useRef } from "react";
import { Circular, Linear, SeqViz } from "seqviz";

export default () => {
  const circular = useRef();
  const linearRef = useRef();

  return (
    <SeqViz name="J23100" seq="TTGACGGCTAGCTCAGTCCTAGGTACAGTGCTAGC" refs={{ circular, linear }}>
      {({ circularProps, linearProps, ...props }) => (
        <div style={{ display: "flex", flexDirection: "column", width: "100%" }}>
          <div ref={linear} style={{ height: "25%", width: "100%" }}>
            <Linear {...linearProps} {...props} />
          </div>
          <div ref={circular} style={{ height: "75%", width: "100%" }}>
            <Circular {...circularProps} {...props} />
          </div>
        </div>
      )}
    </SeqViz>
  );
};

Without React

For usability in non-React apps, we provide a thin wrapper around the React component. The viewer's constructor accepts two arguments:

const element = document.getElementById("root");
const viewer = seqviz.Viewer(element, props);
// Render the viewer to the DOM at the node passed in $element`.
viewer.render();
// To later update the viewer's configuration and re-renders.
viewer.setState(props);
// To render the viewer, eg for server-side rendering, and returns it as an HTML string.
viewer.renderToString();

Contact Us

This library is maintained by Lattice Automation.

You can report bugs and request features at Issues or contact us directly at contact@latticeautomation.com

3.10.7

1 month ago

3.10.5

3 months ago

3.10.6

3 months ago

3.10.4

4 months ago

3.10.3

4 months ago

3.9.2

7 months ago

3.10.1

5 months ago

3.10.0

6 months ago

3.8.10

11 months ago

3.8.11

11 months ago

3.9.1

8 months ago

3.9.0

9 months ago

3.8.8

11 months ago

3.8.7

11 months ago

3.7.9

1 year ago

3.7.8

1 year ago

3.7.7

1 year ago

3.7.13

1 year ago

3.7.11

1 year ago

3.7.12

1 year ago

3.7.10

1 year ago

3.8.0

1 year ago

3.8.3

1 year ago

3.8.2

1 year ago

3.8.1

1 year ago

3.8.6

1 year ago

3.7.5

1 year ago

3.7.4

1 year ago

3.7.3

1 year ago

3.7.2

1 year ago

3.7.6

1 year ago

3.6.2

1 year ago

3.6.0

2 years ago

3.5.29

2 years ago

3.5.28

2 years ago

3.5.27

2 years ago

3.5.26

2 years ago

3.6.3

1 year ago

3.5.30

2 years ago

3.7.1

1 year ago

3.7.0

1 year ago

3.5.14

2 years ago

3.5.13

2 years ago

3.5.12

2 years ago

3.5.11

2 years ago

3.5.10

2 years ago

3.5.19

2 years ago

3.5.18

2 years ago

3.5.17

2 years ago

3.5.16

2 years ago

3.5.15

2 years ago

3.5.25

2 years ago

3.5.24

2 years ago

3.5.22

2 years ago

3.5.21

2 years ago

3.5.20

2 years ago

3.5.9

2 years ago

3.5.7

2 years ago

3.3.9

2 years ago

3.5.6

2 years ago

3.3.8

2 years ago

3.5.5

2 years ago

3.3.7

2 years ago

3.5.4

2 years ago

3.3.6

2 years ago

3.5.8

2 years ago

3.4.0

2 years ago

3.4.2

2 years ago

3.4.1

2 years ago

3.3.14

2 years ago

3.3.15

2 years ago

3.3.16

2 years ago

3.3.1

2 years ago

3.5.3

2 years ago

3.3.5

2 years ago

3.5.2

2 years ago

3.3.4

2 years ago

3.5.1

2 years ago

3.5.0

2 years ago

3.3.2

2 years ago

3.2.0

2 years ago

3.3.0

2 years ago

3.1.0

2 years ago

3.0.45

2 years ago

3.0.46

2 years ago

3.0.49

2 years ago

3.0.47

2 years ago

3.0.48

2 years ago

3.0.50

2 years ago

3.0.44

3 years ago

3.0.43

3 years ago

3.0.41

3 years ago

3.0.42

3 years ago

3.0.40

3 years ago

3.0.39

3 years ago

3.0.38

3 years ago

3.0.36

3 years ago

3.0.37

3 years ago

3.0.34

3 years ago

3.0.35

3 years ago

3.0.32

3 years ago

3.0.33

3 years ago

3.0.31

3 years ago

3.0.30

3 years ago

3.0.29

3 years ago

3.0.28

3 years ago

3.0.27

3 years ago

3.0.24

3 years ago

3.0.25

3 years ago

3.0.26

3 years ago

3.0.23

4 years ago

3.0.22

4 years ago

3.0.21

4 years ago

3.0.20

4 years ago

3.0.19

4 years ago

3.0.18

4 years ago

3.0.17

4 years ago

3.0.16

4 years ago

3.0.15

4 years ago

3.0.14

4 years ago

3.0.13

4 years ago

3.0.12

4 years ago

3.0.11

4 years ago

3.0.10

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

1.0.24

4 years ago

2.0.0

4 years ago

1.0.23

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.3

4 years ago