Skip to main content

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.

By default a column-to-column INTERSECTS join emits the naive overlap predicate (a.chrom = b.chrom AND a.start < b.end AND b.start < a.end) as a plain ON condition, which each engine's optimizer plans as a range join. For DuckDB you can additionally pass dialect="duckdb" to opt into a per-chromosome IEJoin plan for INNER, SEMI, or ANTI joins; shapes it declines fall through to the naive predicate. See DuckDB IEJoin Dialect for the supported shapes and fallback rules.

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]

Or spawn a server directly with uvx:

uvx --from "giql[mcp]" giql-mcp

To add the GIQL MCP server to a specific project in Claude Code:

claude mcp add --scope project giql-mcp -- uvx --from "giql[mcp]" 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

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.5.tar.gz (448.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.5-py3-none-any.whl (142.6 kB view details)

Uploaded Python 3

File details

Details for the file giql-0.5.tar.gz.

File metadata

  • Download URL: giql-0.5.tar.gz
  • Upload date:
  • Size: 448.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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.5.tar.gz
Algorithm Hash digest
SHA256 9b387a0f6ee048a059ea4a67be5a5c6d1c0dde5fcfd7248ba6250e9fb486a4fb
MD5 e78d82e28b360e41691f65a1cd4459ae
BLAKE2b-256 d397814161dca45335e7bba264b0130970d7b2c95f15ca6dce1b4edd0f40d67d

See more details on using hashes here.

File details

Details for the file giql-0.5-py3-none-any.whl.

File metadata

  • Download URL: giql-0.5-py3-none-any.whl
  • Upload date:
  • Size: 142.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fd1cfb3e7c103ec6ec607b8591f94005c6653a7418e0315a7e31e2fa39f57374
MD5 b9b499adbefc7c8ad40b13924d196a75
BLAKE2b-256 73f925aa48a7ef511eaac8e5088dd515f99a31eeb6edf8550d5fda7b5fd9697e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5 This release

2 files

0.4

2 files

0.3

2 files

0.2.1

2 files

0.2

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1

2 files

Supported by

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