summaryrefslogtreecommitdiffstats
path: root/codon.mjs
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2021-02-18 13:16:56 -0500
committerBrian Cully <bjc@kublai.com>2021-02-18 13:16:56 -0500
commit737b94c65bf275ce66df24f65dfbf418d4835902 (patch)
treedab07d0c85853e1a7228e08f9ff3e2e3f51f20ba /codon.mjs
parent4bff68dd9c421b843b5d0c8b52e40bfc5f01f147 (diff)
downloadmolsim2-737b94c65bf275ce66df24f65dfbf418d4835902.tar.gz
molsim2-737b94c65bf275ce66df24f65dfbf418d4835902.zip
Initial pass at getting codon display working.
Diffstat (limited to 'codon.mjs')
-rw-r--r--codon.mjs47
1 files changed, 47 insertions, 0 deletions
diff --git a/codon.mjs b/codon.mjs
new file mode 100644
index 0000000..7cc5ea1
--- /dev/null
+++ b/codon.mjs
@@ -0,0 +1,47 @@
+import AminoAcid from './amino-acid.mjs'
+import Nucleotide from './nucleotide.mjs'
+
+class Codon {
+ constructor(n1, n2, n3) {
+ this.bases = [n1, n2, n3]
+ this.aminoAcid = new AminoAcid(n1, n2, n3)
+
+ const nucleotideList = document.createElement('ol')
+ this.bases = [n1, n2, n3].map(base => {
+ const n = new Nucleotide(base)
+ n.onClick = this._boundNucleotideClickedHandler
+ nucleotideList.appendChild(n.elt)
+ return n
+ })
+ this.elt.appendChild(nucleotideList)
+ this.elt.appendChild(this.aminoAcid.elt)
+ }
+
+ get elt() {
+ if (this._elt === undefined) {
+ this._elt = document.createElement('li')
+ this._elt.classList.add('codon')
+ }
+ return this._elt
+ }
+
+ get aaElt() {
+ if (this._aaElt === undefined) {
+ this._aaElt = document.createElement('div')
+ this._aaElt.classList.add('amino-acid')
+ }
+ return this._aaElt
+ }
+
+ lock() {
+ this.bases.forEach(n => n.lock())
+ this.aminoAcid.lock()
+ }
+
+ unlock() {
+ this.bases.forEach(n => n.unlock())
+ this.aminoAcid.unlock()
+ }
+}
+
+export default Codon