Skip to main content

genomic_system_finder_hmm/
lib.rs

1// SPDX-License-Identifier: GPL-3.0-or-later
2
3//! # genomic-system-finder-hmm
4//!
5//! A pure Rust implementation of HMMER3-compatible profile HMM search.
6//!
7//! This crate provides a WASM-compatible alternative to HMMER's `hmmsearch`,
8//! implementing the Plan7 Viterbi algorithm for scoring protein sequences
9//! against profile HMMs in HMMER3/b format.
10//!
11//! ## Features
12//!
13//! - Parse HMMER3/b format HMM profile files
14//! - Viterbi algorithm for Plan7 HMMs with local entry/exit
15//! - Multi-domain detection
16//! - E-value computation using Gumbel extreme value distribution
17//! - No external dependencies (pure Rust, WASM-compatible)
18//!
19//! ## Usage
20//!
21//! ```text
22//! use genomic_system_finder_hmm::{parser, pipeline, SearchOptions, TargetSequence};
23//!
24//! let hmms = parser::parse_hmm_file(Path::new("profile.hmm")).unwrap();
25//! let targets = vec![TargetSequence {
26//!     id: "seq1".to_string(),
27//!     sequence: b"MKFLILACLAV...".to_vec(),
28//! }];
29//! let results = pipeline::hmmsearch(&hmms[0], &targets, &SearchOptions::default());
30//! ```
31
32pub mod alphabet;
33pub mod hmm;
34pub mod msv;
35pub mod parser;
36pub mod pipeline;
37pub mod stats;
38pub mod viterbi;
39
40pub use hmm::Plan7Hmm;
41pub use pipeline::{DomainHit, SearchOptions, SearchResult, TargetSequence};
42
43/// Errors from HMM operations.
44#[derive(Debug, thiserror::Error)]
45pub enum HmmError {
46    #[error("I/O error: {0}")]
47    Io(String),
48
49    #[error("HMM parse error: {0}")]
50    Parse(String),
51
52    #[error("search error: {0}")]
53    Search(String),
54}