1 unstable release

0.2.1 Aug 24, 2024

#191 in Biology


Used in hmmsearch_rs

GPL-3.0 license

66KB
524 lines

Rust interface to the HMMER C code. This library provides a Rust interface which builds upon the bindings generated by libhmmer-sys and is intended to provide a more idiomatic Rust interface.

It is quite new and not all of the functionality of HMMER is exposed yet. If you need something that is not exposed, please open an issue or a pull request, or better yet have a go at implementing it yourself.

As this is still early days, the API is likely to change. If you are using this library, please pin your dependency to a specific version.

Example usage, running a HMMSEARCH:

let hmms = Hmm::read_hmms_from_path(std::path::Path::new(
    "tests/data/DNGNGWU00010_mingle_output_good_seqs.hmm",
))
.unwrap();
let hmm = &hmms[0];

println!("HMM name: {}", hmm.name());

let mut hmmsearch = HmmerPipeline::new(hmm);

let mut query_seq = EaselSequence::new(Alphabet::Protein);
let seq: &[u8] =
    b"MVYSGPNAPIEVGNSLPLSEIPLATEIHNIELTPGKGGQLVRSAGSSAQLLAKEGNYVTLRLPSGEMRFVRKECYATIGQ";

query_seq.replace_sequence(seq).unwrap();
debug!("Query seq replaced;");

hmmsearch.query(&query_seq);

let hmmsearch_result = hmmsearch.get_results();

println!(
    "Total number of reported hits: {}",
    hmmsearch_result.nreported()
);

for hit in hmmsearch_result.hits() {
    println!("New hit:");
    println!("Hit name: {}", hit.name());
    println!("Hit score: {}", hit.score());
    for domain in hit {
        println!("New domain:");
        println!("Domain score: {}", domain.bitscore());
        println!("Domain evalue: {:?}", domain.evalue());
    }
}

Output of this program:

HMM name: S2.1.ribosomal_protein_L2_rplB
Total number of reported hits: 1
New hit:
Hit name:
Hit score: 150.01991
current domain counter 0
New domain:
Domain score: 149.90887
Domain evalue: 1.4970530541655288e-48

Dependencies

~10MB
~166K SLoC