fulcrumgenomics/rust-yara
GitHub: fulcrumgenomics/rust-yara
为 SeqAn2 的 YARA 基因组读段映射器提供安全的 Rust FFI 绑定,支持 FM 索引构建和双端读段映射。
Stars: 0 | Forks: 0
[](https://github.com/fulcrumgenomics/rust-yara/actions/workflows/check.yml)
[](https://crates.io/crates/yara-mapper)
[](https://docs.rs/yara-mapper)
[](LICENSE)
# rust-yara
YARA read mapper 的 Rust FFI 绑定。
## 概述
rust-yara 为
[YARA read mapper](https://github.com/seqan/seqan/tree/main/apps/yara) 提供安全的 Rust 绑定,这是一个基于 SeqAn2 C++ 库的快速且准确的读段映射器。该工作区既支持从 FASTA 参考文件构建 FM 索引,也支持针对预构建索引进行双端读段映射——全部通过 Rust 完成,且无需 SAM 序列化/反序列化的开销。
## Crate 结构
| Crate | 描述 |
|-------|-------------|
| [`yara-seqan2-sys`](https://crates.io/crates/yara-seqan2-sys) | YARA read mapper 的 Vendored SeqAn2 头文件 |
| [`yara-mapper-sys`](https://crates.io/crates/yara-mapper-sys) | YARA read mapper (SeqAn2) 的底层 FFI 绑定 |
| [`yara-mapper`](https://crates.io/crates/yara-mapper) | YARA read mapper 的安全 Rust 封装 |
## 先决条件
- **Rust** stable 工具链(请参阅 `rust-toolchain.toml` 以获取固定版本)
- **zlib** 开发头文件
- **OpenMP**:
- macOS: `brew install libomp`
- Linux: `libgomp`(通常随 GCC 附带;如果使用 Clang,请安装 `libomp-dev`)
## 快速入门
将 `yara-mapper` 添加到您的 `Cargo.toml` 中:
```
cargo add yara-mapper
```
构建索引并映射读段:
```
use yara_mapper::{IndexerOptions, MapperOptions, ReadBatch, YaraIndexer, YaraMapper};
// Build an index from a FASTA file.
let indexer = YaraIndexer::build("ref.fasta", "ref", &IndexerOptions::default()).unwrap();
println!("Indexed {} contigs", indexer.contig_count());
// Open the index and map reads.
let mapper = YaraMapper::open("ref", &MapperOptions::default()).unwrap();
let mut batch = ReadBatch::new();
batch.push("read1", b"ACGTACGT", b"IIIIIIII", b"TGCATGCA", b"IIIIIIII").unwrap();
let records = mapper.map_paired(&batch).unwrap();
for rec in &records {
println!("contig={} pos={} mapq={}", rec.contig_id, rec.pos, rec.mapq);
}
```
## 示例
从 FASTA 参考序列构建 FM 索引:
```
cargo run --example build_index -- ref.fasta ref
```
针对预构建索引映射读段:
```
cargo run --example align -- ref
```
## 从源码构建
```
cargo build # debug build
cargo clippy --all-targets # lint
cargo fmt --check # format check
```
要使用本地的 SeqAn2 检出副本而不是 vendored 头文件,请设置 `SEQAN_DIR`:
```
export SEQAN_DIR=/path/to/seqan
```
## 许可证
本项目采用 [MIT 许可证](LICENSE) 授权。
其中包含的 [SeqAn2](https://github.com/seqan/seqan) 头文件和
[YARA](https://github.com/seqan/seqan/tree/main/apps/yara) 应用程序源码
采用 BSD 3-Clause 许可证授权 — 详见
[`yara-seqan2-sys/vendor/include/seqan/LICENSE`](yara-seqan2-sys/vendor/include/seqan/LICENSE)
和
[`yara-seqan2-sys/vendor/apps/yara/LICENSE`](yara-seqan2-sys/vendor/apps/yara/LICENSE)。
## 贡献
有关开发设置和指南,请参阅 [CONTRIBUTING.md](CONTRIBUTING.md)。
标签:FASTA, FFI, FM-Index, Rust, SeqAn2, YARA, Zlib, 二代测序, 云资产可视化, 可视化界面, 基因组学, 安全绑定, 序列比对, 开源库, 搜索引擎爬虫, 生物信息学, 索引构建, 网络流量审计, 计算生物学, 读段映射, 跨语言调用, 通知系统, 高性能计算