Program: 30654
Project: 30654
Buggy source:
@Test public void testBisulfite() throws IOException {
  File input=new File(TEST_DATA_DIR,"String_Node_Str");
  File reference=new File(TEST_DATA_DIR,"String_Node_Str");
  File outfile=File.createTempFile("String_Node_Str","String_Node_Str");
  outfile.deleteOnExit();
  int result=new CollectAlignmentSummaryMetrics().instanceMain(new String[]{"String_Node_Str" + input.getAbsolutePath(),"String_Node_Str" + outfile.getAbsolutePath(),"String_Node_Str" + reference.getAbsolutePath(),"String_Node_Str"});
  Assert.assertEquals(result,0);
  NumberFormat format=NumberFormat.getInstance();
  format.setMaximumFractionDigits(4);
  MetricsFile<AlignmentSummaryMetrics,Comparable<?>> output=new MetricsFile<AlignmentSummaryMetrics,Comparable<?>>();
  output.read(new FileReader(outfile));
  for (  AlignmentSummaryMetrics metrics : output.getMetrics()) {
    Assert.assertEquals(metrics.MEAN_READ_LENGTH,101.0);
switch (metrics.CATEGORY) {
case FIRST_OF_PAIR:
      Assert.assertEquals(metrics.TOTAL_READS,1);
    Assert.assertEquals(metrics.PF_READS,1);
  Assert.assertEquals(metrics.PF_HQ_ALIGNED_BASES,101);
Assert.assertEquals(metrics.PF_HQ_MEDIAN_MISMATCHES,20.0);
Assert.assertEquals(metrics.PF_ALIGNED_BASES,101);
Assert.assertEquals(metrics.PF_MISMATCH_RATE,20D / 100D);
Assert.assertEquals(metrics.BAD_CYCLES,20);
Assert.assertEquals(format.format(metrics.PF_HQ_ERROR_RATE),format.format(20 / (double)100));
break;
case SECOND_OF_PAIR:
Assert.assertEquals(metrics.TOTAL_READS,1);
Assert.assertEquals(metrics.PF_READS,1);
Assert.assertEquals(metrics.PF_HQ_ALIGNED_BASES,101);
Assert.assertEquals(metrics.PF_HQ_MEDIAN_MISMATCHES,3.0);
Assert.assertEquals(metrics.PF_ALIGNED_BASES,101);
Assert.assertEquals(metrics.PF_MISMATCH_RATE,0.030303);
Assert.assertEquals(metrics.BAD_CYCLES,3);
Assert.assertEquals(format.format(metrics.PF_HQ_ERROR_RATE),format.format(3 / (double)99));
break;
case PAIR:
Assert.assertEquals(metrics.TOTAL_READS,2);
Assert.assertEquals(metrics.PF_READS,2);
Assert.assertEquals(metrics.PF_HQ_ALIGNED_BASES,202);
Assert.assertEquals(metrics.PF_HQ_MEDIAN_MISMATCHES,3.0);
Assert.assertEquals(metrics.PF_ALIGNED_BASES,202);
Assert.assertEquals(metrics.PF_MISMATCH_RATE,0.115578);
Assert.assertEquals(metrics.BAD_CYCLES,23);
Assert.assertEquals(format.format(metrics.PF_HQ_ERROR_RATE),format.format(23 / (double)199));
break;
case UNPAIRED:
default :
Assert.fail("String_Node_Str" + metrics.CATEGORY);
}
}
}

Fixed version (ground truth):
@Test public void testBisulfite() throws IOException {
  File input=new File(TEST_DATA_DIR,"String_Node_Str");
  File reference=new File(TEST_DATA_DIR,"String_Node_Str");
  File outfile=File.createTempFile("String_Node_Str","String_Node_Str");
  outfile.deleteOnExit();
  int result=new CollectAlignmentSummaryMetrics().instanceMain(new String[]{"String_Node_Str" + input.getAbsolutePath(),"String_Node_Str" + outfile.getAbsolutePath(),"String_Node_Str" + reference.getAbsolutePath(),"String_Node_Str"});
  Assert.assertEquals(result,0);
  NumberFormat format=NumberFormat.getInstance();
  format.setMaximumFractionDigits(4);
  MetricsFile<AlignmentSummaryMetrics,Comparable<?>> output=new MetricsFile<AlignmentSummaryMetrics,Comparable<?>>();
  output.read(new FileReader(outfile));
  for (  AlignmentSummaryMetrics metrics : output.getMetrics()) {
    Assert.assertEquals(metrics.MEAN_READ_LENGTH,101.0);
switch (metrics.CATEGORY) {
case FIRST_OF_PAIR:
      Assert.assertEquals(metrics.TOTAL_READS,1);
    Assert.assertEquals(metrics.PF_READS,1);
  Assert.assertEquals(metrics.PF_HQ_ALIGNED_BASES,101);
Assert.assertEquals(metrics.PF_HQ_MEDIAN_MISMATCHES,20.0);
Assert.assertEquals(metrics.PF_ALIGNED_BASES,101);
Assert.assertEquals(metrics.PF_MISMATCH_RATE,20D / 100D);
Assert.assertEquals(metrics.BAD_CYCLES,20);
Assert.assertEquals(format.format(metrics.PF_HQ_ERROR_RATE),format.format(20 / (double)100));
break;
case SECOND_OF_PAIR:
Assert.assertEquals(metrics.TOTAL_READS,1);
Assert.assertEquals(metrics.PF_READS,1);
Assert.assertEquals(metrics.PF_HQ_ALIGNED_BASES,101);
Assert.assertEquals(metrics.PF_HQ_MEDIAN_MISMATCHES,3.0);
Assert.assertEquals(metrics.PF_ALIGNED_BASES,101);
Assert.assertEquals(metrics.PF_MISMATCH_RATE,0.030303);
Assert.assertEquals(metrics.BAD_CYCLES,3);
Assert.assertEquals(format.format(metrics.PF_HQ_ERROR_RATE),format.format(3 / (double)99));
break;
case PAIR:
Assert.assertEquals(metrics.TOTAL_READS,2);
Assert.assertEquals(metrics.PF_READS,2);
Assert.assertEquals(metrics.PF_HQ_ALIGNED_BASES,202);
Assert.assertEquals(metrics.PF_HQ_MEDIAN_MISMATCHES,11.5);
Assert.assertEquals(metrics.PF_ALIGNED_BASES,202);
Assert.assertEquals(metrics.PF_MISMATCH_RATE,0.115578);
Assert.assertEquals(metrics.BAD_CYCLES,23);
Assert.assertEquals(format.format(metrics.PF_HQ_ERROR_RATE),format.format(23 / (double)199));
break;
case UNPAIRED:
default :
Assert.fail("String_Node_Str" + metrics.CATEGORY);
}
}
}