Algorithm::HMM(3pm)

πŸ“¦
version 3.0.6 Β· 4 versions
, in ubuntu jammy

✨ NAME ✨

Algorithm::HMM β€” bestie, it's Perl bindings for a Hidden Markov Model library πŸ’– no cap, that's the whole vibe. You write Perl, the HMM heavy lifting happens somewhere else, and you get to stay cute.

This one lives in the User Contributed Perl Documentation corner of your system, filed under Algorithm::HMM(3pm). Say hi when you see it πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

Okay so here's the whole lil routine, fr fr. Load a model, run a sequence through it, collect your hits, print your stats, save, reload. Iconic behaviour:

use Algorithm::HMM;

# Load a Hidden Markov Model.
my $hmm = new Algorithm::HMM(Model => 'sample.hmm');

# Run a sequence through the loaded model.
my $rep = $hmm->search("AAIELKBPOWELKQJPASDLKJIGE");

# Get all the global hits from the search.
my @ghits = $rep->global_hits();

# Get all the domain hits from the search.
my @dhits = $rep->domain_hits();

# Display information about the domain hits.
for (@dhits) {
  print("pvalue = " . $_->pvalue . "\n");
  print("evalue = " . $_->evalue . "\n");
  print("score  = " . $_->score  . "\n");
}

# Save the model to a different file.
$hmm->save("sample.hmm.0");

# Load the saved model again.
$hmm->load("sample.hmm.1")

Let's break down the moments, because each one ate πŸ’…:

  • use Algorithm::HMM; β€” pulls the module in, the opening act 🌸
  • my $hmm = new Algorithm::HMM(Model => 'sample.hmm'); β€” constructs a new object and loads a Hidden Markov Model from the file named by the Model argument, here sample.hmm.
  • my $rep = $hmm->search("AAIELKBPOWELKQJPASDLKJIGE"); β€” runs that sequence through the loaded model and hands you back a report object, $rep. The sequence string is passed straight in, exactly as written, letters and all 🧚
  • my @ghits = $rep->global_hits(); β€” grabs all the global hits from the search into @ghits.
  • my @dhits = $rep->domain_hits(); β€” grabs all the domain hits from the search into @dhits.
  • for (@dhits) { ... } β€” loops over every domain hit, and each $_ in there is a hit object you can interrogate for its pvalue, evalue and score πŸ“
    • $_->pvalue β€” the p-value of that hit, printed as pvalue = <value>
    • $_->evalue β€” the e-value of that hit, printed as evalue = <value>
    • $_->score β€” the score of that hit, printed as score = <value> (yes the spacing in the format string is exactly like that, we love consistency πŸ’€)
  • $hmm->save("sample.hmm.0"); β€” saves the model out to a different file, here sample.hmm.0.
  • $hmm->load("sample.hmm.1") β€” loads a saved model again, here from sample.hmm.1. Not me pointing out there's no semicolon at the end of that line in the synopsis… it's giving "copy it verbatim or fix it yourself" energy πŸ™ˆ iykyk
Heads up bestie: the synopsis is the official example, so the file names and the sequence string are reproduced character for character. If you're actually running this, you supply your own paths and your own sequence πŸ’œ

That's the whole page, short and sweet β€” this one is all synopsis, no OPTIONS section, no SEE ALSO, nothing hiding in the back. Take the vibes, keep the exact syntax, and go be the main character of your own sequence analysis πŸŒˆπŸ’–

Brought to you by perl v5.34.0, dated 2022-02-06 β€” mwah, thanks for reading, love u, bye πŸ‘‘πŸ’…βœ¨

πŸ“¦ where this page comes from