Class: Sequence

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 - -

Attributes

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

Examples

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

Extends

Members

canvasCanvas

Get the canvas.

colorColor

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.

fontFont

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.

hasMultipleContigsBoolean

Return true if the sequence consists of muliple contigs.

hasSeqBoolean

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

layoutLayout

Get the layout.

lengthNumber

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

mapContigContig

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).

metaBoolean

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

seqString

Get or set the seqeunce.

sequenceSequence

Get the sequence.

viewerViewer

Get the viewer.

visibleBoolean

Get or Set the visibility of this object.

Methods

staticSequence.complement(){String}

Return the Complement the sequence

Returns:
Type Description
String
  • 'Sequence'

staticSequence.random(length){String}

Create a random sequence of the specified length

Name Type Description
length Number

The length of the sequence to create

Returns:
Type Description
String

addContigs(data){CGArray.<Contig>}

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

Returns:
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.

Returns:
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

Returns:
Type Description
String

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)

removeContigs(contigs)

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

toJSON()

Returns JSON representing the object

toString(){String}

Return the class name as a string.

Returns:
Type Description
String
  • 'Sequence'

update(attributes)

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