diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/AllelePair.java b/java/src/org/broadinstitute/sting/gatk/walkers/phasing/AllelePair.java similarity index 100% rename from java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/AllelePair.java rename to java/src/org/broadinstitute/sting/gatk/walkers/phasing/AllelePair.java diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/ReadBackedPhasingWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java similarity index 100% rename from java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/ReadBackedPhasingWalker.java rename to java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/SNPallelePair.java b/java/src/org/broadinstitute/sting/gatk/walkers/phasing/SNPallelePair.java similarity index 100% rename from java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/SNPallelePair.java rename to java/src/org/broadinstitute/sting/gatk/walkers/phasing/SNPallelePair.java diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/DisjointSet.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/DisjointSet.java deleted file mode 100644 index a46d423d3..000000000 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/DisjointSet.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.broadinstitute.sting.playground.gatk.walkers.phasing; - -import java.util.*; - -/* - * Copyright (c) 2010, The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -public class DisjointSet { - private ItemNode[] nodes; - - public DisjointSet(int numItems) { - this.nodes = new ItemNode[numItems]; - for (int i = 0; i < numItems; i++) - this.nodes[i] = new ItemNode(i); - } - - public int findSet(int itemIndex) { - // Find itemIndex's root Node: - ItemNode curNode = nodes[itemIndex]; - while (curNode.parent != null) - curNode = curNode.parent; - ItemNode root = curNode; - - // Perform path compression: - curNode = nodes[itemIndex]; - while (curNode != root) { - ItemNode next = curNode.parent; - curNode.parent = root; - curNode = next; - } - - return root.itemIndex; - } - - public boolean inSameSet(int x, int y) { - return (x == y || nodes[x].parent == nodes[y].parent || findSet(x) == findSet(y)); - } - - public Set inSameSetAs(int x, Collection testSet) { - Set sameSetInds = new TreeSet(); - - int xSet = findSet(x); - for (int t : testSet) { - if (findSet(t) == xSet) - sameSetInds.add(t); - } - return sameSetInds; - } - - public void setUnion(int x, int y) { - link(findSet(x), findSet(y)); - } - - private void link(int x, int y) { - if (x == y) - return; - - // Union by rank: - if (nodes[x].rank > nodes[y].rank) { - nodes[y].parent = nodes[x]; - } - else { // nodes[x].rank <= nodes[y].rank - nodes[x].parent = nodes[y]; - if (nodes[x].rank == nodes[y].rank) - nodes[y].rank++; - } - } - - private class ItemNode { - private int itemIndex; - private ItemNode parent; - private int rank; - - public ItemNode(int itemIndex) { - this.itemIndex = itemIndex; - this.parent = null; - this.rank = 0; - } - } -} diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/DoublyLinkedList.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/DoublyLinkedList.java deleted file mode 100644 index 154fd6f3b..000000000 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/DoublyLinkedList.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.broadinstitute.sting.playground.gatk.walkers.phasing; - -import java.util.NoSuchElementException; - -/* - * Copyright (c) 2010, The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -public class DoublyLinkedList { - private DoublyLinkedNode first; - private DoublyLinkedNode last; - private int size; - - public DoublyLinkedList() { - this.first = null; - this.last = null; - this.size = 0; - } - - public boolean isEmpty() { - return first == null; - } - - public int size() { - return size; - } - - public void addFirst(E e) { - DoublyLinkedNode newNode = new DoublyLinkedNode(e); - - if (isEmpty()) - last = newNode; - else { - first.previous = newNode; - newNode.next = first; - } - first = newNode; - - size++; - } - - public void addLast(E e) { - DoublyLinkedNode newNode = new DoublyLinkedNode(e); - - if (isEmpty()) - first = newNode; - else { - last.next = newNode; - newNode.previous = last; - } - last = newNode; - - size++; - } - - public E removeFirst() { - if (isEmpty()) - throw new NoSuchElementException(); - E e = first.element; - - if (first.next == null) - last = null; - else - first.next.previous = null; - first = first.next; - - size--; - return e; - } - - public E removeLast() { - if (isEmpty()) - throw new NoSuchElementException(); - E e = last.element; - - if (last.previous == null) - first = null; - else - last.previous.next = null; - last = last.previous; - - size--; - return e; - } - - public E getFirst() { - if (isEmpty()) - throw new NoSuchElementException(); - - return first.element; - } - - public E getLast() { - if (isEmpty()) - throw new NoSuchElementException(); - - return last.element; - } - - public E peek() { - if (isEmpty()) - return null; - - return getFirst(); - } - - public E remove() { - return removeFirst(); - } - - public boolean add(E e) { - addLast(e); - return true; - } - - public BidirectionalIterator iterator() { - return new BidirectionalIterator(this); - } - - - private static class DoublyLinkedNode { - private E element = null; - private DoublyLinkedNode next = null; - private DoublyLinkedNode previous = null; - - public DoublyLinkedNode(E element) { - this.element = element; - this.next = null; - this.previous = null; - } - } - - - public static class BidirectionalIterator implements Cloneable { - private DoublyLinkedNode nextNode; - private DoublyLinkedNode lastNode; - - private BidirectionalIterator(DoublyLinkedNode nextNode, DoublyLinkedNode lastNode) { - this.nextNode = nextNode; - this.lastNode = lastNode; - } - - private BidirectionalIterator(DoublyLinkedList list) { - this(list.first, list.last); - } - - public boolean hasNext() { - return nextNode != null; - } - - public E next() { - if (!hasNext()) - throw new NoSuchElementException(); - - E e = nextNode.element; - nextNode = nextNode.next; - return e; - } - - public boolean hasPrevious() { - if (nextNode != null) - return nextNode.previous != null; - - return lastNode != null; - } - - public E previous() { - if (!hasPrevious()) - throw new NoSuchElementException(); - - if (nextNode != null) - nextNode = nextNode.previous; - else - nextNode = lastNode; - - return nextNode.element; - } - - public BidirectionalIterator clone() { - try { - super.clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - return new BidirectionalIterator(nextNode, lastNode); - } - } -} diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/Graph.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/Graph.java deleted file mode 100644 index dc1389be0..000000000 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/Graph.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.broadinstitute.sting.playground.gatk.walkers.phasing; - -import java.util.*; - -/* - * Copyright (c) 2010, The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -// Represents an undirected graph with no self-edges: -public class Graph implements Iterable { - private Neighbors[] adj; - - public Graph(int numVertices) { - adj = new Neighbors[numVertices]; - for (int i = 0; i < numVertices; i++) - adj[i] = new Neighbors(); - } - - public void addEdge(GraphEdge e) { - if (e.v1 == e.v2) // do not permit self-edges - return; - - adj[e.v1].addNeighbor(e); - adj[e.v2].addNeighbor(e); - } - - public void addEdges(Collection edges) { - for (GraphEdge e : edges) - addEdge(e); - } - - public void removeEdge(GraphEdge e) { - adj[e.v1].removeNeighbor(e); - adj[e.v2].removeNeighbor(e); - } - - public Collection removeAllIncidentEdges(int vertexIndex) { - Collection incidentEdges = new TreeSet(adj[vertexIndex].neighbors); // implemented GraphEdge.compareTo() - - for (GraphEdge neighbEdge : incidentEdges) { - if (vertexIndex != neighbEdge.v1) // vertexIndex == neighbEdge.v2 - adj[neighbEdge.v1].removeNeighbor(neighbEdge); - else if (vertexIndex != neighbEdge.v2) // vertexIndex == neighbEdge.v1 - adj[neighbEdge.v2].removeNeighbor(neighbEdge); - } - adj[vertexIndex].clearAllNeighbors(); - - return incidentEdges; - } - - public DisjointSet getConnectedComponents() { - DisjointSet cc = new DisjointSet(adj.length); - - for (GraphEdge e : this) - cc.setUnion(e.v1, e.v2); - - return cc; - } - - public Iterator iterator() { - return new AllEdgesIterator(); - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < adj.length; i++) { - sb.append(i + ":"); - for (GraphEdge e : adj[i]) { - sb.append(" " + (e.v1 == i ? e.v2 : e.v1)); - } - sb.append("\n"); - } - - return sb.toString(); - } - - private class AllEdgesIterator implements Iterator { - private int curInd; - private Iterator innerIt; - private GraphEdge nextEdge; - - public AllEdgesIterator() { - curInd = 0; - innerIt = null; - nextEdge = null; - } - - public boolean hasNext() { - if (nextEdge != null) - return true; - - for (; curInd < adj.length; curInd++) { - if (innerIt == null) - innerIt = adj[curInd].iterator(); - - while (innerIt.hasNext()) { - GraphEdge e = innerIt.next(); - if (e.v1 == curInd) { // only want to see each edge once - nextEdge = e; - return true; - } - } - - innerIt = null; - } - - return false; - } - - public GraphEdge next() { - if (!hasNext()) - throw new NoSuchElementException(); - - GraphEdge tmpEdge = nextEdge; - nextEdge = null; - return tmpEdge; - } - - public void remove() { - throw new UnsupportedOperationException(); - } - } - - private class Neighbors implements Iterable { - private Set neighbors; - - public Neighbors() { - this.neighbors = new TreeSet(); // implemented GraphEdge.compareTo() - } - - public void addNeighbor(GraphEdge e) { - neighbors.add(e); - } - - public void removeNeighbor(GraphEdge e) { - neighbors.remove(e); - } - - public Iterator iterator() { - return neighbors.iterator(); - } - - public void clearAllNeighbors() { - neighbors.clear(); - } - } -} diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/GraphEdge.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/GraphEdge.java deleted file mode 100644 index 0170d476d..000000000 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/phasing/GraphEdge.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.broadinstitute.sting.playground.gatk.walkers.phasing; - -/* - * Copyright (c) 2010, The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -public class GraphEdge implements Comparable { - protected int v1; - protected int v2; - - public GraphEdge(int v1, int v2) { - this.v1 = v1; - this.v2 = v2; - } - - public int getV1() { - return v1; - } - - public int getV2() { - return v2; - } - - public int compareTo(GraphEdge that) { - if (this.v1 != that.v1) - return (this.v1 - that.v1); - - // this.v1 == that.v1: - return (this.v2 - that.v2); - } - - public boolean equals(GraphEdge other) { - return (this.compareTo(other) == 0); - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("(").append(v1).append(", ").append(v2).append(")"); - return sb.toString(); - } -}