Page MenuHomec4science

getVariants.php
No OneTemporary

File Metadata

Created
Mon, Mar 10, 07:34

getVariants.php

<?php
// query_type define is we are searching by:
// - old is the old version that uses the first version of the schema
// - Gene + Zygosity
// - ...
$query = "";
switch(htmlspecialchars($_GET["query_type"])){
case "gene_and_zygosity":
// select variant_id
// from shrine_ont.genomic_annotations_new
// where annotations ~* 'CTBP2P1;Homozygous;'
$query =
"SELECT variant_id " .
"FROM shrine_ont.genomic_annotations_new " .
"WHERE annotations ~* '" . htmlspecialchars($_GET["gene_name"]) . ";" . htmlspecialchars($_GET["zygosyty"]) .";'";;
break;
case "old":
//select variant_id
//from shrine_ont.genomic_annotations
//where variant_annotations ->> 'Start_Position' = '5239176'
$query =
"SELECT variant_id
FROM shrine_ont.genomic_annotations
WHERE variant_annotations ->> '". htmlspecialchars($_GET["annotation_name"]) . "' = '" . htmlspecialchars($_GET["annotation_value"]) ."'";
break;
default:
echo "Error: query type not recognized";
return;
}
$conn = pg_connect("host=localhost port=5432 dbname=i2b2 user=postgres password=admin");
if (!$conn) {
echo "Error while connecting to the postgres database";
exit;
}
$result = pg_query($conn, $query);
if (!$result) {
echo "An error occurred.\n";
exit;
}
// In json format return both the panel number and the list of variants
echo "{ \"panel_number\" :" . $_GET["panel_number"] . ", \"variants\" : ";
$variantList = "";
while ($row = pg_fetch_row($result)) {
$variantList .= "\"$row[0]\",";
}
// drop the last comma
echo "[" . substr($variantList, 0, -1) . "]}";

Event Timeline