[Biojava-l] Creating a dp object for a profile HMM (2)

Matthew Pocock matthew_pocock at yahoo.co.uk
Fri Jul 11 13:22:00 EDT 2003


Mmm. That's the topological sort of the states. It makes sure that when 
the DP recursion does a foreach(state), it loops over them in an order 
whereby all info is calculated that a state needs before it is reached. 
I am fairly sure that the body of the stateList() method can't infinite 
loop - all loops are bounded - iterators over finite lengthed lists.

Hang on - transtionsTo() could be the culprit. This could be getting 
stuck in an infinite loop in some condition we didn't think of. If you 
put some debug System.err.println statements in there, what happens?

Matthew

hlr02 at doc.ic.ac.uk wrote:
> Hi,
> 
> I have narrowed down the problem in creating a dp object for a profile HMM to a 
> possible bug in the code below from the DP class. I could really use some help 
> here..
> 
> Thanks,
> 
> Henry Romijn
> 
>   public static State[] stateList(MarkovModel mm) 
>   throws IllegalSymbolException, IllegalTransitionException,
>   BioException {
> 
>       // .....code here works ok
> 
>         for (Iterator addStates = alpha.iterator(); addStates.hasNext(); ) {
>         Object state = addStates.next();
>         if (state instanceof MagicalState) {
>           emissionStates.add(0, state);
>         }
>         else if (state instanceof EmissionState) {
>           emissionStates.add(state);
>         }
>         else {
>           ListIterator checkOld = dotStates.listIterator();
>           int insertPos = -1;
>           while (checkOld.hasNext() && insertPos == -1) {
>             Object oldState = checkOld.next();
>             if (comp.compare(state, oldState) == comp.LESS_THAN) {
>               insertPos = checkOld.nextIndex() - 1;
>             }
>           }
>           if (insertPos >= 0) {
>             dotStates.add(insertPos, state);
>           }
>           else {
>             dotStates.add(state);
>           }
>         }
>       }
> 
>       //......
>   }
> 



More information about the Biojava-l mailing list