Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasoifer committed May 24, 2023
1 parent d3c1678 commit 6af743a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void testVCFModeIsConsistentWithPastResults(final String inputFileName, f
/*
* Test that minimap2 data are supported and consistent with past results
*/
@Test
public void testVCFModeMinimap2IsConsistentWithPastResults() throws Exception {
final String inputFileName = NA12878_20_21_WGS_mmp2_bam;
final String referenceFileName = b37_reference_20_21;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void testNonFlowReadGroupParsing(){
FlowBasedReadUtils.ReadGroupInfo frg1 = FlowBasedReadUtils.getReadGroupInfo(header, gread);
assert(!frg1.isFlowPlatform);
}

private GATKRead makeRead(final byte[] bases, final boolean isReverse) {

byte[] quals = new byte[bases.length];
Expand All @@ -70,36 +71,6 @@ private GATKRead makeRead(final byte[] bases, final boolean isReverse) {
return read;
}

@Test (dataProvider = "makeReads")
public void testUncertainFlowTrimming(final GATKRead read, int nTrim, String uncertainFlowBase, final byte[] output, final int start, final int end) {
FlowBasedArgumentCollection fbargs = new FlowBasedArgumentCollection();
fbargs.flowNumUncertainFlows = nTrim;
fbargs.flowFirstUncertainFlowBase = uncertainFlowBase;
GATKRead trimmedRead = FlowBasedRead.hardClipUncertainBases(read, "TAGC", fbargs);
Assert.assertEquals(trimmedRead.getBases(), output);
Assert.assertEquals(trimmedRead.getStart(), start);
Assert.assertEquals(trimmedRead.getEnd(), end);
}



@Test (dataProvider = "iSFlowPlatform")
void testIsFlowPlatform(final SAMFileHeader hdr, final GATKRead read, final boolean answer){
assert(FlowBasedReadUtils.isFlowPlatform(hdr, read) == answer);
}

@Test(expectedExceptions = {RuntimeException.class})
void testMalformedUltimaRGThrowsException(){
GATKRead read = makeRead(new byte[]{'T','A','G','C','G','A'}, false);
read.setAttribute("tp",new byte[6]);
SAMReadGroupRecord rg = new SAMReadGroupRecord("rg");
rg.setPlatform("ULTIMA");
read.setReadGroup("rg");
SAMFileHeader hdr = new SAMFileHeader();
hdr.addReadGroup(rg);
FlowBasedReadUtils.isFlowPlatform(hdr, read);
}

@DataProvider(name="isFlowPlatform")
Object[][] getIsFlowPlatformInputs() {
List<Object[]> tests = new ArrayList<>();
Expand All @@ -123,7 +94,7 @@ Object[][] getIsFlowPlatformInputs() {
GATKRead read3 = makeRead(new byte[]{'T','A','G','C','G','A'}, false);
read3.setAttribute("tp",new byte[6]);
SAMReadGroupRecord rg3 = new SAMReadGroupRecord("rg3");
rg3.setPlatform("ULTIMA");
rg3.setPlatform("LS454");
read3.setReadGroup("rg3");
hdr.addReadGroup(rg3);
tests.add(new Object[]{hdr, read3, false});
Expand All @@ -139,4 +110,22 @@ Object[][] getIsFlowPlatformInputs() {

return tests.toArray(new Object[][]{});
}

@Test (dataProvider = "isFlowPlatform")
void testIsFlowPlatform(final SAMFileHeader hdr, final GATKRead read, final boolean answer){
assert(FlowBasedReadUtils.isFlowPlatform(hdr, read) == answer);
}

@Test(expectedExceptions = {RuntimeException.class})
void testMalformedUltimaRGThrowsException(){
GATKRead read = makeRead(new byte[]{'T','A','G','C','G','A'}, false);
read.setAttribute("tp",new byte[6]);
SAMReadGroupRecord rg = new SAMReadGroupRecord("rg");
rg.setPlatform("ULTIMA");
read.setReadGroup("rg");
SAMFileHeader hdr = new SAMFileHeader();
hdr.addReadGroup(rg);
FlowBasedReadUtils.isFlowPlatform(hdr, read);
}

}

0 comments on commit 6af743a

Please sign in to comment.