Repository navigation
Bug 2947 viterbi - #1
Merged
2 commits merged intoJan 31, 2011
Merged
2 commits merged into
2 commits merged into
Conversation
…. This should only be done if there is an explicit start state. Also remove (incorrect) step in viterbi termination code that was intended to model an explicit end state. The module doesn't currently allow for specifying an end state.
Member
|
Phillip; |
kaskales
pushed a commit
to kaskales/biopython
that referenced
this pull request
Mar 8, 2019
unittest for the __add__ function of Codon alignment
buaahsh
reviewed
May 29, 2026
| @@ -0,0 +1,2407 @@ | |||
| News for the Biopython Project | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Member
There was a problem hiding this comment.
Stop spamming old issues with irrelevant comments please.
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
I think this fixes bug 2947. There were 2 errors in how the state sequence was calcuated.
The first occurs at the beginning of the sequence. viterbi_probs[(state_letters[0], -1)] was initialized to 1 and viterbi_probs[(state_letters[0], -1)] to 0 for all state letters other than the zeroth. This is how it is described in Biological Sequence Analysis by Durbin, et al, but it doesn't work for the code as written because the code doesn't provide for an particular begin state. By initializing the zeroth state letter to 1, and all the others to 0, you're starting off by assigning a higher probability to a state sequence that begins with the zeroth state letter.
I fixed this error by also setting viterbi_probs[(state_letters[0], -1)] to 0, so that all possible initial states are equally probable.
There's a second error in the Viterbi termination code. The algorithm described in Durbin et al allows for modeling a particular end state. Since the code as written doesn't provide for specifying an end state, the termination code miscalculates the sequence probability. The pseudocode in Durbin et al confusingly labels the end state as "0", at least in the printing I have, and this seems to have been carried over into the biopython code, where the zeroth state_letter is whichever one is first in the list. The code as written calculated the probability of the discovered state sequence multiplied by the probability of transitioning from the sequence's last element to the zeroth state named in state_letters, when it should just calculate the probability of the discovered state sequence.
I fixed this by deleting the lines that were intended to account for the transition to an end state.
It could be useful to specify particular begin and end states, but I believe this patch should give correct results for all cases that don't need that ability.
~Phillip