-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHTML_box_code.html
1285 lines (1043 loc) · 32.3 KB
/
HTML_box_code.html
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<style>
/***************/
/* General Stuff */
/***************/
html {
background-color: #e6e9e9;
}
body {
margin: 0 auto;
padding: 2em 2em 4em;
width: 800px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 1.5em;
color: #545454;
background-color: #ffffff;
margin-top: 50px;
margin-bottom: 50px;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.06);
height: auto;
}
h1, h2, h3, h4, h5, h6 {
color: #222;
font-weight: 600;
}
h2 {
text-align: center;
text-decoration: underline;
}
a {
color: #0083e8;
}
b, strong {
font-weight: 600;
}
#pageTitle h1 {
text-align: center;
position: relative;
top: -20px;
margin-bottom: 10px;
padding-bottom: 10px;
}
/*******************/
/* Utility Classes */
/*******************/
#div-column-one textarea,
#div-column-one input[type="text"] {
opacity: 0.7;
}
[data-edited] {
opacity: 1.0;
}
.nowrap {
white-space: nowrap;
}
.inline {
display: inline-block;
}
.clearfix {
overflow: auto;
}
.indent1 {
margin-left: 30px;
}
.indent2 {
margin-left: 60px;
}
/****************/
/* Both Columns */
/****************/
#div-columns {
position: relative;
}
label, input {
display: block;
}
label {
margin-bottom: 6px;
}
/* input text fields can be size-formatted with font-size and padding */
input[type=text] {
border: 2px solid #7facaa;
font-size: 14px;
padding: 7px;
}
/* textAreas can be size-formatted with width/height */
textarea {
width: 300px;
height: 60px;
padding: 7px;
border: 2px solid #7facaa;
font-size: 14px;
resize: none;
}
.div-column {
float: left;
width: 400;
margin-top: 50px;
}
#div-column-one h2,
#div-column-two h2 {
position: relative;
top: -20px;
}
/************/
/* Column 1 */
/************/
#div-column-one {
margin-left: 20px;
padding-right: 55px;
border-right-style: solid;
border-right-width: 5px;
border-right-color: #7facaa;
}
#primer-submit {
width: 250px;
height: 60px;
font-size: 30px;
background: #7facaa;
text-align: center;
border: none;
border-radius: 4px;
color: #FFF;
border: solid 2px #754444;
}
#primer-submit:hover {
background: #754444;
border: solid 2px #7facaa;
text-decoration: none;
cursor: pointer;
}
/************/
/* Column 2 */
/************/
#div-column-two {
margin-left: 60px;
}
#primerConc, #saltConc,
#primerLength, #gcContent {
width: 40px;
}
#primerLength, #gcContent {
display: inline;
}
/******************/
/* Tm Table Stuff */
/******************/
#table-tm {
border-radius: 4px;
border: 2px solid #7facaa;
border-collapse: collapse;
}
#table-tm td,
#table-tm th {
padding-right: 30px;
padding-left: 30px;
border: 1px solid #7facaa;
}
/*#table-tm td:first-child,
#table-tm th:first-child {
padding-right: 50px;
}*/
#table-tm td:first-child {
text-align: right;
}
#table-tm th {
text-align: center;
}
/*#table-tm td:last-child,
#table-tm th:last-child {
padding-left: 30px;
}*/
/********************/
/* Show-Explanation */
/********************/
#div-show-explanation {
clear: left;
position: relative;
margin-top: 100px;
margin-left: 275px;
}
#button-show-explanation {
width: 250px;
height: 50px;
font-size: 16px;
background: #7facaa;
text-align: center;
border: none;
border-radius: 4px;
color: #FFF;
border: solid 2px #754444;
}
#button-show-explanation:hover {
background: #754444;
border: solid 2px #7facaa;
text-decoration: none;
cursor: pointer;
}
#noEdit {
position: relative;
left: -80px;
}
/***************/
/* Explanation */
/***************/
#div-explanation {
clear: left;
position: relative;
margin-top: 100px;
color: #000000;
}
#explanationTitle {
text-align: center;
}
img.tex {
display: block;
margin: 5px auto;
border: none !important;
box-shadow: 0 0 0 !important;
background-color: transparent !important;
}
#div-explanation p {
font-size: 13px;
line-height: 13px;
}
/************/
/* Extra */
/************/
.hidden {
display: none;
}
/*input[type=checkbox], label[for=whichApprox] {
display: inline;
}
input[type=radio] {
display: inline;
margin-bottom: 10px;
}
img {
background: transparent;
border: 10px solid rgba(0, 0, 0, 0.12);
border-radius: 4px;
display: block;
margin: 1.3em auto;
max-width: 95%;
}
input[type="radio"] + label {
display: inline-block;
width: 100px;
font-size: 14px;
margin: -1px 4px 0 0;
vertical-align: middle;
cursor: pointer;
}*/
</style>
<script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</head>
<body>
<div id="pageTitle">
<h1>Melting Temperature Calculator</h1>
</div>
<div id="div-columns" class="clearfix">
<div id="div-column-one" class="div-column">
<form id="form-sequence-input">
<h2>Inputs</h2>
<label>Primer Sequence (5' --> 3')</label>
<textarea id="primer-sequence" type="text" data-default="e.g. ATCGTCTA...">
</textarea>
<br><br>
<label for="primerConc">Primer Concentration [nM]</label>
<input type="text" id="primerConc" data-default="50">
<br><br>
<label for="saltConc">Salt Concentration [mM]</label>
<input type="text" id="saltConc" data-default="50">
<br><br>
<input type="submit" id="primer-submit" value="Click to Submit" />
</form>
</div>
<div id="div-column-two" class="div-column hidden">
<h2>Outputs</h2>
<div id="first-output" class="nowrap">
<label for="primerLength" class="inline">Primer Length: </label>
<input type="text" id="primerLength" readonly>
</div>
<br>
<div class="nowrap">
<label for="gcContent" class="inline">GC Content: </label>
<input type="text" id="gcContent" readonly>
</div>
<br>
<div id="div-reverse-complement">
<label>Primer Reverse Complement</label>
<textarea id="reverse-complement-field" type="text" readonly>
</textarea>
</div>
<br><br>
<div id="div-tmTable">
<label>Melting Temperature Results</label>
<table id="table-tm">
<thead>
<tr>
<th>T<sub>M</sub></th>
<th>Method</th>
</tr>
</thead>
<tbody>
<tr>
<td id="table-tm-basic">5 °C</td>
<td class="second">Basic</td>
</tr>
<tr>
<td id="table-tm-salt">10 °C</td>
<td class="second">Salt-Adjusted</td>
</tr>
<tr>
<td id="table-tm-nn">15 °C</td>
<td class="second">Nearest Neighbor</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="div-show-explanation" class="hidden">
<button id="button-show-explanation">Show Explanation of Outputs</button>
<label id="noEdit">(you won't be able to edit your "Inputs" after clicking this!)</label>
</div>
<div id="div-explanation" class="hidden">
<h2 id="#explanationTitle">Explanation of Results</h2>
<section id="intro-explanation">
<p>So how did we get those melting temperatures? Glad you asked! We used three separate methods to get three
different approximations for the melting temperature. The Basic method is the least accurate, the Salt-Adjusted
method is more accurate than Basic, and the Nearest-Neighbor method is the most accurate. The text below walks you
through the math we did to get to our answers.</p>
</section>
<br>
<section id="basic-explanation">
<h3>Explanation of the "Basic" approximation method: </h3>
<div class="indent1">
<p>The "Basic" melting temperature approximation method is based solely off of the GC content and length of the strand. The idea here is that longer strands bind more strongly to each other, and that GC pairs bind more strongly to each other than AT pairs.</p>
</div>
<p class="indent1">For strands with fewer than 14 base pairs, the melting temperature is calculated using a simple rule of thumb expressed
by the following equation:</p>
<div class="indent2">
<p> $T_{M} (^{\circ}C) = 2*(N_{A}+N_{T}) + 4*(N_{C} + N_{G})$</p>
<p> Where $T_{M}$ is the melting temperature in degrees Celsius and
N<sub>X</sub> is the number of X's in the primer (e.g. $N_{A}$ = # of A's in the primer)</p>
</div>
<p class="indent1">For strands with lengths greater than or equal to 14, the melting temperature is calculated using the formula below:</p>
<div class="indent2">
<p> $T_{M} = 64.9 + 41*\frac{N_{G} + N_{C}}{L_{primer}} - \frac{672}{L_{primer}}$</p>
<p> Where $T_{M}$ is the melting temperature in degrees Celsius,
N<sub>X</sub> is the number of X's in the primer (e.g. $N_{A}$ = # of A's in the primer), and $L_{primer}$ is the
length of the primer.</p>
</div >
<p class="indent1"> For the primer you entered:</p>
<div class="indent2">
<p id="N_A">N<sub>A</sub> = </p>
<p id="N_T">N<sub>T</sub> = </p>
<p id="N_C">N<sub>C</sub> = </p>
<p id="N_G">N<sub>G</sub> = </p>
<p id="L_primer">$L_{primer} = $</p>
</div>
<p class="indent1"> Therefore, the melting temperature was calculated as follows:</p>
<div class="indent2">
<p id="equationBasic">f</p>
<p id="equationBasicPlug">f</p>
<p id="equationBasicAnswer">f</p>
</div>
</section>
<br><br>
<section id="salt-explanation">
<h3>Explanation of the "Salt-Adjusted" approximation method: </h3>
<div class="indent1">
<p>The "Salt-Adjusted" melting temperature approximation method is basically just the basic method with a salt correction.
That is, to do this method, all we really do is take our answer from the Basic method and add a "salt correction term".
The idea here is that the presence of salt (like sodium (element Na)) makes the bonds between DNA stronger, raising the
melting temperature.</p>
</div>
<p class="indent1">For strands with fewer than 14 base pairs, the melting temperature is calculated using the following equation:</p>
<div class="indent2">
<p> $T_{M} (^{\circ}C) = 2*(N_{A}+N_{T}) + 4*(N_{C} + N_{G}) + 16.6*\log_{10}([Na^{+}]/0.05)$</p>
<p> Where $T_{M}$ is the melting temperature in degrees Celsius,
N<sub>X</sub> is the number of X's in the primer (e.g. $N_{A}$ = # of A's in the primer), and
$[Na^{+}]$ is the concentration of salt in moles/Liter.</p>
</div>
<p class="indent1">For strands with lengths greater than or equal to 14, the melting temperature is calculated using the formula below:</p>
<div class="indent2">
<p> $T_{M} = 100.5 + 41*\frac{N_{G} + N_{C}}{L_{primer}} - \frac{820}{L_{primer}} + 16.6*\log_{10}([Na^{+}])$ </p>
<p> Where $T_{M}$ is the melting temperature in degrees Celsius,
N<sub>X</sub> is the number of X's in the primer (e.g. $N_{A}$ = # of A's in the primer),
$L_{primer}$ is the length of the primer, and
$[Na^{+}]$ is the concentration of salt in moles/Liter</p>
</div>
<p class="indent1"> For the primer you entered:</p>
<div class="indent2">
<p id="N_ASalt">N<sub>A</sub> = </p>
<p id="N_TSalt">N<sub>T</sub> = </p>
<p id="N_CSalt">N<sub>C</sub> = </p>
<p id="N_GSalt">N<sub>G</sub> = </p>
<p id="L_primerSalt">$L_{primer} = $</p>
<p id="saltConcSalt">salt</p>
</div>
<p class="indent1"> Therefore, the melting temperature was calculated as follows:</p>
<div class="indent2">
<p id="equationSalt">f</p>
<p id="equationSaltPlug">f</p>
<p id="equationSaltAnswer">f</p>
</div>
</section>
<br><br>
<section id="nearest-explanation">
<h3>Explanation of the "Nearest-Neighbor" approximation method: </h3>
<div class="indent1">
<p>The "Nearest-Neighbor" melting temperature approximation method is different than the Basic and Salt-Adjusted methods.
Unlike those methods, the Nearest-Neighbor model takes into account complex thermodynamics resulting from DNA stacking
and hydrogen bonds. Additionally, this model takes into account the concentration of your primer in solution as well as
the concentration of salt in the solution. The Nearest-Neighbor model is the most theoretically accurate of the three, and
is often used by scientists that want to optimize their PCR experiments.</p>
</div>
<p class="indent1">The governing equation for the Nearest-Neighbor model is as follows:</p>
<div class="indent2">
<p> $T_{M} (^{\circ}C) = \frac{\Delta H-3400}{\Delta S + R*\log_{10}(C_{primer}/4)} + 16.6*\log_{10}([Na^{+}]) - 273.15$</p>
<p> Where $T_{M}$ is the melting temperature in degrees Celsius,
$\Delta H$ is the enthalpy factor in cal/mole,
$\Delta S$ is the entropy factor in cal/mole,
R is the universal gas constant in cal/mole/Liter,
$C_{primer}$ is the primer concentration in moles/Liter, and
$[Na^{+}]$ is the concentration of salt (sodium) in the solution.</p>
</div>
<p class="indent1"> For the primer you entered:</p>
<div class="indent2">
<p id="dhNearest">f</p>
<p id="dsNearest">f</p>
<p id="RNearest">f</p>
<p id="primerConcNearest">f</p>
<p id="saltConcNearest">f</p>
</div>
<p class="indent1"> Therefore, the melting temperature was calculated as follows:</p>
<div class="indent2">
<p id="equationNearest">f</p>
<p id="equationNearestPlug">f</p>
<p id="equationNearestAnswer">f</p>
</div>
</section>
</div>
</body>
</html>
<script>var lineBreak = $("<br>");
var bases = ["A", "T", "C", "G"];
var basicTM = 0;
var saltTM = 0;
var nearestTM = 0;
var pSeq = "";
var final_dH = 0;
var final_dS = 0;
var R = 1.987;
var unifiedDH = {
AA_TT: -7.9,
AT_TA: -7.2,
TA_AT: -7.2,
CA_GT: -8.5,
GT_CA: -8.4,
CT_GA: -7.8,
GA_CT: -8.2,
CG_GC: -10.6,
GC_CG: -9.8,
GG_CC: -8.0,
TC_AG: -8.2,
AC_TG: -8.4,
TG_AC: -8.5,
AG_TC: -7.8,
TT_AA: -7.9,
CC_GG: -8.0
};
var unifiedDS = {
AA_TT: -22.2,
AT_TA: -20.4,
TA_AT: -21.3,
CA_GT: -22.7,
GT_CA: -22.4,
CT_GA: -21.0,
GA_CT: -22.2,
CG_GC: -27.2,
GC_CG: -24.4,
GG_CC: -19.9,
TC_AG: -22.2,
AC_TG: -22.4,
TG_AC: -22.7,
AG_TC: -21.0,
TT_AA: -22.2,
CC_GG: -19.9
};
var unifiedDG= {
AA_TT: -1.00,
AT_TA: -0.88,
TA_AT: -0.58,
CA_GT: -1.45,
GT_CA: -1.44,
CT_GA: -1.28,
GA_CT: -1.30,
CG_GC: -2.17,
GC_CG: -2.24,
GG_CC: -1.84,
TC_AG: -1.30,
AC_TG: -1.44,
TG_AC: -1.45,
AG_TC: -1.28,
TT_AA: -1.00,
CC_GG: -1.84
};
var initEnergies = {
term_GC_H: 0.1,
term_GC_S: -2.8/1000.0,
term_GC_G: 0.98,
term_AT_H: 2.3,
term_AT_S: 4.1/1000.0,
term_AT_G: 1.03
};
var pairCombos = [
"AA",
"TT",
"GG",
"CC",
"AT",
"AC",
"AG",
"TA",
"TC",
"TG",
"GA",
"GC",
"GT",
"CA",
"CG",
"CT"
];
var opposites = {
A: "T",
T: "A",
C: "G",
G: "C"
};
var revCompNN = {
AA: "TT",
AT: "AT",
TA: "TA",
CA: "TG",
GT: "AC",
CT: "AG",
GA: "TC",
CG: "CG",
GC: "GC",
GG: "CC",
TT: "AA",
TG: "CA",
AC: "GT",
AG: "CT",
TC: "GA",
CC: "GG",
};
var compNN = {
AA: "TT",
AT: "TA",
TA: "AT",
CA: "GT",
GT: "CA",
CT: "GA",
GA: "CT",
CG: "GC",
GC: "CG",
GG: "CC",
TT: "AA",
TG: "AC",
AC: "TG",
AG: "TC",
TC: "AG",
CC: "GG",
};
var blankNN = {
AA_TT: 0,
AT_TA: 0,
TA_AT: 0,
CA_GT: 0,
GT_CA: 0,
CT_GA: 0,
GA_CT: 0,
CG_GC: 0,
GC_CG: 0,
GG_CC: 0,
TC_AG: 0,
AC_TG: 0,
TG_AC: 0,
AG_TC: 0,
TT_AA: 0,
CC_GG: 0
};
/********************************/
/** General Utility Functions ***/
/********************************/
function seqToPairs(sequence) {
var pairs = [];
for (var i=0; i<sequence.length-1; i++) {
var base = sequence[i];
var nextBase = sequence[i+1];
var bp = base.concat(nextBase);
pairs.push(bp);
}
return pairs;
};
function cleanSequence(sequence) {
var cleanedSequence = "";
for (var i=0; i<sequence.length; i++) {
var base = sequence[i];
if (isValidBase(base)) {
cleanedSequence += base.toUpperCase();
}
}
return cleanedSequence;
};
function isValidBase(base) {
for (var i=0; i<bases.length; i++) {
if (base === bases[i] || base === bases[i].toLowerCase()) return true;
}
return false;
};
function isValidSequence(sequence) {
console.log("called: isValidSequence(" + sequence + ")");
sequence = sequence.toUpperCase();
if (sequence === "" || sequence.length < 11) {
return false;
}
for (var i=0; i<sequence.length; i++) {
var base = sequence[i];
if (!isValidBase(base) && base !== " " && base !== "\n") {
return false;
}
}
return true;
};
function comp(base) {
return opposites[base];
};
function reverseComplement(sequence) {
console.log("called: reverseComplement(" + sequence + ")");
var revComp = "";
for (var i=sequence.length-1; i>-1; i--) {
revComp += comp(sequence[i]);
}
return revComp;
};
function countGC(sequence) {
numGC = 0;
for (var i=0; i<sequence.length; i++) {
var base = sequence[i];
if (base == "G" || base == "C") numGC++;
}
return numGC;
};
function calcGCFraction(sequence) {
console.log("called: calcGCFraction(" + sequence + ")");
return(countGC(sequence)/sequence.length);
};
function isValidSaltConc(saltConc) {
for (var i=0; i<saltConc.length; i++) {
var ch = saltConc[i];
if (!(/^[0-9]+$/.test(ch))) return false;
}
if (parseFloat(saltConc) <= 0.0 || parseFloat(saltConc) > 1000.0) return false;
return true;
};
function isValidPrimerConc(primerConc) {
for (var i=0; i<primerConc.length; i++) {
var ch = primerConc[i];
if (!(/^[0-9]+$/.test(ch))) return false;
}
if (parseFloat(primerConc) <= 0.0 || parseFloat(primerConc) > 1000.0) return false;
return true;
};
function countBase(base, sequence) {
var n = 0;
for (var i=0; i<sequence.length; i++) {
if (base === sequence[i]) n++;
}
return n;
};
/********************************/
/******* NN Utility Functions ***/
/********************************/
function pairsToNNKeys(pairs) {
var keys = [];
for (var i=0; i<pairs.length; i++) {
var key = pairToNNKey(pairs[i]);
keys.push(key);
}
return keys;
}
function pairToNNKey( pair ) {
var opp_pair = compNN[pair];
var key = pair + "_" + opp_pair;
return key;
};
function seqToNNKeys( sequence ) {
console.log("called: seqToNNKeys");
var pairs = seqToPairs(sequence);
var keys = pairsToNNKeys(pairs);
return keys;
};
function getDH(sequence) {
console.log("called: getDH");
var keys = seqToNNKeys(sequence);
var dH = 0;
for (var i=0; i<keys.length; i++) {
key = keys[i];
dH += unifiedDH[key];
}
if (sequence[sequence.length] === "G" || sequence[sequence.length] === "C") {
dH += 0.1;
}
else {
dH += 2.3;
}
return dH;
};
function getDS(sequence) {
console.log("called: getDS");
pSeq = sequence;
var keys = seqToNNKeys(sequence);
var dS = 0;
for (var i=0; i<keys.length; i++) {
key = keys[i];
dS += unifiedDS[key];
}
if (sequence[sequence.length] === "G" || sequence[sequence.length] === "C") {
dS += -2.8;
}
else {
dS += 4.1;
}
return dS;
};
/********************************/
/*** Input Getter Functions *****/
/********************************/
function getPrimerSequence() {
console.log("called: getPrimerSequence() with result = " + $("#primer-sequence").text())
return $("#primer-sequence").val();
};
function getPrimerConc() {
return $("#primerConc").val().trim();
};
function getSaltConc() {
return $("#saltConc").val().trim();
};
/********************************/
/*** Output Setter Functions *****/
/********************************/
function setLengthField(length) {
$("#primerLength").val(length);
};
function setGCContentField(content) {
$("#gcContent").val(content + "%");
};
function setReverseComplementField(revComp) {
$("#reverse-complement-field").val(revComp);
};
function setTableMeltingTemps(temps) {
$("#table-tm-basic").text(temps[0] + "\xB0C");
$("#table-tm-salt").text(temps[1] + "\xB0C");
$("#table-tm-nn").text(temps[2] + "\xB0C");
};
function setPrimerSequenceInputField(sequence) {
$("#primer-sequence").val(sequence);
};
function fillOutputs() {
var sequence = cleanSequence(getPrimerSequence());
var meltingTemps = getMeltingTemps(sequence);
setTableMeltingTemps(meltingTemps);
setLengthField(sequence.length);
setGCContentField(Math.round(calcGCFraction(sequence)*100));
setReverseComplementField(reverseComplement(sequence));
setPrimerSequenceInputField(sequence);
};
/********************************/
/*** Melting Temp Functions *****/
/********************************/
function getBasicTM(sequence) {
var meltingTemp = 0;
if (sequence.length < 14) {
var numGC = countGC(sequence);
var numAT = sequence.length - numGC;
meltingTemp = 2*numAT + 4*numGC;
}
else {
meltingTemp = 64.9 + 41*countGC(sequence)/sequence.length - 672.4/sequence.length;
}
meltingTemp = meltingTemp.toFixed(1);
basicTM = meltingTemp;
return meltingTemp;
};