public
Description: Conversion tool that turns DNA sequences into RNA sequences, and lists the amino acids in the RNA
Homepage: http://neverfriday.com/dna-rna-amino/
Clone URL: git://github.com/omouse/dna-rna-amino.git
dna-rna-amino / views.js
100644 103 lines (90 sloc) 3.27 kb
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
/* data.js - part of the dna-rna-amino package
* Licensed under the MIT license found in the file LICENSE
* If the text of the license is not included, refer to this
* website for the terms of the license:
* http://www.opensource.org/licenses/mit-license.php
*/
 
/* Functions and objects for displaying data. Also includes
* functions for getting data from HTML/user-interface elements.
* Uses jQuery 1.2.6 in some spots.
*/
 
function view_dna_conversion () {
  var dna = getDNASequence();
  displayRNASequence(transcribeDNA(dna));
  if (isSequenceCorrectLength(dna))
    $("#dna-sequence div").removeClass("invalid");
  else
    $("#dna-sequence div").addClass("invalid");
}
 
function view_rna_conversion () {
  var rna = getRNASequence();
  displayDNASequence(reverseTranscribe(rna));
  if (isSequenceCorrectLength(rna))
    $("#rna-sequence div").removeClass("invalid");
  else
    $("#rna-sequence div").addClass("invalid");
}
 
function _tr (s) { return "<tr>" + s + "</tr>\n"; }
function _td (s) { return "<td>" + s + "</td>"; }
 
function hide_amino_acids () {
  $("#aminoAcids").hide();
  $("#aminoAcidTotals").hide();
}
 
function show_amino_acids (n) {
  if (n < 1000) {
    $("#aminoAcids").show(1, function () {
$("#aminoAcidTotals").show();
});
  }
  else {
    $("#aminoAcids").slideDown(n, function () {
$("#aminoAcidTotals").slideDown(1000);
});
    }
}
 
function view_amino_acids (results) {
  hide_amino_acids();
  $("#aminoAcids tbody").empty();
  for (var i = 0; i < results.length; i++) {
    var amino = results[i];
    //console.log("adding amino: %s", amino);
    //$("#aminoAcids").append("<li>" + amino.abbreviation + ", " + amino.molecularWeight + "</li>");
    $("#aminoAcids tbody").append(_tr(_td(amino.abbreviation)
+ _td(amino.name)
+ _td(amino.atomicWeightRatio)
+ _td(amino.molecularWeight)
+ _td(amino.kiloDaltonWeight)
+ _td(amino.pK1)
+ _td(amino.pK2)
+ _td(amino.pL)
));
  }
  $("#totalMolecularWeight").html(aminoTotal(results, "molecularWeight"));
  $("#totalKiloDaltonWeight").html(aminoTotal(results, "kiloDaltonWeight"));
  $("#totalPL").html(aminoTotal(results, "pL") / results.length);
  show_amino_acids(results.length * 100);
}
 
function getRNASequence () {
  return _cleanup_sequence($("#rnaString").val(), baseRNA);
}
 
function getDNASequence () {
  return _cleanup_sequence($("#dnaString").val(), baseDNA);
}
 
function displayRNASequence (s) {
  $("#rnaString").val(_cleanup_sequence(s, baseRNA));
}
 
function displayDNASequence (s) {
  $("#dnaString").val(_cleanup_sequence(s, baseDNA));
}
 
$(document).ready(function () {
  $("#dnaString").keyup(function (e) { view_dna_conversion(); });
  $("#rnaString").keyup(function (e) { view_rna_conversion(); });
  $("h2.load-local").cluetip({ local: true, cursor: "pointer",
hideLocal: false, arrows: true,
sticky: false,
positionBy: "mouse" });
  $("div.tooltip").hide();
  // Colour the rows of the amino acids table
  $("tr > td[class!=amino-grouping]:first-child").css("padding-left", "1.5em");
  hide_amino_acids();
  });