-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewAlleleCatalog.blade.php
203 lines (166 loc) · 11.7 KB
/
viewAlleleCatalog.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
@php
include resource_path() . '/views/system/config.blade.php';
$organism = $info['organism'];
$dataset = $info['dataset'];
$gene = $info['gene'];
$chromosome = $info['chromosome'];
$position = $info['position'];
$phenotype = $info['phenotype'];
$gene_result_arr = $info['gene_result_arr'];
$phenotype_distribution_result_arr = $info['phenotype_distribution_result_arr'];
$allele_catalog_result_arr = $info['allele_catalog_result_arr'];
@endphp
<head>
<title>{{ $config_organism }}-KB</title>
<link rel="shortcut icon" href="{{ asset('css/images/Header/kbcommons_icon.ico') }}">
<link rel="stylesheet" href="{{ asset('system/home/PhenoDistTool/css/modal.css') }}">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css"></link>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
</head>
<body>
<!-- Back button -->
<a href="{{ route('system.tools.PhenoDistTool', ['organism'=>$organism]) }}"><button> < Back </button></a>
<br />
<br />
<!-- Modal -->
<div id="info-modal" class="info-modal">
<!-- Modal content -->
<div class="modal-content">
<span class="modal-close">×</span>
<div id="modal-content-div" style='width:100%; height:auto; border:3px solid #000; overflow:scroll;max-height:1000px;'></div>
<div id="modal-content-comment"></div>
</div>
</div>
@php
// Color for functional effects
$ref_color_code = "#D1D1D1";
$missense_variant_color_code = "#7FC8F5";
$frameshift_variant_color_code = "#F26A55";
$exon_loss_variant_color_code = "#F26A55";
$lost_color_code = "#F26A55";
$gain_color_code = "#F26A55";
$disruptive_color_code = "#F26A55";
$conservative_color_code = "#FF7F50";
$splice_color_code = "#9EE85C";
// Render result to a table
if(isset($allele_catalog_result_arr) && is_array($allele_catalog_result_arr) && !empty($allele_catalog_result_arr)) {
echo "<p>* Significant position(s) are highlighted in red. </p>";
for ($i = 0; $i < count($allele_catalog_result_arr); $i++) {
$phenotype_distribution_position_array = array();
for ($j=0; $j < count($phenotype_distribution_result_arr[$i]); $j++) {
array_push($phenotype_distribution_position_array, $phenotype_distribution_result_arr[$i][$j]->Position);
}
// Make table
echo "<div style='width:100%; height:auto; border:3px solid #000; overflow:scroll; max-height:1000px;'>";
echo "<table style='text-align:center;'>";
// Table header
echo "<tr>";
echo "<th></th>";
foreach ($allele_catalog_result_arr[$i][0] as $key => $value) {
if ($key != "Gene" && $key != "Chromosome" && $key != "Position" && $key != "Genotype" && $key != "Genotype_Description") {
// Improvement status count section
echo "<th style=\"border:1px solid black; min-width:80px;\">" . $key . "</th>";
} elseif ($key == "Gene") {
echo "<th style=\"border:1px solid black; min-width:80px;\">" . $key . "</th>";
} elseif ($key == "Chromosome") {
echo "<th style=\"border:1px solid black; min-width:80px;\">" . $key . "</th>";
} elseif ($key == "Position") {
// Position and genotype_description section
$position_array = preg_split("/[;, \n]+/", $value);
for ($j = 0; $j < count($position_array); $j++) {
if (in_array($position_array[$j], $phenotype_distribution_position_array)) {
echo "<th style=\"border:1px solid black; min-width:80px; color:red;\"><a style=\"color:red;\" href=\"../viewVariantAndPhenotypeFigures/" . $organism . "?Dataset=" . $dataset . "&Chromosome=" . $allele_catalog_result_arr[$i][0]->Chromosome . "&Position=" . $position_array[$j] . "&Phenotype=" . $phenotype . "\" target=\"_blank\">" . $position_array[$j] . "</a></th>";
} else {
echo "<th style=\"border:1px solid black; min-width:80px;\">" . $position_array[$j] . "</th>";
}
}
}
}
echo "<th></th>";
echo "</tr>";
// Table body
for ($j = 0; $j < count($allele_catalog_result_arr[$i]); $j++) {
$tr_bgcolor = ($j % 2 ? "#FFFFFF" : "#DDFFDD");
$row_id_prefix = $allele_catalog_result_arr[$i][$j]->Gene . "_" . $allele_catalog_result_arr[$i][$j]->Chromosome . "_" . $j;
echo "<tr bgcolor=\"" . $tr_bgcolor . "\">";
echo "<td><input type=\"checkbox\" id=\"" . $row_id_prefix . "_l" . "\" name=\"" . $row_id_prefix . "_l" . "\" value=\"" . $row_id_prefix . "_l" . "\" onclick=\"checkHighlight(this)\"></td>";
foreach ($allele_catalog_result_arr[$i][$j] as $key => $value) {
if ($key != "Gene" && $key != "Chromosome" && $key != "Position" && $key != "Genotype" && $key != "Genotype_Description") {
// Improvement status count section
if (intval($value) > 0) {
echo "<td style=\"border:1px solid black;min-width:80px;\">";
echo "<a href=\"javascript:void(0);\" onclick=\"queryMetadataByImprovementStatusAndGenotypeCombination('" . $organism . "', '" . strval($dataset) . "', '" . strval($key) . "', '" . $allele_catalog_result_arr[$i][$j]->Gene . "', '" . $allele_catalog_result_arr[$i][$j]->Chromosome . "', '" . $allele_catalog_result_arr[$i][$j]->Position . "', '" . $allele_catalog_result_arr[$i][$j]->Genotype . "', '" . $allele_catalog_result_arr[$i][$j]->Genotype_Description . "')\">";
echo $value;
echo "</a>";
echo "</td>";
} else {
echo "<td style=\"border:1px solid black;min-width:80px;\">" . $value . "</td>";
}
} elseif ($key == "Gene") {
echo "<td style=\"border:1px solid black;min-width:80px;\">" . $value . "</td>";
} elseif ($key == "Chromosome") {
echo "<td style=\"border:1px solid black;min-width:80px;\">" . $value . "</td>";
} elseif ($key == "Genotype_Description") {
// Position and genotype_description section
$position_array = preg_split("/[;, \n]+/", $allele_catalog_result_arr[$i][$j]->Position);
$genotype_description_array = preg_split("/[;, \n]+/", $value);
for ($k = 0; $k < count($genotype_description_array); $k++) {
// Change genotype_description background color
$td_bg_color = "#FFFFFF";
if (preg_match("/missense.variant/i", $genotype_description_array[$k])) {
$td_bg_color = $missense_variant_color_code;
$temp_value_arr = preg_split("/[;, |\n]+/", $genotype_description_array[$k]);
$genotype_description_array[$k] = (count($temp_value_arr) > 2 ? $temp_value_arr[0] . "|" . $temp_value_arr[2] : $genotype_description_array[$k]);
} else if (preg_match("/frameshift/i", $genotype_description_array[$k])) {
$td_bg_color = $frameshift_variant_color_code;
} else if (preg_match("/exon.loss/i", $genotype_description_array[$k])) {
$td_bg_color = $exon_loss_variant_color_code;
} else if (preg_match("/lost/i", $genotype_description_array[$k])) {
$td_bg_color = $lost_color_code;
$temp_value_arr = preg_split("/[;, |\n]+/", $genotype_description_array[$k]);
$genotype_description_array[$k] = (count($temp_value_arr) > 2 ? $temp_value_arr[0] . "|" . $temp_value_arr[2] : $genotype_description_array[$k]);
} else if (preg_match("/gain/i", $genotype_description_array[$k])) {
$td_bg_color = $gain_color_code;
$temp_value_arr = preg_split("/[;, |\n]+/", $genotype_description_array[$k]);
$genotype_description_array[$k] = (count($temp_value_arr) > 2 ? $temp_value_arr[0] . "|" . $temp_value_arr[2] : $genotype_description_array[$k]);
} else if (preg_match("/disruptive/i", $genotype_description_array[$k])) {
$td_bg_color = $disruptive_color_code;
} else if (preg_match("/conservative/i", $genotype_description_array[$k])) {
$td_bg_color = $conservative_color_code;
} else if (preg_match("/splice/i", $genotype_description_array[$k])) {
$td_bg_color = $splice_color_code;
} else if (preg_match("/ref/i", $genotype_description_array[$k])) {
$td_bg_color = $ref_color_code;
}
echo "<td id=\"" . $row_id_prefix . "_" . $position_array[$k] . "\" style=\"border:1px solid black;min-width:80px;background-color:" . $td_bg_color . "\">" . $genotype_description_array[$k] . "</td>";
}
}
}
echo "<td><input type=\"checkbox\" id=\"" . $row_id_prefix . "_r" . "\" name=\"" . $row_id_prefix . "_r" . "\" value=\"" . $row_id_prefix . "_r" . "\" onclick=\"checkHighlight(this)\"></td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
echo "<div style='margin-top:10px;' align='right'>";
echo "<button onclick=\"queryAllCountsByGene('" . $organism . "', '" . $dataset . "', '" . $allele_catalog_result_arr[$i][0]->Gene . "', '" . $allele_catalog_result_arr[$i][0]->Chromosome . "')\" style=\"margin-right:20px;\"> Download (Accession Counts)</button>";
echo "<button onclick=\"queryAllByGene('" . $organism . "', '" . $dataset . "', '" . $allele_catalog_result_arr[$i][0]->Gene . "', '" . $allele_catalog_result_arr[$i][0]->Chromosome . "')\"> Download (All Accessions)</button>";
echo "</div>";
echo "<br />";
echo "<br />";
}
} else {
echo "<p>No Allele Catalog data found in database!!!</p>";
}
@endphp
<div class="footer" style="margin-top:20px;float:right;">© Copyright 2024 KBCommons</div>
</body>
<script src="{{ asset('system/home/PhenoDistTool/js/modal.js') }}" type="text/javascript"></script>
<script src="{{ asset('system/home/PhenoDistTool/js/viewAlleleCatalog.js') }}" type="text/javascript"></script>
<script type="text/javascript">
var organism = <?php if(isset($organism)) {echo json_encode($organism, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var dataset = <?php if(isset($dataset)) {echo json_encode($dataset, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var chromosome = <?php if(isset($chromosome)) {echo json_encode($chromosome, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var position = <?php if(isset($position)) {echo json_encode($position, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
var phenotype = <?php if(isset($phenotype)) {echo json_encode($phenotype, JSON_INVALID_UTF8_IGNORE);} else {echo "";}?>;
</script>