跳转到主要内容

postbis

提供压缩的 DNA、RNA、氨基酸及比对序列类型,以及类型转换、运算符、索引和生物信息学函数。

postbis · 提供压缩的 DNA、RNA、氨基酸及比对序列类型,以及类型转换、运算符、索引和生物信息学函数。

概览

ID扩展软件包版本类别许可证编程语言
3780postbispostbis1.0TYPEPostgreSQLC
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d-r否是否是是否
The packaged repository is an untagged copy of PostBIS, inactive since 2019; Pigsty pins commit ce454ebf and patches PostgreSQL 14-18 compatibility plus alphabet output and indexed slice correctness.

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY1.019 18 17 16 15postbis-
RPMPIGSTY1.019 18 17 16 15postbis_$v-
DEBPIGSTY1.019 18 17 16 15postgresql-$v-postbis-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el8.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
软件包版本平台仓库大小下载
postbis_191.0el9.x86_64pigsty168.9 KiBpostbis_19-1.0-1PGSTY.el9.x86_64.rpm
postbis_191.0el9.aarch64pigsty166.4 KiBpostbis_19-1.0-1PGSTY.el9.aarch64.rpm
postbis_191.0el10.x86_64pigsty170.9 KiBpostbis_19-1.0-1PGSTY.el10.x86_64.rpm
postbis_191.0el10.aarch64pigsty167.0 KiBpostbis_19-1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-postbis1.0d12.x86_64pigsty152.2 KiBpostgresql-19-postbis_1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-postbis1.0d12.aarch64pigsty147.3 KiBpostgresql-19-postbis_1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-postbis1.0d13.x86_64pigsty153.2 KiBpostgresql-19-postbis_1.0-1PGSTY~trixie_amd64.deb
postgresql-19-postbis1.0d13.aarch64pigsty148.2 KiBpostgresql-19-postbis_1.0-1PGSTY~trixie_arm64.deb
postgresql-19-postbis1.0u22.x86_64pigsty162.9 KiBpostgresql-19-postbis_1.0-1PGSTY~jammy_amd64.deb
postgresql-19-postbis1.0u22.aarch64pigsty161.1 KiBpostgresql-19-postbis_1.0-1PGSTY~jammy_arm64.deb
postgresql-19-postbis1.0u24.x86_64pigsty160.6 KiBpostgresql-19-postbis_1.0-1PGSTY~noble_amd64.deb
postgresql-19-postbis1.0u24.aarch64pigsty157.8 KiBpostgresql-19-postbis_1.0-1PGSTY~noble_arm64.deb
postgresql-19-postbis1.0u26.x86_64pigsty160.8 KiBpostgresql-19-postbis_1.0-1PGSTY~resolute_amd64.deb
postgresql-19-postbis1.0u26.aarch64pigsty157.5 KiBpostgresql-19-postbis_1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
postbis_181.0el8.x86_64pigsty166.0 KiBpostbis_18-1.0-1PGSTY.el8.x86_64.rpm
postbis_181.0el8.aarch64pigsty162.2 KiBpostbis_18-1.0-1PGSTY.el8.aarch64.rpm
postbis_181.0el9.x86_64pigsty169.0 KiBpostbis_18-1.0-1PGSTY.el9.x86_64.rpm
postbis_181.0el9.aarch64pigsty166.6 KiBpostbis_18-1.0-1PGSTY.el9.aarch64.rpm
postbis_181.0el10.x86_64pigsty170.8 KiBpostbis_18-1.0-1PGSTY.el10.x86_64.rpm
postbis_181.0el10.aarch64pigsty167.1 KiBpostbis_18-1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-postbis1.0d12.x86_64pigsty152.3 KiBpostgresql-18-postbis_1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-postbis1.0d12.aarch64pigsty147.2 KiBpostgresql-18-postbis_1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-postbis1.0d13.x86_64pigsty153.3 KiBpostgresql-18-postbis_1.0-1PGSTY~trixie_amd64.deb
postgresql-18-postbis1.0d13.aarch64pigsty147.9 KiBpostgresql-18-postbis_1.0-1PGSTY~trixie_arm64.deb
postgresql-18-postbis1.0u22.x86_64pigsty162.7 KiBpostgresql-18-postbis_1.0-1PGSTY~jammy_amd64.deb
postgresql-18-postbis1.0u22.aarch64pigsty160.9 KiBpostgresql-18-postbis_1.0-1PGSTY~jammy_arm64.deb
postgresql-18-postbis1.0u24.x86_64pigsty160.7 KiBpostgresql-18-postbis_1.0-1PGSTY~noble_amd64.deb
postgresql-18-postbis1.0u24.aarch64pigsty157.8 KiBpostgresql-18-postbis_1.0-1PGSTY~noble_arm64.deb
postgresql-18-postbis1.0u26.x86_64pigsty160.5 KiBpostgresql-18-postbis_1.0-1PGSTY~resolute_amd64.deb
postgresql-18-postbis1.0u26.aarch64pigsty157.4 KiBpostgresql-18-postbis_1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
postbis_171.0el8.x86_64pigsty166.0 KiBpostbis_17-1.0-1PGSTY.el8.x86_64.rpm
postbis_171.0el8.aarch64pigsty162.1 KiBpostbis_17-1.0-1PGSTY.el8.aarch64.rpm
postbis_171.0el9.x86_64pigsty169.0 KiBpostbis_17-1.0-1PGSTY.el9.x86_64.rpm
postbis_171.0el9.aarch64pigsty166.6 KiBpostbis_17-1.0-1PGSTY.el9.aarch64.rpm
postbis_171.0el10.x86_64pigsty170.9 KiBpostbis_17-1.0-1PGSTY.el10.x86_64.rpm
postbis_171.0el10.aarch64pigsty167.1 KiBpostbis_17-1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-postbis1.0d12.x86_64pigsty152.2 KiBpostgresql-17-postbis_1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-postbis1.0d12.aarch64pigsty147.3 KiBpostgresql-17-postbis_1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-postbis1.0d13.x86_64pigsty153.2 KiBpostgresql-17-postbis_1.0-1PGSTY~trixie_amd64.deb
postgresql-17-postbis1.0d13.aarch64pigsty147.9 KiBpostgresql-17-postbis_1.0-1PGSTY~trixie_arm64.deb
postgresql-17-postbis1.0u22.x86_64pigsty169.0 KiBpostgresql-17-postbis_1.0-1PGSTY~jammy_amd64.deb
postgresql-17-postbis1.0u22.aarch64pigsty167.0 KiBpostgresql-17-postbis_1.0-1PGSTY~jammy_arm64.deb
postgresql-17-postbis1.0u24.x86_64pigsty160.7 KiBpostgresql-17-postbis_1.0-1PGSTY~noble_amd64.deb
postgresql-17-postbis1.0u24.aarch64pigsty157.9 KiBpostgresql-17-postbis_1.0-1PGSTY~noble_arm64.deb
postgresql-17-postbis1.0u26.x86_64pigsty160.5 KiBpostgresql-17-postbis_1.0-1PGSTY~resolute_amd64.deb
postgresql-17-postbis1.0u26.aarch64pigsty157.3 KiBpostgresql-17-postbis_1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
postbis_161.0el8.x86_64pigsty166.0 KiBpostbis_16-1.0-1PGSTY.el8.x86_64.rpm
postbis_161.0el8.aarch64pigsty162.1 KiBpostbis_16-1.0-1PGSTY.el8.aarch64.rpm
postbis_161.0el9.x86_64pigsty169.0 KiBpostbis_16-1.0-1PGSTY.el9.x86_64.rpm
postbis_161.0el9.aarch64pigsty166.6 KiBpostbis_16-1.0-1PGSTY.el9.aarch64.rpm
postbis_161.0el10.x86_64pigsty170.9 KiBpostbis_16-1.0-1PGSTY.el10.x86_64.rpm
postbis_161.0el10.aarch64pigsty167.1 KiBpostbis_16-1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-postbis1.0d12.x86_64pigsty152.3 KiBpostgresql-16-postbis_1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-postbis1.0d12.aarch64pigsty147.2 KiBpostgresql-16-postbis_1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-postbis1.0d13.x86_64pigsty153.3 KiBpostgresql-16-postbis_1.0-1PGSTY~trixie_amd64.deb
postgresql-16-postbis1.0d13.aarch64pigsty148.1 KiBpostgresql-16-postbis_1.0-1PGSTY~trixie_arm64.deb
postgresql-16-postbis1.0u22.x86_64pigsty169.0 KiBpostgresql-16-postbis_1.0-1PGSTY~jammy_amd64.deb
postgresql-16-postbis1.0u22.aarch64pigsty167.0 KiBpostgresql-16-postbis_1.0-1PGSTY~jammy_arm64.deb
postgresql-16-postbis1.0u24.x86_64pigsty160.6 KiBpostgresql-16-postbis_1.0-1PGSTY~noble_amd64.deb
postgresql-16-postbis1.0u24.aarch64pigsty157.8 KiBpostgresql-16-postbis_1.0-1PGSTY~noble_arm64.deb
postgresql-16-postbis1.0u26.x86_64pigsty160.4 KiBpostgresql-16-postbis_1.0-1PGSTY~resolute_amd64.deb
postgresql-16-postbis1.0u26.aarch64pigsty157.3 KiBpostgresql-16-postbis_1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
postbis_151.0el8.x86_64pigsty166.9 KiBpostbis_15-1.0-1PGSTY.el8.x86_64.rpm
postbis_151.0el8.aarch64pigsty162.6 KiBpostbis_15-1.0-1PGSTY.el8.aarch64.rpm
postbis_151.0el9.x86_64pigsty170.3 KiBpostbis_15-1.0-1PGSTY.el9.x86_64.rpm
postbis_151.0el9.aarch64pigsty168.0 KiBpostbis_15-1.0-1PGSTY.el9.aarch64.rpm
postbis_151.0el10.x86_64pigsty171.9 KiBpostbis_15-1.0-1PGSTY.el10.x86_64.rpm
postbis_151.0el10.aarch64pigsty168.0 KiBpostbis_15-1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-postbis1.0d12.x86_64pigsty153.6 KiBpostgresql-15-postbis_1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-postbis1.0d12.aarch64pigsty148.4 KiBpostgresql-15-postbis_1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-postbis1.0d13.x86_64pigsty154.6 KiBpostgresql-15-postbis_1.0-1PGSTY~trixie_amd64.deb
postgresql-15-postbis1.0d13.aarch64pigsty149.2 KiBpostgresql-15-postbis_1.0-1PGSTY~trixie_arm64.deb
postgresql-15-postbis1.0u22.x86_64pigsty170.6 KiBpostgresql-15-postbis_1.0-1PGSTY~jammy_amd64.deb
postgresql-15-postbis1.0u22.aarch64pigsty168.1 KiBpostgresql-15-postbis_1.0-1PGSTY~jammy_arm64.deb
postgresql-15-postbis1.0u24.x86_64pigsty161.4 KiBpostgresql-15-postbis_1.0-1PGSTY~noble_amd64.deb
postgresql-15-postbis1.0u24.aarch64pigsty158.6 KiBpostgresql-15-postbis_1.0-1PGSTY~noble_arm64.deb
postgresql-15-postbis1.0u26.x86_64pigsty161.8 KiBpostgresql-15-postbis_1.0-1PGSTY~resolute_amd64.deb
postgresql-15-postbis1.0u26.aarch64pigsty158.3 KiBpostgresql-15-postbis_1.0-1PGSTY~resolute_arm64.deb

源码

pig build pkg postbis;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install postbis;		# install by package name

pig install postbis -v 19;   # install for PG 19
pig install postbis -v 18;   # install for PG 18
pig install postbis -v 17;   # install for PG 17
pig install postbis -v 16;   # install for PG 16
pig install postbis -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION postbis;

用法

来源:

postbis 1.0 为 DNA、RNA、氨基酸及比对序列提供紧凑的原生数据类型,并提供可配置字母表与类型修饰符、类型转换、序列操作、生物学变换、比较操作符,以及 B-tree 和哈希操作符类。

存储强类型序列

CREATE EXTENSION postbis;

CREATE TABLE specimen (
  specimen_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  dna dna_sequence(SHORT, FLC, CASE_SENSITIVE) NOT NULL,
  rna rna_sequence(IUPAC, CASE_SENSITIVE),
  protein aa_sequence(IUPAC, CASE_SENSITIVE)
);

INSERT INTO specimen (dna, rna, protein)
VALUES ('AACCGGTT', 'AACGUU', 'ACDEFG');

SELECT specimen_id,
       char_length(dna) AS bases,
       substr(dna, 3, 4)::text AS fragment
FROM specimen;

输入验证取决于所选字母表、大小写敏感性和类型修饰符。应验证转换能拒绝所需生物学约定之外的符号,并避免意外混用对齐与未对齐类型。

变换与翻译序列

SELECT complement('ACGTN'::dna_sequence)::text;
-- TGCAN

SELECT reverse_complement('ACGTN'::dna_sequence)::text;
-- NACGT

SELECT transcribe('AACGTT'::dna_sequence)::text;
-- AACGUU

SELECT translate('AUGGCCUAA'::rna_sequence)::text;
-- MA

扩展还提供 reverse_transcribe()、six_frame()、get_alphabet()、entropy()、gc_content() 和序列生成函数。标准遗传密码不适用时,翻译函数可以接收显式翻译表。

检查压缩并添加索引

SELECT char_length(sequence) AS symbols,
       octet_length(sequence) AS storage_bytes,
       compression_ratio(sequence) AS storage_ratio
FROM (
  SELECT repeat('ACGT', 256)::dna_sequence AS sequence
) AS sample;

CREATE INDEX specimen_dna_btree ON specimen USING btree (dna);
CREATE INDEX specimen_dna_hash  ON specimen USING hash  (dna);

这些序列类型支持等值、排序、拼接、子串、搜索和长度函数。在生产负载中依赖索引之前,应使用真实数据分布检查执行计划。

打包与持久性风险

Pigsty 应用下游兼容补丁,将 PostBIS 1.0 打包到 PostgreSQL 14–18。这一打包结果并不改变上游生命周期:项目已经停止维护,也没有 1.0 以后的扩展升级路径。

自定义类型使用原生压缩磁盘表示。应把已存储值和索引视为绑定到经过测试的准确构建。采用或迁移前,必须验证转储恢复、二进制和逻辑升级、复制、驱动解码、索引重建、错误输入处理和大型序列内存行为。

reverse()、char_length() 和 substr() 等函数重载了常见名称,因此模式限定和受控 search_path 设置很重要。对新的持久数据集,除非已经在本地审计、打包该扩展并指定明确的长期迁移负责人,否则应优先使用受维护的序列工具或普通 PostgreSQL 类型。

表格阅读器