Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
akiezun committed Apr 22, 2016
1 parent a599e38 commit 64329e1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public ArgumentsBuilder addFileArgument(String argumentName, File file){
}

/**
* add an argument with a file as its parameter
* add an argument with a boolean as its parameter
*/
public ArgumentsBuilder addBooleanArgument(String argumentName, boolean yes){
Utils.nonNull(argumentName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void identicalBamTest() throws Exception {
args.add(secondBam.getCanonicalPath());
args.add("--throwOnDiff true");
args.add("--VALIDATION_STRINGENCY SILENT");
final Object result = this.runCommandLine(args.getArgsArray());
final Object result = this.runCommandLine(args);
Assert.assertEquals(result, 0);
}

Expand Down Expand Up @@ -63,7 +63,7 @@ public void singleReadDiffTest(File firstBam, File secondBam, File referenceFile
args.add(referenceFile.getAbsolutePath());
}

final Object result = this.runCommandLine(args.getArgsArray());
final Object result = this.runCommandLine(args);
if (Objects.equals(firstBam, secondBam)) {
Assert.assertEquals(result, 0);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
import java.io.File;

//Note: has to be in this package to have access to Main.instanceMain
public final class BQSRIntegrationTest extends CommandLineProgramTest {
public final class BothStepsOfBQSRIntegrationTest extends CommandLineProgramTest {

@Test //Tests that BQSR with and without indel recalibration produces the same bam file
public void testIndelRemoval() throws Exception {
//Note; using a small 27M file for speed
final File bamIn = new File(getToolTestDataDir() + "CEUTrio.HiSeq.WGS.b37.NA12878.20.bam");
final File bamIn = new File(NA12878_20_21_WGS_bam);
final String interval = "20";

final File recalOutWithIndels = baseRecalibrator(bamIn, false);
final File bamOutWithIndels = applyBQSR(bamIn, recalOutWithIndels, false);
final File recalOutWithIndels = baseRecalibrator(bamIn, interval, false);
final File bamOutWithIndels = applyBQSR(bamIn, interval, recalOutWithIndels, false);

final File recalOutWithoutIndels = baseRecalibrator(bamIn, true);
final File bamOutWithoutIndels = applyBQSR(bamIn, recalOutWithoutIndels, true);
final File recalOutWithoutIndels = baseRecalibrator(bamIn, interval, true);
final File bamOutWithoutIndels = applyBQSR(bamIn, interval, recalOutWithoutIndels, true);

final ArgumentsBuilder args1 = new ArgumentsBuilder();
args1.addArgument("VALIDATION_STRINGENCY", ValidationStringency.SILENT.name());
Expand All @@ -33,22 +34,24 @@ public void testIndelRemoval() throws Exception {
Assert.assertEquals(result, 0);
}

private File applyBQSR(final File bamIn, final File recalOut, final boolean skipIndels) {
private File applyBQSR(final File bamIn, final String interval, final File recalOut, final boolean skipIndels) {
final File bamOut = BaseTest.createTempFile("applyBQSR." + skipIndels, ".bam");
final ArgumentsBuilder args1 = new ArgumentsBuilder();
args1.addInput(bamIn);
args1.addFileArgument("bqsr", recalOut);
args1.addArgument("L", interval);
args1.addOutput(bamOut);
new Main().instanceMain(makeCommandLineArgs(args1.getArgsList(), ApplyBQSR.class.getSimpleName()));
return bamOut;
}

private File baseRecalibrator(final File bamIn, final boolean skipIndels) {
private File baseRecalibrator(final File bamIn, final String interval, final boolean skipIndels) {
final File recalOut = BaseTest.createTempFile("baseRecalibrator." + skipIndels, ".recal");

final ArgumentsBuilder args1 = new ArgumentsBuilder();
args1.addInput(bamIn);
args1.addOutput(recalOut);
args1.addArgument("L", interval);
args1.addFileArgument("knownSites", new File(dbsnp_138_b37_20_21_vcf));
args1.addReference(new File(b37_reference_20_21));
args1.addBooleanArgument("skipIndelBQSR", skipIndels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public void testArgumentsBuilder() {
args.add("--value1");
args.add(1);
args.add("Input=")
.add(new File("/path/to/somewhere"))
.add(new File("path/to/somewhere"))
.add("Value2=2")
.add(" Value3= 3 Value4=4");

Assert.assertEquals(args.getArgsArray(), new String[]{"--value1", "1",
"--Input", "/path/to/somewhere","--Value2","2","--Value3","3","--Value4","4"});
"--Input", "path/to/somewhere","--Value2","2","--Value3","3","--Value4","4"});
}
@Test
public void testOneBigString(){
Expand All @@ -31,8 +31,8 @@ public void testOneBigString(){

@Test
public void testFromArray(){
ArgumentsBuilder args = new ArgumentsBuilder(new Object[]{"Option=" + new File("/path/to"), "OtherOption=" + -1, new File("/somewhere")});
Assert.assertEquals(args.getArgsArray(), new String[]{"--Option","/path/to", "--OtherOption", "-1", "/somewhere"});
ArgumentsBuilder args = new ArgumentsBuilder(new Object[]{"Option=" + new File("path/to"), "OtherOption=" + -1, new File("somewhere")});
Assert.assertEquals(args.getArgsArray(), new String[]{"--Option","path/to", "--OtherOption", "-1", "somewhere"});
}

@Test
Expand Down Expand Up @@ -62,41 +62,41 @@ public void testAddBooleanArgument() throws Exception {
@Test
public void testAddFileArgument() throws Exception {
ArgumentsBuilder args = new ArgumentsBuilder();
File file = new File("/path/to/somewhere");
File file = new File("path/to/somewhere");
args.addFileArgument("foo", file);
Assert.assertEquals(args.getArgsArray(), new String[]{"--foo", file.toString()});
Assert.assertEquals(args.getArgsArray(), new String[]{"--foo", file.getAbsolutePath()});
}

@Test
public void testInput() throws Exception {
ArgumentsBuilder args = new ArgumentsBuilder();
File file = new File("/path/to/somewhere");
File file = new File("path/to/somewhere");
args.addInput(file);
Assert.assertEquals(args.getArgsArray(), new String[]{"--" + StandardArgumentDefinitions.INPUT_LONG_NAME, file.toString()});
Assert.assertEquals(args.getArgsArray(), new String[]{"--" + StandardArgumentDefinitions.INPUT_LONG_NAME, file.getAbsolutePath()});
}

@Test
public void testOutput() throws Exception {
ArgumentsBuilder args = new ArgumentsBuilder();
File file = new File("/path/to/somewhere");
File file = new File("path/to/somewhere");
args.addOutput(file);
Assert.assertEquals(args.getArgsArray(), new String[]{"--" + StandardArgumentDefinitions.OUTPUT_LONG_NAME, file.toString()});
Assert.assertEquals(args.getArgsArray(), new String[]{"--" + StandardArgumentDefinitions.OUTPUT_LONG_NAME, file.getAbsolutePath()});
}

@Test
public void testReference() throws Exception {
ArgumentsBuilder args = new ArgumentsBuilder();
File file = new File("/path/to/somewhere");
File file = new File("path/to/somewhere");
args.addReference(file);
Assert.assertEquals(args.getArgsArray(), new String[]{"--" + StandardArgumentDefinitions.REFERENCE_LONG_NAME, file.toString()});
Assert.assertEquals(args.getArgsArray(), new String[]{"--" + StandardArgumentDefinitions.REFERENCE_LONG_NAME, file.getAbsolutePath()});
}

@Test
public void testVcf() throws Exception {
ArgumentsBuilder args = new ArgumentsBuilder();
File file = new File("/path/to/somewhere");
File file = new File("path/to/somewhere");
args.addVCF(file);
Assert.assertEquals(args.getArgsArray(), new String[]{"--" + StandardArgumentDefinitions.VARIANT_LONG_NAME, file.toString()});
Assert.assertEquals(args.getArgsArray(), new String[]{"--" + StandardArgumentDefinitions.VARIANT_LONG_NAME, file.getAbsolutePath()});
}

}
Binary file not shown.

0 comments on commit 64329e1

Please sign in to comment.