Class: Sequence


The CGView Sequence represents the sequence that makes up the map.

Sequence Length

The essential proptery of the Sequence is the length. The length must be known in order to draw a map of the correct size. There are 3 ways to set the Sequence length on map creation.

  • seq: provide the sequence. The length will be set directly from the sequence.
  • length: provide the sequence length without sequence
  • contigs: an array of contigs. Each contig must then include its length or sequence.

The seq and length propteries are read only and cannot be changed unless a new map is loaded (see IO.loadJSON. With contigs, the updateContigs and moveContigs methods can be used to change the name, orienation, visbility and order, however, the seq and length property of each contig is still read only.

Sequence Coordinates:

CGView uses two coordinate systems: Contig space and map space. For features and plot, positions are relative to contigs. However, when drawing we use positions relative to the entire map.

Action and Events

Action Viewer Method Sequence Method Event
Update - update() sequence-update
Read sequence - -


Attribute Type Description
name String Sequence name. [TODO]
seqiu String The map sequence.
lengthiu Number The length of the sequence. This is ignored if a seq is provided. [Default: 1000]
contigsiu Array Array of contigs. Contigs are ignored if a seq is provided.
font String A string describing the font [Default: 'SansSerif, plain, 14']. See Font for details.
color String A string describing the sequence color [Default: 'black']. See Color for details.
visible Boolean Sequence sequence is visible when zoomed in enough [Default: true]
meta Object Meta data

iu Ignored on Sequence update


new Sequence(viewer, options, meta)

Create a Sequence

Name Type Description
viewer Viewer

The viewer

options Object

Attributes used to create the sequence

meta Object optional

User-defined Meta data to add to the sequence




Get the canvas.


Get or set the backbone color. When setting the color, a string representing the color or a Color object can be used. For details see Color.


Get or set sequence font. When setting the font, a string representing the font or a Font object can be used. For details see Font.


Return true if the sequence consists of muliple contigs.


Return true of a sequence is available. Returns false if there is only a length.


Get the layout.


Get or set the seqeunce length. If the seq property is set, the length can not be adjusted.


This is used internally to represent the entire map sequence. It is generated by the supplied seq or the concatenation of all the contigs. The Sequence.seq (or length) is the same as Sequence.mapContig.seq (or length).


Get or Set the meta data of this object. See the meta data tutorial for details.


Get or set the seqeunce.


Get the sequence.


Get the viewer.


Get or Set the visibility of this object.



Return the Complement the sequence

Type Description
  • 'Sequence'


Create a random sequence of the specified length

Name Type Description
length Number

The length of the sequence to create

Type Description


Add one or more contigs (see attributes). See adding records for details.

Name Type Description
data Object | Array

Object or array of objects describing the contigs

Type Description
CGArray.<Contig> CGArray of added contigs

asFasta(id, options)

Create FASTA string for the sequence.

Name Type Description
id String

ID line for FASTA (i.e. text after '>'). Only used if there is one contig or concatenateContigs is true.

options Object

Options: concatenateContigs

Returns a CGArray of contigs or a single contig. See reading records for details.

Name Type Description
term Integer | String | Array

See CGArray.get for details.

Type Description
Contig | CGArray

inherited deleteFromObjects()

Remove the object from Viewer.objects

forRange(range, revComp){String}

Return the sequence for the range

Name Type Description
range Range

the range for which to return the sequence

revComp Boolean

If true return the reverse complement sequence

Type Description

moveContig(oldIndex, newIndex)

Move a contig from one index to a new one

Name Type Description
oldIndex Number

Index of contig to move (0-based)

newIndex Number

New index for the contig (0-based)


Remove contigs. See removing records for details. Notes:

  • Removing contigs, will remove the features associated with the contig
  • This will only work with contigs in Sequence.contigs(). It will not remove the mapContig.
  • Will not remove last contig. If removing all contigs, the last contig will not be removed.
Name Type Description
contigs Contig | Array

Contig or a array of contigs to remove


Returns JSON representing the object


Return the class name as a string.

Type Description
  • 'Sequence'


Update sequence attributes. See updating records for details.

Name Type Description
attributes Object

Object describing the properties to change

updateContigs(contigsOrUpdates, attributes)

Update attributes for one or more contigs. See updating records for details.

Name Type Description
contigsOrUpdates Contig | Array | Object

Contig, array of contigs or object describing updates

attributes Object

Object describing the properties to change