Traces#

class pyhmmer.plan7.TraceAligner#

A factory for aligning several sequences to a reference model.

Example

>>> aligner = TraceAligner()
>>> traces = aligner.compute_traces(thioesterase, proteins[:100])
>>> msa = aligner.align_traces(thioesterase, proteins[:100], traces)

Added in version 0.4.7.

align_traces(hmm, sequences, traces, digitize=False, trim=False, all_consensus_cols=False)#

Compute traces for a collection of sequences relative to an HMM.

Parameters:
  • hmm (HMM) – The reference HMM to use for the alignment.

  • sequences (DigitalSequenceBlock) – The target sequences to align to the HMM.

  • traces (Traces) – The traces corresponding to the alignment of sequences to hmm, obtained by a previous call to compute_traces.

  • digitize (bool) – If set to True, returns a DigitalMSA instead of a TextMSA.

  • trim (bool) – Trim off any residues that get assigned to flanking \(N\) and \(C\) states (in profile traces) or \(I_0\) and \(I_m\) (in core traces).

  • all_consensus_cols (bool) – Force a column to be created for every consensus column in the model, even if it means having all gap character in a column. Note that this is enabled by default for hmmalign since HMMER v3.1, but disabled here.

Returns:

MSA – A multiple sequence alignment containing the aligned sequences, either a TextMSA or a DigitalMSA depending on the value of the digitize argument.

Raises:
  • AlphabetMismatch – when the alphabet of any of the sequences does not correspond to the HMM alphabet.

  • InvalidHMM – when given a HMM that is not valid.

Changed in version 0.7.0: Targets must now be inside a DigitalSequenceBlock.

compute_traces(hmm, sequences)#

Compute traces for a collection of sequences relative to an HMM.

Parameters:
  • hmm (HMM) – The reference HMM to use for the alignment.

  • sequences (DigitalSequenceBlock) – The target sequences to align to the HMM.

Returns:

Traces – The traces for each sequence.

Raises:
  • AlphabetMismatch – when the alphabet of any of the sequences does not correspond to the HMM alphabet.

  • InvalidHMM – when given a HMM that is not valid.

Changed in version 0.7.0: Targets must now be inside a DigitalSequenceBlock.

class pyhmmer.plan7.Traces#

A list of tracebacks obtained by aligning several sequences to a model.

Added in version 0.4.7.

__getitem__(key, /)#

Return self[key].

__init__()#

Create an empty list of traces.

class pyhmmer.plan7.Trace#

A traceback for the alignment of a model to a sequence.

Added in version 0.4.7.

__init__(posteriors=False)#

Create a new Trace object.

Parameters:

posteriors (bool) – Whether or not to allocate additional memory for the storage of posterior probabilties.

expected_accuracy()#

Returns the sum of the posterior residue decoding probabilities.

classmethod from_sequence(sequence)#

Create a faux trace from a single sequence.

Added in version 0.6.0.

score(sequence, profile)#

Score traceback for target sequence using given profile.

Added in version 0.10.5.

L#

The sequence length.

Type:

int

M#

The model length.

Type:

int

posterior_probabilities#

The posterior probability of each residue.

Type:

VectorF or None