Insertion state 2026-10-20
An insertion state in a profile hidden Markov model emits characters between successive match states. A bypass allows zero inserted characters and a self-transition allows several. Under a fixed loop probability , the length of an insertion run conditional on entering has a geometric distribution on positive integers with exit probability .
Columns 22–28 form one run between alignment columns 21 and 29, corresponding to match states and . A self-repeating insertion state can emit a variable number of residues, so these seven alignment columns require one populated insertion state, not seven successive mandatory states.
Pool all nongap residues in this run to estimate its emission probabilities:
insert_columns = np.flatnonzero(~match_mask)
runs = np.split(insert_columns, np.flatnonzero(np.diff(insert_columns) > 1) + 1)
insert_emissions = []
for run in runs:
    if len(run):
        counts, n = emission_counts(A[:, run].ravel())
        insert_emissions.append({aa: count/n for aa, count in counts.items()})
        print(run+1, n, insert_emissions[-1])
There are 24 emitted residues, giving
All other amino acids have probability zero in this empirical emission probabilities. A conventional full architecture may provide an optional insertion state at every boundary, including the two ends, giving possible insertion positions; only one has an observed insertion here and is required by this alignment's populated insertion region.
With no deletion states allowed, each match state must emit once in every aligned sequence. Thus the four gap-free alignment columns, , become . Columns and form one optional run, represented by a single looping insertion state ; column requires a separate insertion state after . Two insertion states are sufficient and minimal in an ordered profile hidden Markov model: the two optional regions are separated by a compulsory emission and occupy different positions in the profile.
Estimate each transition probability by the number of observed uses of that transition divided by all transitions leaving its source state. The complete arrow diagram is given below; repeated labels denote the same state, so the second and third lines supply the branches of the first line. Start and End are silent:
Three aligned sequences visit , giving three exits to , while one sequence emits twice there, giving one self-transition. Thus its exit and loop probabilities are and , respectively. Two sequences visit and two bypass it. All absent transitions have probability zero.
The probability mass functions of the emitting states, estimated from all characters assigned to each state with no added counts, are
In particular, pooling the two optional columns into pools four emissions: two T, one A and one G. This is a generative Hidden Markov model, so it can generate other run lengths and combinations as well as the training sequences; reproducing each training column deterministically is not its purpose.
The sequence has five characters, while the four match states account for four compulsory emissions. Consequently exactly one insertion state emission is needed. An insertion at would have to emit T, which has probability zero there. The only nonzero hidden path is therefore
Multiply its transition probabilities and emission probabilities, including the probability of exiting immediately and bypassing :
Normally the forward algorithm sums over all compatible paths. Here all other paths have probability zero, so this single path gives the full sequence probability.
A profile hidden Markov model represents the position-dependent structure of a sequence alignment using an ordered series of match states and optional insertion states, commonly with silent deletion states as well. An emitting state chooses one character from its probability mass function; transitions describe which profile position comes next. If deletion states are forbidden, an alignment column containing gaps cannot be a compulsory match state.