fg-labs/rust-yara
GitHub: fg-labs/rust-yara
该项目为基于 SeqAn2 的 YARA read mapper 提供了安全的 Rust FFI 绑定,支持在 Rust 中高效进行基因组索引构建和序列比对。
Stars: 0 | Forks: 0
[](https://github.com/fg-labs/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++ 库的快速、准确的 read mapper。该工作空间支持从 FASTA 参考序列构建 FM 索引以及将双端 reads 比对到预构建的索引——全部在 Rust 中完成,且没有 SAM 序列化/反序列化的开销。
## Crate 结构
| Crate | 描述 |
|-------|-------------|
| [`yara-seqan2-sys`](https://crates.io/crates/yara-seqan2-sys) | YARA read mapper 的 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** 稳定版工具链 (固定版本见 `rust-toolchain.toml`)
- **zlib** 开发头文件
- **OpenMP**:
- macOS: `brew install libomp`
- Linux: `libgomp` (通常随 GCC 一起包含;如果使用 Clang,请安装 `libomp-dev`)
## 快速开始
将 `yara-mapper` 添加到你的 `Cargo.toml`:
```
cargo add yara-mapper
```
构建索引并比对 reads:
```
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
```
将 reads 比对到预构建的索引:
```
cargo run --example align -- ref
```
## 从源代码构建
```
cargo build # debug build
cargo clippy --all-targets # lint
cargo fmt --check # format check
```
要使用本地的 SeqAn2 副本而不是打包的头文件,请设置 `SEQAN_DIR`:
```
export SEQAN_DIR=/path/to/seqan
```
## 许可证
本项目在 [MIT License](LICENSE) 下获得许可。
打包的 [SeqAn2](https://github.com/seqan/seqan) 头文件和 [YARA](https://github.com/seqan/seqan/tree/main/apps/yara) 应用程序源代码根据 BSD 3-Clause License 获得许可 — 参见 [`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) 了解开发设置和指南。
标签:C++ 绑定, FASTA, FFI, FM-index, OpenMP, Read Mapping, Rust, SeqAn2, YARA, 云资产可视化, 内存映射, 可视化界面, 基因组学, 序列比对, 数据索引, 测序数据分析, 生信工具, 生物信息学, 网络流量审计, 通知系统, 高性能计算