use of com.milaboratory.core.sequence.provider.SequenceProvider in project repseqio by repseqio.
the class ConcatenatedLazySequenceTest method testRandom0.
public <S extends Sequence<S>> void testRandom0(Alphabet<S> alphabet) throws Exception {
Well44497b w = new Well44497b();
S sequence = alphabet.getEmptySequence();
SequenceProvider<S>[] providers = new SequenceProvider[100];
for (int i = 0; i < 100; i++) {
final S seq = TestUtil.randomSequence(alphabet, 0, 200);
sequence = sequence.concatenate(seq);
providers[i] = SequenceProviderUtils.fromSequence(seq);
ConcatenatedLazySequence<S> sProvider = new ConcatenatedLazySequence<>(Arrays.copyOf(providers, i + 1));
if (sequence.size() == 0)
continue;
for (int j = 0; j < 10; j++) {
int from = sequence.size() == 1 ? 0 : w.nextInt(sequence.size() - 1);
int to = (sequence.size() - from) == 0 ? from : from + w.nextInt(sequence.size() - from);
Range r = new Range(from, to);
if (r.isEmpty())
continue;
assertEquals(sequence.getRange(r), sProvider.getRegion(r));
}
}
}
Aggregations