blob: 6c00be0c26ce9eb9b100058fb571aee4cf5c42eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
import NucleotideSelector from './nucleotide-selector.mjs'
class Nucleotide {
constructor(base) {
this.value = base
this._boundClickHandler = this.clickHandler.bind(this)
}
get elt() {
if (this._elt === undefined) {
this._elt = document.createElement('li')
this._elt.classList.add('nucleotide')
}
return this._elt
}
get valueElt() {
if (this._valueElt === undefined) {
this._valueElt = document.createElement('span')
this.elt.appendChild(this._valueElt)
}
return this._valueElt
}
get value() {
return this.valueElt.innerText
}
set value(val) {
this.valueElt.innerText = val
}
get onClick() {
if (this._onClick !== undefined) {
return this._onClick
}
return () => {}
}
set onClick(fn) {
this._onClick = fn
}
lock() {
this.elt.removeEventListener('click', this._boundClickHandler)
}
unlock() {
this.elt.addEventListener('click', this._boundClickHandler)
}
select() {
this._elt.classList.add('selected')
}
deselect() {
this._elt.classList.remove('selected')
}
clickHandler(evt) {
this.onClick(this)
}
}
Nucleotide.transition = {'A': 'G',
'C': 'T',
'G': 'A',
'T': 'C'}
Nucleotide.complementingTransversion = {'A': 'T',
'C': 'G',
'G': 'C',
'T': 'A'}
Nucleotide.defaultTransversion = {'A': 'C',
'C': 'A',
'G': 'T',
'T': 'G'}
Nucleotide.bases = Object.keys(Nucleotide.transition)
export default Nucleotide
|