[Biojava-dev] generating OrderNDistribution sequences

Francois Pepin fpepin at cs.mcgill.ca
Sun Mar 7 17:31:07 EST 2004


Hi everyone,

I've been hitting this bug while generating OrderNDistributions
sequences:
java.lang.ArrayIndexOutOfBoundsException: 2
        at 
org.biojava.bio.symbol.PackedSymbolListFactory.makeSymbolList(PackedSymbolList
Factory.java:74)
        at 
org.biojava.bio.dist.DistributionTools.generateOrderNSymbolList(DistributionTo
ols.java:613)
        at 
org.biojava.bio.dist.DistributionTools.generateSymbolList(DistributionTools.ja
va:541)
        at 
org.biojava.bio.dist.DistributionTools.generateSequence(DistributionTools.java
:524)

which can be linked at lines 641-642 of DistributionTools, 
Symbol[] syms = new Symbol[ll.size()];
ll.toArray(syms);

where the ll should be l (ll has length of the order of distribution,
while l is the list of generated symbols).

I've fixed it in the CVS.

Out of curiosity, why does PackedSymbolListFactory has the following
method with a size argument?
 public SymbolList makeSymbolList(Symbol [] symbolArray, int size,
Alphabet alfa)

This is what ended up causing the errors ultimately because the size and
symbolArray.length disagreed (it would've crapped out anyway). It seems
to me as being a risk or error more than anything else.

I don't think it'd be worth changing, but I'm curious as why it was put
there in the first place.

Francois



More information about the biojava-dev mailing list