[Biojava-dev] Problems with parameter change event notification in profile HMM (2)

hlr02 at doc.ic.ac.uk hlr02 at doc.ic.ac.uk
Wed Jul 16 15:36:22 EDT 2003


Contrary to what I wrote, using setWeights(state,distribution) doesn't fire a 
change event either, i.e. any changes in transition distributions do not seem 
to be picked up by change events.

Henry

Quoting hlr02 at doc.ic.ac.uk:

> Hi,
> 
> I tested the change event notification for changes in profile HMM transition
> 
> and emission probabilities, which should result in firing of a 
> MarkovModel.PARAMETER change event. This doesn't always work:
> 
> 1. Changing emission distributions by using setDistribution(distribution) 
> results in no PARAMETER change events being fired at all, i.e.
> 
> for (Iterator i = profile.stateAlphabet().iterator(); i.hasNext(); ) {
>   State s = (State) i.next();
>   // this should generate parameter change events
>   if (s instanceof EmissionState && ! (s instanceof MagicalState)) {
>     EmissionState es = (EmissionState) s;
>     // this doesn't generate change events
>     es.setDistribution(
>       new UniformDistribution((FiniteAlphabet)profile.emissionAlphabet())
>     );
>   } 
> }
> 
> However, changing the emission distribution by stepping through the 
> distribution and changing probabilities one by one using setWeight(symbol, 
> weight) works fine and does result in change events.
> 
> 2. Changing transition probabilities one by one in the transition alphabet 
> returned by transitionFrom(state) doesn't result in any change events, i.e.
> 
> for (Iterator i = profile.stateAlphabet().iterator(); i.hasNext(); ) {
>   
>   State s = (State) i.next();
>   double length = ( (FiniteAlphabet) profile.transitionsFrom(s)).size();
>   FiniteAlphabet fromStates = profile.transitionsFrom(s);
>   Distribution dist = profile.getWeights(s);
>   // this doesn't result in change events
>   for (Iterator j = fromStates.iterator(); j.hasNext(); ) {
>     State t = (State) j.next();
>     dist.setWeight(t, (1/length) );
>   }
> } 
> 
> However, changing the transition probability from a state in one go by using
> 
> setWeights(state,distribution) does result in firing a PARAMETER change
> event.
> 
> I used two change listeners, a change forwarder and ChangeListener.LOG_TO_OUT
> 
> to test the above.
> 
> Since the above may allow changes in the model without any change
> notification, 
> this could create serious problems when for example a Change Listener in a
> GUI 
> relies on change events to update its state.
> 
> Any ideas how to fix this?
> 
> Regards,
> 
> Henry
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at biojava.org
> http://biojava.org/mailman/listinfo/biojava-dev
> 



----- End forwarded message -----




More information about the biojava-dev mailing list