2 Segmenting a sequence
We work on a well-known sequence, the DNA sequence of λ−phage,
in file lambda.seq, which is in specific
format. In this example, we use a previously defined HMM, from file
We load the sequence and the
lexique corresponding to the HMM.
- We build and draw the
partition of the states of the
most probable "path" computed with Viterbi algorithm.
- We compute the Matrice of the
log-probabilities of the descriptors given the sequence and the
model, by Forward-Backward algorithm.
- We build a new partition, in which each segment is made where the most
probable descriptor in former Matrice is the same on a continuous set
- And if we want to draw the partition such that the height of
each arc is proportional with minus the density of log-probability
of the model on this segment.
p2.draw_nf("lambda_val.ps",num=1,func=lambda x: -x.val()/len(x))
- And we want to draw only the segments described by descriptor 3.
p2.draw_nf("lambda_val3.ps",seg=,func=lambda x: -x.val()/len(x))
- We compute the proportion of common descriptions between both
- We build the 50-partitioning from the predictions of the
lexique, and draw it.
- We compute the list of the similarities between the partitions
of ps and both partitions p1 and p2.
for i in range(len(ps)):
for i in l:
Notice and compare the best scores and their corresponding number of
segments with the actual number of segments of p and