diff --git a/src/main/java/BiGpairSEQ.java b/src/main/java/BiGpairSEQ.java index 25d4050..eab7c2a 100644 --- a/src/main/java/BiGpairSEQ.java +++ b/src/main/java/BiGpairSEQ.java @@ -1,11 +1,13 @@ +import java.util.Random; + //main class. For choosing interface type and caching file data public class BiGpairSEQ { + private static final Random rand = new Random(); private static CellSample cellSampleInMemory = null; private static String cellFilename = null; private static Plate plateInMemory = null; private static String plateFilename = null; - private static GraphWithMapData graphInMemory = null; private static String graphFilename = null; @@ -20,6 +22,10 @@ public class BiGpairSEQ { } } + public static Random getRand() { + return rand; + } + public static CellSample getCellSampleInMemory() { return cellSampleInMemory; } diff --git a/src/main/java/Equations.java b/src/main/java/Equations.java index 26fc56e..f7c508d 100644 --- a/src/main/java/Equations.java +++ b/src/main/java/Equations.java @@ -4,10 +4,6 @@ import java.math.MathContext; public abstract class Equations { - public static int getRandomInt(int min, int max) { - return (int) ((Math.random() * (max - min)) + min); - } - //pValue calculation as described in original pairSEQ paper. //Included for comparison with original results. //Not used by BiGpairSEQ for matching. diff --git a/src/main/java/InteractiveInterface.java b/src/main/java/InteractiveInterface.java index 7c90b46..655c445 100644 --- a/src/main/java/InteractiveInterface.java +++ b/src/main/java/InteractiveInterface.java @@ -1,17 +1,15 @@ import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Scanner; -import java.util.InputMismatchException; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; // public class InteractiveInterface { - final static Scanner sc = new Scanner(System.in); - static int input; - static boolean quit = false; + private static final Random rand = BiGpairSEQ.getRand(); + private static final Scanner sc = new Scanner(System.in); + private static int input; + private static boolean quit = false; public static void startInteractive() { @@ -169,10 +167,11 @@ public class InteractiveInterface { if(maxPop < minPop) { throw new InputMismatchException("Max well population must be greater than min well population"); } - populations = new Integer[numSections]; - for(int i = 0; i < numSections; i++) { - populations[i] = Equations.getRandomInt(minPop, maxPop); - } + //maximum should be inclusive, so need to add one to max of randomly generated values + populations = (Integer[]) rand.ints(minPop, maxPop + 1) + .limit(numSections) + .boxed() + .toArray(); System.out.print("Populations: "); System.out.println(Arrays.toString(populations)); } diff --git a/src/main/java/Plate.java b/src/main/java/Plate.java index 3369d65..5a13eff 100644 --- a/src/main/java/Plate.java +++ b/src/main/java/Plate.java @@ -10,7 +10,7 @@ import java.util.*; public class Plate { private String sourceFile; private List> wells; - private Random rand = new Random(); + private final Random rand = BiGpairSEQ.getRand(); private int size; private double error; private Integer[] populations;