Search in sources :

Example 11 with Well44497b

use of org.apache.commons.math3.random.Well44497b 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));
        }
    }
}
Also used : CachedSequenceProvider(com.milaboratory.core.sequence.provider.CachedSequenceProvider) SequenceProvider(com.milaboratory.core.sequence.provider.SequenceProvider) Well44497b(org.apache.commons.math3.random.Well44497b) Range(com.milaboratory.core.Range)

Aggregations

Well44497b (org.apache.commons.math3.random.Well44497b)11 NucleotideSequence (com.milaboratory.core.sequence.NucleotideSequence)5 Test (org.junit.Test)5 VDJCAlignments (com.milaboratory.mixcr.basictypes.VDJCAlignments)4 TargetBuilder (com.milaboratory.mixcr.tests.TargetBuilder)3 VDJCAlignerParameters (com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters)3 RandomGenerator (org.apache.commons.math3.random.RandomGenerator)3 PartialAlignmentsAssemblerAligner (com.milaboratory.mixcr.partialassembler.PartialAlignmentsAssemblerAligner)2 VDJCMultiRead (com.milaboratory.mixcr.partialassembler.VDJCMultiRead)2 VDJCLibrary (io.repseq.core.VDJCLibrary)2 Point (java.awt.Point)2 CUtils (cc.redberry.pipe.CUtils)1 Range (com.milaboratory.core.Range)1 PairedRead (com.milaboratory.core.io.sequence.PairedRead)1 SequenceRead (com.milaboratory.core.io.sequence.SequenceRead)1 SequenceReaderCloseable (com.milaboratory.core.io.sequence.SequenceReaderCloseable)1 SingleReadImpl (com.milaboratory.core.io.sequence.SingleReadImpl)1 NSequenceWithQuality (com.milaboratory.core.sequence.NSequenceWithQuality)1 SequenceQuality (com.milaboratory.core.sequence.SequenceQuality)1 CachedSequenceProvider (com.milaboratory.core.sequence.provider.CachedSequenceProvider)1