Plan7

High-level interface to the Plan7 data model.

Plan7 is the model architecture used by HMMER since HMMER2.

See also

Details about the Plan 7 architecture in the HMMER documentation.

Alignment

class pyhmmer.plan7.Alignment

A single alignment of a sequence to a profile.

Background Model

class pyhmmer.plan7.Background

The null background model of HMMER.

Domains

class pyhmmer.plan7.Domain

A single domain in a query Hit.

score

The overall score in bits, null-corrected.

Type

float

class pyhmmer.plan7.Domains

A sequence of domains corresponding to a single Hit.

Hits

class pyhmmer.plan7.Hit

A high-scoring database hit found by the comparison pipeline.

pre_score

Bit score of the sequence before null2 correction.

Type

float

score

Bit score of the sequence with all domains after correction.

Type

float

class pyhmmer.plan7.TopHits

A ranked list of top-scoring hits.

TopHits are thresholded using the parameters from the pipeline, and are sorted by key when you obtain them from a Pipeline instance:

>>> abc = thioesterase.alphabet
>>> hits = Pipeline(abc).search(thioesterase, proteins)
>>> hits.is_sorted()
True

Use len to query the number of top hits, and the usual indexing notation to extract a particular hit:

>>> len(hits)
1
>>> hits[0].name
b'938293.PRJEB85.HG003687_113'
clear()

Free internals to allow reusing for a new pipeline run.

HMM

class pyhmmer.plan7.HMM

A data structure storing the Plan7 Hidden Markov Model.

write()

Write the HMM to a file handle.

Parameters
  • fh (io.IOBase) – A Python file handle, opened in binary mode (this must be the case even with binary=False, since the C code will emit bytes in either case).

  • binary (bool) – Pass False to emit the file in ASCII mode using the latest supported HMMER format, or True to use the binary HMMER3 format.

zero()

Set all parameters to zero (including model composition).

M

The length of the model (i.e. the number of nodes).

Type

int

accession

The accession of the HMM, if any.

Type

bytes or None

description

The description of the HMM, if any.

Type

bytes or None

name

The name of the HMM, if any.

Type

bytes or None

HMM File

class pyhmmer.plan7.HMMFile

A wrapper around a file (or database), storing serialized HMMs.

close()

Close the HMM file and free resources.

This method has no effect if the file is already closed.

Pipeline

class pyhmmer.plan7.Pipeline

An HMMER3 accelerated sequence/profile comparison pipeline.

search()

Run the pipeline using a query HMM against a sequence database.

Parameters
  • hmm (HMM) – The HMM object to use to query the sequence database.

  • sequences (Iterable of DigitalSequence) – The sequences to query with the HMMs. Pass a SequenceFile instance in digital mode to iteratively read from disk.

  • hits (TopHits, optional) – A hit collection to store results in, if any. If None, a new collection will be allocated. Use a non-None value if you are running several HMMs sequentially and want to aggregate the results, or if you are able to recycle a TopHits instance with TopHits.clear.

Returns

TopHits – the hits found in the sequence database. If an instance was passed via the hits argument, it is safe to ignore the return value and to access it by reference.

Raises

ValueError – When the alphabet of the current pipeline does not match the alphabet of the given HMM.

Profile

class pyhmmer.plan7.Profile

A Plan7 search profile.

clear()

Clear internal buffers to reuse the profile without reallocation.

configure()

Configure a search profile using the given models.

Parameters
  • hmm (pyhmmer.plan7.HMM) – The model HMM with core probabilities.

  • bg (pyhmmer.plan7.Background) – The null background model.

  • L (int) – The expected target sequence length.

  • multihit (bool) – Whether or not to use multihit modes.

  • local (bool) – Whether or not to use non-local modes.

is_local()

Returns whether or not the profile is in a local alignment mode.

is_multihit()

Returns whether or not the profile is in a multihit alignment mode.

optimized()

Convert the profile to a platform-specific optimized profile.

class pyhmmer.plan7.OptimizedProfile

An optimized profile that uses platform-specific instructions.

is_local()

Returns whether or not the profile is in a local alignment mode.

write()

Write an optimized profile to two separate files.

HMMER implements an acceleration pipeline using several scoring algorithms. Parameters for MSV (the Multi ungapped Segment Viterbi) are saved independently to the fh_filter handle, while the rest of the profile is saved to fh_profile.