This project demonstrates a simple PHP + Bootstrap web application for issuing Beacon-style SPARQL queries against a GraphDB repository. It supports four query types:
- Beacon Sequence Query
- Beacon Range Query
- Beacon Bracket Query
- Beacon Aminoacid Change Query (find genomic variants by a fixed
infoKey="VT"and a user-providedinfoValue, e.g."INDEL")
After retrieving the main query results, the app automatically (after a short delay) fetches metadata for each row (except for the VT query, which skips metadata).
This application is built in PHP. It uses the Bootstrap CSS framework for a cleaner UI and AJAX calls (via fetch) for running SPARQL queries on a GraphDB repository. A server-side cache (in $_SESSION) prevents repeated queries from being re-run.
- A single-page Bootstrap UI that:
- Shows three placeholder logos at the top.
- Offers a dropdown to select which query to run (Sequence, Range, Bracket, or VT).
- Displays different parameter input fields depending on the selected query.
- Uses an AJAX call (via the JavaScript
fetchAPI) to query the backend (ajax_handler.php). - Shows a spinner overlay while waiting for the query results.
- After the main query results appear, the system issues additional “metadata” queries for each result row (except for the VT query, which skips metadata).
- Renders both the main query results and the metadata in tables.
- A PHP backend endpoint that:
- Receives JSON POST requests from
index.php. - Uses a session-based cache (in
$_SESSION) to avoid re-running identical SPARQL queries. - Depending on the request’s
queryType:main: Runs one of four SPARQL queries (Sequence, Range, Bracket, or VT).- Each query is built with user-provided parameters.
- Responds with a JSON array of rows (e.g.
{ "results": [ { "chrom": "1", "pos": "719853", ... }, ... ] }).
metadata: Uses(pos, ref, alt)from a main query row to run a “metadata” SPARQL query, returning info keys/values (infoKey,infoValue).
- Returns JSON responses with either
{"results": [...]}or an{"error": "..."}message.
- Receives JSON POST requests from
-
Install & Run GraphDB
- Download and install GraphDB on your local machine (or on a server).
- Create a repository (e.g., named
myRepo) and load your RDF data into it.
-
Enable Anonymous Read (optional)
- If you want the app to query without credentials, ensure your GraphDB repository allows anonymous read access.
- Otherwise, provide credentials in
ajax_handler.phpusingcurl_setopt($ch, CURLOPT_USERPWD, "user:pass");.
-
Adjust Configuration
- In
ajax_handler.php, locate the line:Replace$graphdbEndpoint = "http://localhost:7200/repositories/YOUR_REPO_HERE";
YOUR_REPO_HEREwith your actual repository name (for example,myRepo).
- In
-
Place files on a PHP server
- Put
index.phpandajax_handler.phpin the same folder on your web server. - Make sure session support is active (e.g., call
session_start()and checkphp.ini).
- Put
-
Open
index.phpin your Browser- For example,
http://localhost/path/to/index.php. - Select a query type (Sequence, Range, Bracket, or VT).
- Fill in the parameters (position, reference, etc.).
- Click Run Main Query. The spinner appears.
- Once the main query completes, results are displayed. If applicable (for queries 1–3), a second metadata query runs automatically (after half a second) to retrieve additional info.
- For example,
- SPARQL Query IRIs:
If your data uses different ontology IRIs or properties, update thePREFIXlines or the triple patterns inajax_handler.php. - Literal Types:
If your data usesxsd:stringinstead ofrdf:PlainLiteral, adjust theFILTERconditions to match. - Caching:
By default, caching is in$_SESSION. For multi-user production scenarios, consider using a more robust shared cache (files, Redis, etc.). - Spinner / Layout:
Modify or remove the spinner overlay or card styles inindex.php. - Authentication:
- If GraphDB is secured, add Basic Auth with
curl_setopt($ch, CURLOPT_USERPWD, "username:password");. - Limit public access as needed.
- If GraphDB is secured, add Basic Auth with