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)
Hint
The
hmmalignfunction is a higher-level function for performing trace alignment and supports parallelization with multithreading. Consider using it for better performance.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 ofsequencestohmm, obtained by a previous call tocompute_traces.digitize (
bool) – If set toTrue, returns aDigitalMSAinstead of aTextMSA.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 forhmmalignsince HMMER v3.1, but disabled here.
- Returns:
MSA– A multiple sequence alignment containing the aligned sequences, either aTextMSAor aDigitalMSAdepending on the value of thedigitizeargument.- 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].
- append(trace)#
Append a trace at the end of the block.
Added in version 0.11.4.
- clear()#
Remove all traces from the block.
Added in version 0.11.4.
- extend(iterable)#
Extend block by appending traces from the iterable.
Added in version 0.11.4.
- index(trace, start=0, stop=9223372036854775807)#
Return the index of the first occurence of
trace.- Returns:
int– The index of the trace inside the block.- Raises:
ValueError – When the block does not contain
trace.
Added in version 0.11.4.
- insert(index, trace)#
Insert a new trace in the block before
index.Added in version 0.11.4.
- pop(index=-1)#
Remove and return a trace from the block (the last one by default).
- Returns:
Trace– The trace freshly removed from the block.
Added in version 0.11.4.
- remove(trace)#
Remove the first occurence of the given trace.
- Raises:
ValueError – When the block does not contain
trace.
Added in version 0.11.4.
- 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
Traceobject.- 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.