Page MenuHomec4science

getVariants.php
No OneTemporary

File Metadata

Created
Mon, May 12, 16:30

getVariants.php

<?php
//select variant_id
//from shrine_ont.genomic_annotations
//where variant_annotations ->> 'Start_Position' = '5239176'
$conn = pg_connect("host=localhost port=5432 dbname=i2b2 user=postgres password=admin");
if (!$conn) {
echo "Error while connecting to the postgres database";
exit;
}
// get the row which contains all the values of the passed annotation
$query =
"SELECT variant_id
FROM shrine_ont.genomic_annotations
WHERE variant_annotations ->> '". htmlspecialchars($_GET["annotation_name"]) . "' = '" . htmlspecialchars($_GET["annotation_value"]) ."'";
$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