-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests and further refactors, note that I've disovered a potent…
…ial bug, see the todo in the tests
- Loading branch information
1 parent
63593fc
commit 1df4aa2
Showing
4 changed files
with
96 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* | ||
* @author Samuel Lee <[email protected]> | ||
*/ | ||
public final class SimpleCount implements Locatable, Feature { | ||
public class SimpleCount implements Locatable, Feature { | ||
|
||
private final SimpleInterval interval; | ||
private final int count; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...institute/hellbender/tools/walkers/haplotypecaller/MultiPloidyGenotyperCacheUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.broadinstitute.hellbender.tools.walkers.haplotypecaller; | ||
|
||
import htsjdk.samtools.util.OverlapDetector; | ||
import org.broadinstitute.hellbender.GATKBaseTest; | ||
import org.broadinstitute.hellbender.tools.copynumber.formats.records.SimpleCount; | ||
import org.broadinstitute.hellbender.tools.walkers.genotyper.MinimalGenotypingEngine; | ||
import org.broadinstitute.hellbender.tools.walkers.genotyper.StandardCallerArgumentCollection; | ||
import org.broadinstitute.hellbender.utils.SimpleInterval; | ||
import org.broadinstitute.hellbender.utils.genotyper.SampleList; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.testng.Assert; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.testng.Assert.*; | ||
|
||
public class MultiPloidyGenotyperCacheUnitTest extends GATKBaseTest { | ||
|
||
|
||
@DataProvider | ||
public static Object[][] getGenotyperParams() { | ||
return new Object[][]{ | ||
{"1:10-30", 2}, | ||
{"1:70-85", 3}, | ||
{"1:80-93", 3}, | ||
// {"1:89-92", 2}, TODO is this a bug? | ||
{"1:90-95", 1}, | ||
{"1:85-120", 5}, | ||
{"2:200", 2}, | ||
{"2:1-500", 4} | ||
}; | ||
} | ||
|
||
@Test(dataProvider = "getGenotyperParams") | ||
public void testGettingGenotypers(String interval, int expectedPloidy){ | ||
final var detector = getOverlapDetector(); | ||
final MultiPloidyGenotyperCache<MinimalGenotypingEngine> genotypingCache = new MultiPloidyGenotyperCache<>(this::getEngine, 2, detector); | ||
final MinimalGenotypingEngine genotypingEngine = genotypingCache.getGenotypingEngine(new SimpleInterval(interval)); | ||
Assert.assertEquals(genotypingEngine.getGenotypeArgs().samplePloidy, expectedPloidy); | ||
} | ||
|
||
@NotNull | ||
private OverlapDetector<SimpleCount> getOverlapDetector() { | ||
final var counts = List.of( | ||
getCount("1:80", 3), | ||
getCount("1:90-95", 1), | ||
getCount("1:100-110", 5), | ||
getCount("2:85-90", 4)); | ||
return OverlapDetector.create(counts); | ||
} | ||
|
||
@Test | ||
public void testReturnsTheSameGenotyper(){ | ||
final var detector = getOverlapDetector(); | ||
final MultiPloidyGenotyperCache<MinimalGenotypingEngine> genotypingCache = new MultiPloidyGenotyperCache<>(this::getEngine, 2, detector); | ||
final MinimalGenotypingEngine genotypingEngine = genotypingCache.getGenotypingEngine(new SimpleInterval("1:10-20")); | ||
final MinimalGenotypingEngine genotypingEngine2 = genotypingCache.getGenotypingEngine(new SimpleInterval("2:10-20")); | ||
Assert.assertSame(genotypingEngine, genotypingEngine2); | ||
} | ||
|
||
|
||
private MinimalGenotypingEngine getEngine(int ploidy){ | ||
final var args = new StandardCallerArgumentCollection(); | ||
args.genotypeArgs.samplePloidy = ploidy; | ||
final var samples = SampleList.singletonSampleList("sample1"); | ||
return new MinimalGenotypingEngine(args, samples); | ||
} | ||
|
||
private static SimpleCount getCount(String location, int count){ | ||
return new SimpleCount(new SimpleInterval(location), count); | ||
} | ||
|
||
} |