Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104528350
getVariants.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Mar 10, 04:59
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Mar 12, 04:59 (1 d, 19 h)
Engine
blob
Format
Raw Data
Handle
24805778
Attached To
R4897 i2b2-webclient
getVariants.php
View Options
<?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
(
$_GET
[
"query_type"
]){
case
"gene_and_zygosity"
:
// case insensitive regex query
// select variant_id
// from shrine_ont.genomic_annotations_new
// where annotations ~* '^CTBP2P1;(Homozygous|Unknown);'
$zigosity
=
$_GET
[
"zygosity"
];
// array of zygosity options, put them in the query separated by | (or)
$query
=
"SELECT variant_id "
.
"FROM shrine_ont.genomic_annotations_new "
.
"WHERE annotations ~* '^"
.
$_GET
[
"gene_name"
]
.
";("
.
join
(
'|'
,
$zigosity
)
.
");'"
;
break
;
case
"variantName_and_zygosity"
:
// case insensitive regex query
// select variant_id
// from shrine_ont.genomic_annotations_new
/* where variant_name='Y:59022489:?>A'*/
$zigosity
=
$_GET
[
"zygosity"
];
$query
=
"SELECT variant_id "
.
"FROM shrine_ont.genomic_annotations_new "
.
"WHERE variant_name='"
.
$_GET
[
"variant_name"
]
.
"' AND "
.
"annotations ~* '"
.
"("
.
join
(
'|'
,
$zigosity
)
.
")'"
;
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 ->> '"
.
$_GET
[
"annotation_name"
]
.
"' = '"
.
$_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
Log In to Comment