Rename Utils to GraphUtils to avoid conflicts with the sting.Utils class; fix broken unit test in SharedVertexSequenceSplitterUnitTest

This commit is contained in:
Mark DePristo 2013-04-04 10:24:12 -04:00
parent 15461567d7
commit 5545c629f5
6 changed files with 14 additions and 14 deletions

View File

@ -48,7 +48,6 @@ package org.broadinstitute.sting.gatk.walkers.haplotypecaller.graphs;
import com.google.java.contract.Requires; import com.google.java.contract.Requires;
import java.io.File;
import java.util.*; import java.util.*;
/** /**
@ -177,9 +176,9 @@ public class CommonSuffixSplitter {
*/ */
@Requires("!middleVertices.isEmpty()") @Requires("!middleVertices.isEmpty()")
protected static SeqVertex commonSuffix(final Collection<SeqVertex> middleVertices) { protected static SeqVertex commonSuffix(final Collection<SeqVertex> middleVertices) {
final List<byte[]> kmers = Utils.getKmers(middleVertices); final List<byte[]> kmers = GraphUtils.getKmers(middleVertices);
final int min = Utils.minKmerLength(kmers); final int min = GraphUtils.minKmerLength(kmers);
final int suffixLen = Utils.compSuffixLen(kmers, min); final int suffixLen = GraphUtils.compSuffixLen(kmers, min);
final byte[] kmer = kmers.get(0); final byte[] kmer = kmers.get(0);
final byte[] suffix = Arrays.copyOfRange(kmer, kmer.length - suffixLen, kmer.length); final byte[] suffix = Arrays.copyOfRange(kmer, kmer.length - suffixLen, kmer.length);
return new SeqVertex(suffix); return new SeqVertex(suffix);

View File

@ -60,8 +60,8 @@ import java.util.List;
* Date: 3/25/13 * Date: 3/25/13
* Time: 9:42 PM * Time: 9:42 PM
*/ */
final class Utils { final class GraphUtils {
private Utils() {} private GraphUtils() {}
/** /**
* Compute the maximum shared prefix length of list of bytes. * Compute the maximum shared prefix length of list of bytes.

View File

@ -70,7 +70,7 @@ public final class SeqGraph extends BaseGraph<SeqVertex> {
* merging inappropriate head or tail nodes, which introduces large insertion / deletion events * merging inappropriate head or tail nodes, which introduces large insertion / deletion events
* as the merge operation creates a link among the non-linked sink / source vertices * as the merge operation creates a link among the non-linked sink / source vertices
*/ */
private final static int MIN_COMMON_SEQUENCE_TO_MERGE_SOURCE_SINK_VERTICES = 10; protected final static int MIN_COMMON_SEQUENCE_TO_MERGE_SOURCE_SINK_VERTICES = 10;
/** /**
* Construct an empty SeqGraph * Construct an empty SeqGraph

View File

@ -295,8 +295,8 @@ public class SharedVertexSequenceSplitter {
min = Math.min(min, v.getSequence().length); min = Math.min(min, v.getSequence().length);
} }
final int prefixLen = Utils.compPrefixLen(kmers, min); final int prefixLen = GraphUtils.compPrefixLen(kmers, min);
final int suffixLen = Utils.compSuffixLen(kmers, min - prefixLen); final int suffixLen = GraphUtils.compSuffixLen(kmers, min - prefixLen);
final byte[] kmer = kmers.get(0); final byte[] kmer = kmers.get(0);
final byte[] prefix = Arrays.copyOfRange(kmer, 0, prefixLen); final byte[] prefix = Arrays.copyOfRange(kmer, 0, prefixLen);

View File

@ -47,6 +47,7 @@
package org.broadinstitute.sting.gatk.walkers.haplotypecaller.graphs; package org.broadinstitute.sting.gatk.walkers.haplotypecaller.graphs;
import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.BaseTest;
import org.broadinstitute.sting.utils.Utils;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -195,8 +196,8 @@ public class SeqGraphUnitTest extends BaseTest {
final SeqGraph graph = new SeqGraph(); final SeqGraph graph = new SeqGraph();
SeqVertex pre1 = new SeqVertex("ACT"); SeqVertex pre1 = new SeqVertex(Utils.dupString("A", SeqGraph.MIN_COMMON_SEQUENCE_TO_MERGE_SOURCE_SINK_VERTICES) + "CT");
SeqVertex pre2 = new SeqVertex("AGT"); SeqVertex pre2 = new SeqVertex(Utils.dupString("A", SeqGraph.MIN_COMMON_SEQUENCE_TO_MERGE_SOURCE_SINK_VERTICES) + "GT");
SeqVertex top = new SeqVertex("A"); SeqVertex top = new SeqVertex("A");
SeqVertex middle1 = new SeqVertex("GC"); SeqVertex middle1 = new SeqVertex("GC");
SeqVertex middle2 = new SeqVertex("TC"); SeqVertex middle2 = new SeqVertex("TC");
@ -282,7 +283,7 @@ public class SeqGraphUnitTest extends BaseTest {
final SeqVertex newMiddle1 = new SeqVertex("G"); final SeqVertex newMiddle1 = new SeqVertex("G");
final SeqVertex newMiddle2 = new SeqVertex("T"); final SeqVertex newMiddle2 = new SeqVertex("T");
final SeqVertex newBottom = new SeqVertex("C" + bottom.getSequenceString()); final SeqVertex newBottom = new SeqVertex("C" + bottom.getSequenceString());
final SeqVertex newTop = new SeqVertex("A"); final SeqVertex newTop = new SeqVertex(Utils.dupString("A", SeqGraph.MIN_COMMON_SEQUENCE_TO_MERGE_SOURCE_SINK_VERTICES));
final SeqVertex newTopDown1 = new SeqVertex("G"); final SeqVertex newTopDown1 = new SeqVertex("G");
final SeqVertex newTopDown2 = new SeqVertex("C"); final SeqVertex newTopDown2 = new SeqVertex("C");
final SeqVertex newTopBottomMerged = new SeqVertex("TA"); final SeqVertex newTopBottomMerged = new SeqVertex("TA");

View File

@ -98,10 +98,10 @@ public class SharedVertexSequenceSplitterUnitTest extends BaseTest {
min = Math.min(min, s.length()); min = Math.min(min, s.length());
} }
final int actualPrefixLen = org.broadinstitute.sting.gatk.walkers.haplotypecaller.graphs.Utils.compPrefixLen(bytes, min); final int actualPrefixLen = GraphUtils.compPrefixLen(bytes, min);
Assert.assertEquals(actualPrefixLen, expectedPrefixLen, "Failed prefix test"); Assert.assertEquals(actualPrefixLen, expectedPrefixLen, "Failed prefix test");
final int actualSuffixLen = org.broadinstitute.sting.gatk.walkers.haplotypecaller.graphs.Utils.compSuffixLen(bytes, min - actualPrefixLen); final int actualSuffixLen = GraphUtils.compSuffixLen(bytes, min - actualPrefixLen);
Assert.assertEquals(actualSuffixLen, expectedSuffixLen, "Failed suffix test"); Assert.assertEquals(actualSuffixLen, expectedSuffixLen, "Failed suffix test");
} }