Skip to content

genomics

Genomic intervals, compressed DNA and genotype types with aggregates and indexes

pg-genomics · Genomic intervals, compressed DNA and genotype types with aggregates and indexes

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102477genomicspg-genomics0.1TYPEC

PostgreSQL · 16

Usage

Sources:

genomics 0.1 is the extension name of the pg-genomics project. It provides genomic intervals, compressed DNA and genotype values, aggregates and operator classes. The documented server version is PostgreSQL 16. A superuser installs the native extension; it is relocatable and requires no shared preload.

Types and Core Queries

CREATE EXTENSION genomics;
SELECT '1:100-200'::genomic_region && '1:150-250'::genomic_region;
SELECT length('1:1-7 GATTACA'::dna);
SELECT substr('1:1-7 GATTACA'::dna, '1:2-4'::genomic_region);
SELECT counts('1:1-10 00100001?0'::genotype);

genomic_region represents a chromosome and inclusive interval. dna combines a region with a sequence; the example substring is 1:2-4 ATT. genotype encodes the mutation states 0, 1, 2 and unknown. counts returns their counts in that order, so this example returns {7,2,0,1}.

Aggregates and Indexing

SELECT reference(seq)
FROM (VALUES ('1:1-4 ACGN'::dna), ('1:1-4 AGGN'::dna)) AS samples(seq);

SELECT genetic_distance(a, b)
FROM (VALUES ('1:1-10 0000000010'::genotype,
              '1:1-10 00100001?0'::genotype)) AS samples(a, b);

reference constructs a reference sequence by per-position voting. genetic_distance aggregates paired genotype comparisons. The supplied GIN operator class accelerates genotype mutation-pattern searches; the B-tree class supports region equality and lexicographic ordering. The overlap operator && does not imply that a B-tree can answer arbitrary overlap searches.

Data and Operational Boundaries

Use the documented coordinate and sequence formats, and validate region lengths before loading real datasets. The project relies on PostgreSQL TOAST and normal table/index maintenance. Its external evaluation dataset is not bundled, and benchmark results do not establish performance for another workload. No license grant was found in the reviewed source revision.

Table reader