Team:Harvard/ZF Binding Site Finder
From 2011.igem.org
(Difference between revisions)
Line 238: | Line 238: | ||
} | } | ||
+ | }); | ||
+ | |||
+ | // findAllSites function | ||
+ | $("#findallsites").click(function () { | ||
+ | |||
+ | //initialize check variable, if check != 0 then results were found, else no results found | ||
+ | var check = 0; | ||
+ | |||
+ | //get test sequence | ||
+ | var testseq = $("#sequence").val().toUpperCase(); | ||
+ | |||
+ | //build array of nucleotides | ||
+ | var nucleotides = new Array("G", "C", "T", "A"); | ||
+ | |||
+ | //initialize table string to hold code for table | ||
+ | var table = ""; | ||
+ | |||
+ | //loop multidimensional array to iterate all possible zinc fingers, each array has 4 elements for 4 nucleotides | ||
+ | var nest = new Array(4); | ||
+ | for(var a=0; a<4; a++) | ||
+ | { | ||
+ | nest[a] = new Array(4); | ||
+ | for(var b=0; b<4; b++) | ||
+ | { | ||
+ | nest[a][b] = new Array(4); | ||
+ | for(var c=0; c<4; c++) | ||
+ | { | ||
+ | nest[a][b][c] = new Array(4); | ||
+ | for(var d=0; d<4; d++) | ||
+ | { | ||
+ | nest[a][b][c][d] = new Array(4); | ||
+ | for(var e=0; e<4; e++) | ||
+ | { | ||
+ | nest[a][b][c][d][e] = new Array(4); | ||
+ | for(var f=0; f<4; f++) | ||
+ | { | ||
+ | //build regular expression for each nucleotide combination | ||
+ | nest[a][b][c][d][e][f] = "\\w\\w" + reverseComplement(nucleotides[c]) + "\\w\\w" + reverseComplement(nucleotides[b]) + "\\w\\w" + reverseComplement(nucleotides[a]); | ||
+ | |||
+ | //add in x NTPs between first and second finger | ||
+ | var nucgap = $("#gap").val(); | ||
+ | |||
+ | for(i=0;i<nucgap;i++){ | ||
+ | nest[a][b][c][d][e][f] = nest[a][b][c][d][e][f] + "\\w"; | ||
+ | } | ||
+ | |||
+ | //finish constructing dynamic regular expression | ||
+ | nest[a][b][c][d][e][f] = nest[a][b][c][d][e][f] + nucleotides[d] + "\\w\\w" + nucleotides[e] + "\\w\\w" + nucleotides[f] + "\\w\\w"; | ||
+ | |||
+ | //find all instances of current nucleotide combination | ||
+ | var array1 = new RegExp(nest[a][b][c][d][e][f], "gi"); | ||
+ | var array2 = testseq.match(array1); | ||
+ | |||
+ | //do nothing if no result found | ||
+ | if(testseq.search(array1) == -1) | ||
+ | { | ||
+ | } else { | ||
+ | //add table heading for each combo | ||
+ | table = table + "<tr><td colspan='4'><b>" + "Bottom finger: " + nucleotides[a] + nucleotides[b] + nucleotides[c] + " Top finger: " + nucleotides[d] + nucleotides[e] + nucleotides[f] + "</b></td></tr>"; | ||
+ | |||
+ | var revComp = ""; | ||
+ | var seqtwo = ""; | ||
+ | var index = 0; | ||
+ | |||
+ | for(i=0;i<array2.length;i++) | ||
+ | { | ||
+ | array1.test(testseq); | ||
+ | |||
+ | table = table + "<tr>"; | ||
+ | //subtract 18 nucleotides, nucgap inter-ZF nucleotides, +1 for index correction for location of binding site | ||
+ | table = table + "<td>" + (array1.lastIndex - 18 - nucgap) + "</td>"; | ||
+ | seqbottom = reverseComplement(array2[i].substring(0,9)); | ||
+ | table = table + "<td>" + seqbottom + "</td>"; | ||
+ | table = table + "<td>" + array2[i].substring(array2[i].length - 9,array2[i].length) + "</td>"; | ||
+ | table = table + "<td>" + array2[i] + "</td>"; | ||
+ | table = table + "</tr>"; | ||
+ | } | ||
+ | |||
+ | check++; | ||
+ | |||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | //only build table if check is nonzero | ||
+ | if(check == 0) | ||
+ | { | ||
+ | $("#results").html("No binding sites found, unfortunately :("); | ||
+ | } else { | ||
+ | //add table preamble | ||
+ | var table = "<table><tr><td colspan='4'><b>Zinc Finger Binding Site Candidates</b></td></tr><td><b>Location</b></td><td><b>Bottom Sequence</b></td><td><b>Top Sequence</b></td><td><b>Entire Sequence (top strand perspective)</b></td>" + table; | ||
+ | |||
+ | //add table tail | ||
+ | table = table + "</table><br /><br />" | ||
+ | |||
+ | //write table to page | ||
+ | $("#results").html(table); | ||
+ | } | ||
}); | }); | ||
Line 318: | Line 420: | ||
<input type="button" id="findsites" value="Test (drop down menu)" /> | <input type="button" id="findsites" value="Test (drop down menu)" /> | ||
<input type="button" id="findcustom" value="Test custom input" /> | <input type="button" id="findcustom" value="Test custom input" /> | ||
- | <input type="button" value="Show me ALL binding sites! | + | <input type="button" id="findallsites" value="Show me ALL binding sites!" /> |
</td></tr> | </td></tr> | ||
</table> | </table> |
Revision as of 04:05, 9 July 2011
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">