Loading beagleutil/Phase.javadeleted 100644 → 0 +0 −78 Original line number Diff line number Diff line /* * Copyright (C) 2014-2016 Brian L. Browning * * This file is part of Beagle * * Beagle is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Beagle is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package beagleutil; /** * <p>Class {@code Phase} represents the equivalence of two phased genotypes * for a marker or for a set of markers. Genotype equivalence is defined * in terms of allele equivalence. Two alleles are equivalent if * either allele is missing or if both alleles are non-missing and equal. * </p> * <p> * For the case of a single marker with phased (i.e. ordered) genotypes * ({@code a1}, {@code a2}) * and ({@code b1}, {@code b2}), then * <br> * 1) the genotypes have IDENTICAL phase if a) alleles {@code a1} * and {@code b1} are equivalent, b) alleles {@code a2} and * {@code b2} are equivalent, and c) either alleles {@code a1} * and {@code b2} are not equivalent or alleles * {@code a2} and {@code b1} are not equivalent. * <br> * 2) the genotypes have OPPOSITE phase if a) alleles {@code a1} * and {@code b2} are equivalent, b) alleles {@code a2} and * {@code b1} are equivalent, and c) either alleles {@code a1} * and {@code b1} are not equivalent or alleles {@code a2} and * {@code b2} are not equivalent. * <br> * 3) the genotypes have UNKOWN phase if a) alleles {@code a1} * and {@code b1} are equivalent, b) alleles {@code a2} and * {@code b2} are equivalent, c) alleles {@code a1} and * {@code b2} are equivalent, and d) alleles {@code a2} and * {@code b1} are equivalent. * <br> * 4) the genotypes have INCONSISTENT phase if a) either alleles * {@code a1} and {@code b1} are not equivalent or alleles * {@code a2} and {@code b2} are not equivalent, and * b) either alleles {@code a1} and {@code b2} are not equivalent * or alleles {@code a2} and {@code b1} are not equivalent. * </p> * For the case of two sets of phased genotypes for the same markers, * the two sets have * <br> * 1) IDENTICAL phase if the phase is IDENTICAL for at least * one marker and is either IDENTICAL or UNKNOWN for all markers. * <br> * 2) OPPOSITE phase if the if the phase is OPPOSITE for at * lease one marker and is either OPPOSITE or UNKNOWN for all markers. * <br> * 3) UNKNOWN phase if the phase is UNKNOWN for all markers. * <br> * 4) INCONSISTENT phase if a) the phase is INCONSISTENT for at least one * marker or if b) the relative phase is IDENTICAL for at least one marker and * OPPOSITE for at least one marker. * * @author Brian L. Browning */ public enum Phase { IDENTICAL, OPPOSITE, UNKNOWN, INCONSISTENT } blbutil/MultiThreadUtils.java 0 → 100644 +111 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014-2016 Brian L. Browning * * This file is part of Beagle * * Beagle is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Beagle is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package blbutil; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; /** * Class {@code Utilities} contains miscellaneous static utility methods * for multi-threaded programming. * * @author Brian L. Browning {@code <browning@uw.edu>} */ public class MultiThreadUtils { private MultiThreadUtils() { // private constructor to prevent instantiation } /** * Inserts the specified element at the tail of the specified blocking * queue, waiting for space to become available if the queue is full. * The Java Virtual Machine is terminated if an {@code InterruptedException} * is thrown while waiting for space to be come available in the queue. * @param <E> the element type * @param q a blocking queue * @param e the element to add * @throws NullPointerException if {@code q == null || e == null} */ public static <E> void putInBlockingQ(BlockingQueue<E> q, E e) { try { q.put(e); } catch (InterruptedException ex) { Utilities.exit("ERROR: " , ex); } } /** * Removes and returns the element at the head of the specified blocking * queue, waiting if necessary for an element to become available. * The Java Virtual Machine is terminated if an {@code InterruptedException} * is thrown while waiting for space to be come available in the queue. * @param <E> the element type * @param q a blocking queue * @return the element at the head of the queue */ public static <E> E takeFromBlockingQ(BlockingQueue<E> q) { try { return q.take(); } catch (InterruptedException ex) { Utilities.exit("ERROR: " , ex); } assert false; return null; } /** * Blocks the current thread until the specified {@code CountDownLatch} * has counted down to 0. The Java Virtual Machine is terminated if an * {@code InterruptedException} is thrown while waiting for for the * {@code CountDownLatch} to count down to 0. * @param latch the count down latch * @throws NullPointerException if {@code latch == null} */ public static void await(CountDownLatch latch) { try { latch.await(); } catch (InterruptedException e) { Utilities.exit("ERROR", e); } } /** * Shuts down and awaits termination of the specified * {@code ExecutorService}. The Java Virtual Machine is terminated if an * {@code InterruptedException} is thrown while awaiting termination * of the executor service. * @param es the executor service to be shut down * @throws NullPointerException if {@code es == null} */ public static void shutdownExecService(ExecutorService es) { try { es.shutdown(); es.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); } catch (InterruptedException e) { Utilities.exit("ERROR", e); } } } blbutil/SampleFileIt.java +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ */ package blbutil; import beagleutil.Samples; import vcf.Samples; /** * <p>An iterator for records in a file. Each records contains Loading blbutil/Utilities.java +0 −1 Original line number Diff line number Diff line Loading @@ -249,7 +249,6 @@ public class Utilities { * @throws NullPointerException if {@code e == null} */ public static void exit(Throwable t) { System.out.println("ERROR: " + t); t.printStackTrace(System.out); System.exit(1); } Loading bref/AsIsBref3Writer.java +2 −2 Original line number Diff line number Diff line Loading @@ -19,11 +19,10 @@ package bref; import beagleutil.ChromIds; import beagleutil.Samples; import blbutil.FileUtil; import blbutil.Utilities; import ints.IntArray; import ints.IntList; import blbutil.Utilities; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; Loading @@ -38,6 +37,7 @@ import java.util.List; import java.util.Set; import vcf.Marker; import vcf.RefGTRec; import vcf.Samples; /** * <p>Class {@code AsIsBref3Writer} writes VCF data with phased, non-missing Loading Loading
beagleutil/Phase.javadeleted 100644 → 0 +0 −78 Original line number Diff line number Diff line /* * Copyright (C) 2014-2016 Brian L. Browning * * This file is part of Beagle * * Beagle is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Beagle is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package beagleutil; /** * <p>Class {@code Phase} represents the equivalence of two phased genotypes * for a marker or for a set of markers. Genotype equivalence is defined * in terms of allele equivalence. Two alleles are equivalent if * either allele is missing or if both alleles are non-missing and equal. * </p> * <p> * For the case of a single marker with phased (i.e. ordered) genotypes * ({@code a1}, {@code a2}) * and ({@code b1}, {@code b2}), then * <br> * 1) the genotypes have IDENTICAL phase if a) alleles {@code a1} * and {@code b1} are equivalent, b) alleles {@code a2} and * {@code b2} are equivalent, and c) either alleles {@code a1} * and {@code b2} are not equivalent or alleles * {@code a2} and {@code b1} are not equivalent. * <br> * 2) the genotypes have OPPOSITE phase if a) alleles {@code a1} * and {@code b2} are equivalent, b) alleles {@code a2} and * {@code b1} are equivalent, and c) either alleles {@code a1} * and {@code b1} are not equivalent or alleles {@code a2} and * {@code b2} are not equivalent. * <br> * 3) the genotypes have UNKOWN phase if a) alleles {@code a1} * and {@code b1} are equivalent, b) alleles {@code a2} and * {@code b2} are equivalent, c) alleles {@code a1} and * {@code b2} are equivalent, and d) alleles {@code a2} and * {@code b1} are equivalent. * <br> * 4) the genotypes have INCONSISTENT phase if a) either alleles * {@code a1} and {@code b1} are not equivalent or alleles * {@code a2} and {@code b2} are not equivalent, and * b) either alleles {@code a1} and {@code b2} are not equivalent * or alleles {@code a2} and {@code b1} are not equivalent. * </p> * For the case of two sets of phased genotypes for the same markers, * the two sets have * <br> * 1) IDENTICAL phase if the phase is IDENTICAL for at least * one marker and is either IDENTICAL or UNKNOWN for all markers. * <br> * 2) OPPOSITE phase if the if the phase is OPPOSITE for at * lease one marker and is either OPPOSITE or UNKNOWN for all markers. * <br> * 3) UNKNOWN phase if the phase is UNKNOWN for all markers. * <br> * 4) INCONSISTENT phase if a) the phase is INCONSISTENT for at least one * marker or if b) the relative phase is IDENTICAL for at least one marker and * OPPOSITE for at least one marker. * * @author Brian L. Browning */ public enum Phase { IDENTICAL, OPPOSITE, UNKNOWN, INCONSISTENT }
blbutil/MultiThreadUtils.java 0 → 100644 +111 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014-2016 Brian L. Browning * * This file is part of Beagle * * Beagle is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Beagle is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package blbutil; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; /** * Class {@code Utilities} contains miscellaneous static utility methods * for multi-threaded programming. * * @author Brian L. Browning {@code <browning@uw.edu>} */ public class MultiThreadUtils { private MultiThreadUtils() { // private constructor to prevent instantiation } /** * Inserts the specified element at the tail of the specified blocking * queue, waiting for space to become available if the queue is full. * The Java Virtual Machine is terminated if an {@code InterruptedException} * is thrown while waiting for space to be come available in the queue. * @param <E> the element type * @param q a blocking queue * @param e the element to add * @throws NullPointerException if {@code q == null || e == null} */ public static <E> void putInBlockingQ(BlockingQueue<E> q, E e) { try { q.put(e); } catch (InterruptedException ex) { Utilities.exit("ERROR: " , ex); } } /** * Removes and returns the element at the head of the specified blocking * queue, waiting if necessary for an element to become available. * The Java Virtual Machine is terminated if an {@code InterruptedException} * is thrown while waiting for space to be come available in the queue. * @param <E> the element type * @param q a blocking queue * @return the element at the head of the queue */ public static <E> E takeFromBlockingQ(BlockingQueue<E> q) { try { return q.take(); } catch (InterruptedException ex) { Utilities.exit("ERROR: " , ex); } assert false; return null; } /** * Blocks the current thread until the specified {@code CountDownLatch} * has counted down to 0. The Java Virtual Machine is terminated if an * {@code InterruptedException} is thrown while waiting for for the * {@code CountDownLatch} to count down to 0. * @param latch the count down latch * @throws NullPointerException if {@code latch == null} */ public static void await(CountDownLatch latch) { try { latch.await(); } catch (InterruptedException e) { Utilities.exit("ERROR", e); } } /** * Shuts down and awaits termination of the specified * {@code ExecutorService}. The Java Virtual Machine is terminated if an * {@code InterruptedException} is thrown while awaiting termination * of the executor service. * @param es the executor service to be shut down * @throws NullPointerException if {@code es == null} */ public static void shutdownExecService(ExecutorService es) { try { es.shutdown(); es.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); } catch (InterruptedException e) { Utilities.exit("ERROR", e); } } }
blbutil/SampleFileIt.java +1 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ */ package blbutil; import beagleutil.Samples; import vcf.Samples; /** * <p>An iterator for records in a file. Each records contains Loading
blbutil/Utilities.java +0 −1 Original line number Diff line number Diff line Loading @@ -249,7 +249,6 @@ public class Utilities { * @throws NullPointerException if {@code e == null} */ public static void exit(Throwable t) { System.out.println("ERROR: " + t); t.printStackTrace(System.out); System.exit(1); } Loading
bref/AsIsBref3Writer.java +2 −2 Original line number Diff line number Diff line Loading @@ -19,11 +19,10 @@ package bref; import beagleutil.ChromIds; import beagleutil.Samples; import blbutil.FileUtil; import blbutil.Utilities; import ints.IntArray; import ints.IntList; import blbutil.Utilities; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; Loading @@ -38,6 +37,7 @@ import java.util.List; import java.util.Set; import vcf.Marker; import vcf.RefGTRec; import vcf.Samples; /** * <p>Class {@code AsIsBref3Writer} writes VCF data with phased, non-missing Loading