Page MenuHomec4science

getVariantNames.php
No OneTemporary

File Metadata

Created
Sun, Mar 9, 23:12

getVariantNames.php

<?php
// case insensitive with regex
//select variant_name
//from shrine_ont.variant_names
//where variant_name ~* '.*a1.*'
//LIMIT 20
$conn = pg_connect("host=localhost port=5432 dbname=i2b2 user=shrine_ont password=demouser");
if (!$conn) {
echo "Error while connecting to the postgres database";
exit;
}
// escape the ? for regex query
$variant_name = str_replace("?", "\?", $_GET["variant_name"]);
// get the row which contains all the values of the passed annotation
$query =
"SELECT variant_name
FROM shrine_ont.genomic_annotations_new
WHERE variant_name ~* '.*" . $variant_name .".*'
LIMIT " . $_GET["limit"];
$result = pg_query($conn, $query);
if (!$result) {
echo "An error occurred.\n";
exit;
}
// In json format return the list of genes
$variantNames = "";
while ($row = pg_fetch_row($result)) {
$variantNames .= "\"$row[0]\",";
}
// drop the last comma and concatenate in json format
echo "[" . substr($variantNames, 0, -1) . "]";

Event Timeline