/** * Creates a new {@code DuoBaum} instance. * * @param dag the directed acyclic graph that determines the transition probabilities. * @param gl the emission probabilities. * @param seed the initial random seed. * @param nCopies the number of haplotype pairs that will be sampled for each individual in a * parent-offspring duo. * @throws IllegalArgumentException if {@code nCopies<1 || * dag.markers().equals(gl.markers())==false} * @throws NullPointerException if {@code dag==null || gl==null} */ public DuoBaum(Dag dag, GL gl, long seed, int nCopies) { if (dag.markers().equals(gl.markers()) == false) { throw new IllegalArgumentException("inconsistent markers"); } if (nCopies < 1) { throw new IllegalArgumentException("nCopies<1: " + nCopies); } this.dag = dag; this.gl = gl; this.nMarkers = dag.nMarkers(); this.nCopies = nCopies; this.seed = seed; this.random = new Random(seed); this.nodeAB1 = new int[nCopies]; this.nodeA2 = new int[nCopies]; this.nodeB2 = new int[nCopies]; this.nodeValue = new double[nCopies]; this.allelesAB1 = new byte[nCopies][gl.nMarkers()]; this.allelesA2 = new byte[nCopies][gl.nMarkers()]; this.allelesB2 = new byte[nCopies][gl.nMarkers()]; int size = (int) Math.ceil(Math.sqrt(1 + 8 * dag.nMarkers()) / 2.0) + 1; this.levels = new DuoBaumLevel[size]; for (int j = 0; j < levels.length; ++j) { levels[j] = new DuoBaumLevel(dag, gl); } this.fwdNodes = new DuoNodes(); this.bwdNodes = new DuoNodes(); }