public String tokenizeSymbolList(SymbolList sl) throws IllegalAlphabetException { if (sl.getAlphabet() != getAlphabet()) { throw new IllegalAlphabetException( "Alphabet " + sl.getAlphabet().getName() + " does not match " + getAlphabet().getName()); } StringBuffer sb = new StringBuffer(); for (Iterator i = sl.iterator(); i.hasNext(); ) { Symbol sym = (Symbol) i.next(); try { Character c = _tokenizeSymbol(sym); sb.append(c.charValue()); } catch (IllegalSymbolException ex) { throw new IllegalAlphabetException(ex, "Couldn't tokenize"); } } return sb.substring(0); }
public SymbolList mutate(SymbolList seq) throws ChangeVetoException, IllegalAlphabetException, IllegalSymbolException { int maxIndex = getMutationProbs().length - 1; OrderNDistribution d = getMutationSpectrum(); Random r = new Random(); for (int i = 1; i < seq.length(); i++) { int index = Math.min(i - 1, maxIndex); double mutProb = getMutationProbs()[index]; if (r.nextDouble() < mutProb) { Edit e = new Edit(i, seq.getAlphabet(), d.getDistribution(seq.symbolAt(i)).sampleSymbol()); seq.edit(e); } } return seq; }