-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewPromotersByGenes.blade.php
231 lines (186 loc) · 10.8 KB
/
viewPromotersByGenes.blade.php
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
@php
include resource_path() . '/views/system/config.blade.php';
$organism = $info['organism'];
$result_arr = $info['result_arr'];
@endphp
<head>
<title>{{ $config_organism }}-KB</title>
<link rel="shortcut icon" href="{{ asset('css/images/Header/kbcommons_icon.ico') }}">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
</head>
<body>
<!-- Back button -->
<a href="{{ route('system.tools.GenVarX', ['organism'=>$organism]) }}"><button> < Back </button></a>
<br />
<br />
@php
for ($i = 0; $i < count($result_arr); $i++) {
echo "<b>Queried Gene: </b>" . $result_arr[$i]->Name . " (" . $result_arr[$i]->Chromosome . ":" . $result_arr[$i]->Start . "-" . $result_arr[$i]->End . ") (" . $result_arr[$i]->Strand . ")";
echo "<br /><br />";
echo "<b>Promoter Region: </b>" . $result_arr[$i]->Promoter_Start . "-" . $result_arr[$i]->Promoter_End;
echo "<br /><br />";
if (count($result_arr[$i]->Motif_Data) > 0) {
echo "<div style=\"width:auto; height:auto; border:3px solid #000; max-height:1000px; overflow:scroll;\">";
echo "<table style=\"text-align:center; width:100%;\">";
// Table header
echo "<tr>";
foreach ($result_arr[$i]->Motif_Data[0] as $key => $value) {
echo "<th style=\"border:1px solid black; text-align:center; min-width:80px;\">" . $key . "</th>";
}
echo "</tr>";
// Table row
for ($j = 0; $j < count($result_arr[$i]->Motif_Data); $j++) {
// Table row
echo "<tr bgcolor=\"" . ($j % 2 ? "#FFFFFF" : "#DDFDD") . "\">";
foreach ($result_arr[$i]->Motif_Data[$j] as $key => $value) {
if ($key == "Binding_TF") {
echo "<td style=\"border:1px solid black; min-width:80px;\">";
echo "<a href=\"javascript:void(0);\" onclick=\"getMotifWeblogo('" . $organism . "', '" . $value . "', '" . $result_arr[$i]->Name . "', '" . $result_arr[$i]->Motif_Data[$j]->Chromosome . "', '" . $result_arr[$i]->Motif_Data[$j]->Start . "', '" . $result_arr[$i]->Motif_Data[$j]->End . "', '" . $result_arr[$i]->Motif_Data[$j]->Gene_Binding_Sequence . "')\">";
echo $value;
echo "</a>";
echo "</td>";
} else {
echo "<td style=\"border:1px solid black; min-width:80px;\">" . $value . "</td>";
}
}
echo "</tr>";
}
echo "</table>";
echo "</div>";
echo "<br />";
// Div tags for selected motif, weblogo, and motif sequence table
echo "<div id=\"" . $result_arr[$i]->Name . "_b\" style='width:auto; height:auto; overflow:visible; max-height:1000px;'></div>";
echo "<div id=\"" . $result_arr[$i]->Name . "_weblogo\" style='width:auto; height:auto; overflow:visible; max-height:1000px;'></div>";
echo "<div id=\"" . $result_arr[$i]->Name . "_detail_table\" style='width:auto; height:auto; overflow:visible; max-height:1000px;'></div>";
echo "<br /><br />";
} else {
echo "<p>No binding TF found in our database!!!</p><br /><br />";
}
}
@endphp
</body>
<script type="text/javascript">
function getMotifWeblogo(organism, motif, gene, chromosome, motif_start, motif_end, motif_sequence) {
// Clear data appended to the div tags, if there is any
if (document.getElementById(gene+"_b").innerHTML) {
document.getElementById(gene+"_b").innerHTML = null;
}
if (document.getElementById(gene+"_weblogo").innerHTML) {
document.getElementById(gene+"_weblogo").innerHTML = null;
}
if (document.getElementById(gene+"_detail_table").innerHTML) {
document.getElementById(gene+"_detail_table").innerHTML = null;
}
// Create b tag for motif
var motif_b = document.createElement("b");
motif_b.innerHTML = "Selected TF: " + motif;
document.getElementById(gene+"_b").appendChild(motif_b);
// Load Ceqlogo / Weblogo image
var weblogo = document.createElement("img");
if (organism === "Osativa") {
weblogo.setAttribute("src", "{{ asset('system/home/GenVarX/assets/mViz_Rice_Japonica_motif_weblogos')}}" + "/" + motif + ".png");
document.getElementById(gene+"_weblogo").appendChild(weblogo);
} else if(organism === "Athaliana") {
weblogo.setAttribute("src", "{{ asset('system/home/GenVarX/assets/mViz_Arabidopsis_motif_weblogos')}}" + "/" + motif + ".png");
document.getElementById(gene+"_weblogo").appendChild(weblogo);
} else if(organism === "Zmays") {
weblogo.setAttribute("src", "{{ asset('system/home/GenVarX/assets/mViz_Maize_motif_weblogos') }}" + "/" + motif + ".png");
document.getElementById(gene+"_weblogo").appendChild(weblogo);
}
// Create motif sequence table
let detail_table = document.createElement("table");
detail_table.setAttribute("style", "text-align:center; border:3px solid #000;");
let detail_tr_index = document.createElement("tr");
let detail_tr_position = document.createElement("tr");
let detail_tr_nucleotide = document.createElement("tr");
let detail_tr_genotype_count = document.createElement("tr");
for (let i = 0; i < (motif_end-motif_start+1); i++) {
var detail_th = document.createElement("th");
detail_th.setAttribute("style", "border:1px solid black; min-width:80px; height:18.5px;");
detail_th.innerHTML = Number(i)+1;
detail_tr_index.appendChild(detail_th);
var detail_th = document.createElement("th");
detail_th.setAttribute("style", "border:1px solid black; min-width:80px; height:18.5px;");
detail_th.innerHTML = Number(motif_start)+Number(i);
detail_tr_position.appendChild(detail_th);
var detail_td = document.createElement("td");
detail_td.setAttribute("style", "border:1px solid black; min-width:80px; height:18.5px;");
detail_td.innerHTML = motif_sequence[i];
detail_tr_nucleotide.appendChild(detail_td);
var detail_td = document.createElement("td");
detail_td.id = "genotype_count_"+(Number(motif_start)+Number(i)).toString();
detail_tr_genotype_count.appendChild(detail_td);
}
detail_table.appendChild(detail_tr_index);
detail_table.appendChild(detail_tr_position);
detail_table.appendChild(detail_tr_nucleotide);
detail_table.appendChild(detail_tr_genotype_count);
document.getElementById(gene+"_detail_table").appendChild(detail_table);
$.ajax({
url: 'queryGenotypeCount/'+organism,
type: 'GET',
contentType: 'application/json',
data: {
Organism: organism,
Chromosome: chromosome,
Start: motif_start,
End: motif_end
},
success: function (response) {
let res = JSON.parse(response);
for (let i = 0; i < res.length; i++) {
var genotype_count_element = document.getElementById("genotype_count_"+(res[i]['Position']).toString());
if (genotype_count_element.innerHTML === null || genotype_count_element.innerHTML == '') {
// Construct table with header
genotype_count_element.setAttribute("style", "border:1px solid black; min-width:80px; height:18.5px;");
var genotype_count_table = document.createElement("table");
genotype_count_table.id = "genotype_count_"+(res[i]['Position']).toString()+"_table";
var genotype_count_tr_index = document.createElement("tr");
var detail_th = document.createElement("th");
detail_th.setAttribute("style", "border:1px solid black; min-width:20px; height:18.5px;");
detail_th.innerHTML = "Genotype";
genotype_count_tr_index.appendChild(detail_th);
var detail_th = document.createElement("th");
detail_th.setAttribute("style", "border:1px solid black; min-width:20px; height:18.5px;");
detail_th.innerHTML = "Category";
genotype_count_tr_index.appendChild(detail_th);
var detail_th = document.createElement("th");
detail_th.setAttribute("style", "border:1px solid black; min-width:20px; height:18.5px;");
detail_th.innerHTML = "Count";
genotype_count_tr_index.appendChild(detail_th);
genotype_count_table.appendChild(genotype_count_tr_index);
genotype_count_element.appendChild(genotype_count_table);
}
}
for (let i = 0; i < res.length; i++) {
var genotype_count_element_table = document.getElementById("genotype_count_"+(res[i]['Position']).toString()+"_table");
var genotype_count_tr_index = document.createElement("tr");
var detail_td = document.createElement("td");
detail_td.setAttribute("style", "border:1px solid black; min-width:20px; height:18.5px;");
detail_td.innerHTML = res[i]['Genotype'];
genotype_count_tr_index.appendChild(detail_td);
var detail_td = document.createElement("td");
detail_td.setAttribute("style", "border:1px solid black; min-width:20px; height:18.5px;");
detail_td.innerHTML = res[i]['Category'];
genotype_count_tr_index.appendChild(detail_td);
var detail_td = document.createElement("td");
detail_td.setAttribute("style", "border:1px solid black; min-width:20px; height:18.5px;");
var position_a = document.createElement("a");
position_a.href = "../viewVariantAndPhenotype/"+organism+"?Chromosome="+res[i]['Chromosome']+"&Position="+res[i]['Position']+"&Genotype="+res[i]['Genotype'];
position_a.target = "_blank";
position_a.innerHTML = res[i]['Count']
detail_td.appendChild(position_a);
genotype_count_tr_index.appendChild(detail_td);
genotype_count_element_table.appendChild(genotype_count_tr_index);
}
},
error: function (xhr, status, error) {
console.log('Error with code ' + xhr.status + ': ' + xhr.statusText);
}
});
// Change the overflow style of the div to scroll
document.getElementById(gene+"_b").style.overflow = 'scroll';
document.getElementById(gene+"_weblogo").style.overflow = 'scroll';
document.getElementById(gene+"_detail_table").style.overflow = 'scroll';
}
</script>