use of org.apache.commons.math3.random.Well44497a in project repseqio by repseqio.
the class GeneFeatureTest method testRandom1.
@Test
public void testRandom1() {
Well44497a rand = new Well44497a();
int tn = BasicReferencePoint.TOTAL_NUMBER_OF_BASIC_REFERENCE_POINTS;
for (int baseBlock = 2; baseBlock < 5; ++baseBlock) for (int t = 0; t < 1000; ++t) {
int[] all = new int[tn];
ArrayList<GeneFeature> features = new ArrayList<>();
int begin, end = 0;
do {
begin = end + rand.nextInt(baseBlock);
end = begin + 1 + rand.nextInt(baseBlock);
if (end >= tn)
break;
Arrays.fill(all, begin, end, 1);
features.add(create(begin, end));
} while (end < tn);
IntArrayList expectedPoints = new IntArrayList();
if (all[0] == 1)
expectedPoints.add(0);
for (int i = 1; i < tn; ++i) if (all[i] != all[i - 1])
expectedPoints.add(i);
if (all[tn - 1] == 1)
expectedPoints.add(tn);
GeneFeature actual = new GeneFeature(features.toArray(new GeneFeature[features.size()]));
assertEquals(create(expectedPoints.toArray()), actual);
assertEquals(expectedPoints.size() / 2, actual.regions.length);
}
}
Aggregations