Skip to main content

Genomic Interval Query Language - SQL dialect for genomic range queries

Project description

GIQL

Genomic Interval Query Language (GIQL)

/JEE-quel/

docs | syntax | transpiler

GIQL is an extended SQL dialect that allows you to declaratively express genomic interval operations.

The giql Python package transpiles GIQL queries into standard SQL syntax for execution on any database or analytics engine.

Note: This project is in active development — APIs, syntax, and behavior may change.

Installation

To install the transpiler:

pip install giql

Usage (transpilation)

The giql package transpiles GIQL queries to standard SQL.

from giql import transpile

sql = transpile(
    "SELECT * FROM peaks WHERE interval INTERSECTS 'chr1:1000-2000'",
    tables=["peaks"],
)
print(sql)
SELECT
  *
FROM peaks
WHERE
  (
    "chrom" = 'chr1' AND "start" < 2000 AND "end" > 1000
  )

Each table referenced in a GIQL query exposes a genomic "pseudo-column" that maps to separate logical chromosome, start, end, and strand columns. You can customize the column mappings.

from giql import Table, transpile

sql = transpile(
    "SELECT * FROM variants WHERE position INTERSECTS 'chr1:1000-2000'",
    tables=[
        Table(
            "variants",
            genomic_col="position",
            chrom_col="chromosome",
            start_col="start_pos",
            end_col="end_pos",
        )
    ],
)
print(sql)

The transpiled SQL can be executed with fast genome-unaware databases or in-memory analytic engines like DuckDB.

You can also use oxbow to efficiently stream specialized genomics formats into DuckDB.

import duckdb
import oxbow as ox
from giql import transpile

conn = duckdb.connect()

# Load a streaming data source as a DuckDB relation
peaks = ox.from_bed("peaks.bed", bed_schema="bed6+4").to_duckdb(conn)

sql = transpile(
    "SELECT * FROM peaks WHERE interval INTERSECTS 'chr1:1000-2000'",
    tables=["peaks"],
)

# Execute and return the output as a dataframe
df = con.execute(sql).fetchdf()

MCP Server

GIQL includes an MCP server that gives LLM-powered tools access to operator references, syntax guides, and documentation. Install with the mcp extra:

pip install giql[mcp]

See src/giql/mcp/README.md for configuration and usage details.

Development

git clone https://github.com/abdenlab/giql.git
cd giql
uv sync

To build the documentation locally:

uv run --group docs sphinx-build docs docs/_build
# The built docs will be in docs/_build/html/

For serve the docs locally with automatic rebuild:

uv run --group docs sphinx-autobuild docs docs/_build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

giql-0.3rc0.tar.gz (145.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

giql-0.3rc0-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file giql-0.3rc0.tar.gz.

File metadata

  • Download URL: giql-0.3rc0.tar.gz
  • Upload date:
  • Size: 145.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for giql-0.3rc0.tar.gz
Algorithm Hash digest
SHA256 ae349c40f9736e1f3bf2b5d442b35eb48d1ef9bf99ef7542274c63875bfaf0c8
MD5 0d76b7f224341ca2c3a3c62d854969aa
BLAKE2b-256 acc79619713a5669f5f26edf878791489f990e7afb23d198edd3d89c1f942a6f

See more details on using hashes here.

File details

Details for the file giql-0.3rc0-py3-none-any.whl.

File metadata

  • Download URL: giql-0.3rc0-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for giql-0.3rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 a47078b937176f99c4259d76f2d803fc4b37c1cd27e0393467fa1d6ae7adc0d5
MD5 699644f835034bcca53e7e6f85493599
BLAKE2b-256 fe7e792ccf0daa870a5c2a45500b46f2b53175ad5fd435d4ec13811f14f62fa3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page