Program: 50485
Project: 50485
Buggy source:
@Test public void testChiSquare() throws MathException {
  final DifferentialExpressionCalculator deCalc=new DifferentialExpressionCalculator();
  final int numReplicates=2;
  deCalc.defineElement("String_Node_Str");
  deCalc.defineElement("String_Node_Str");
  deCalc.defineGroup("String_Node_Str");
  deCalc.defineGroup("String_Node_Str");
  deCalc.reserve(2,numReplicates * 2);
  for (int i=1; i <= numReplicates; i++) {
    deCalc.associateSampleToGroup("String_Node_Str" + i,"String_Node_Str");
    deCalc.associateSampleToGroup("String_Node_Str" + i,"String_Node_Str");
  }
  deCalc.observe("String_Node_Str","String_Node_Str",7);
  deCalc.observe("String_Node_Str","String_Node_Str",3);
  deCalc.observe("String_Node_Str","String_Node_Str",15);
  deCalc.observe("String_Node_Str","String_Node_Str",5);
  deCalc.observe("String_Node_Str","String_Node_Str",15);
  deCalc.observe("String_Node_Str","String_Node_Str",15);
  deCalc.observe("String_Node_Str","String_Node_Str",20);
  deCalc.observe("String_Node_Str","String_Node_Str",20);
  final DifferentialExpressionInfo info=new DifferentialExpressionInfo("String_Node_Str");
  final DifferentialExpressionResults results=new DifferentialExpressionResults();
  final ChiSquareTestCalculator calc=new ChiSquareTestCalculator(results);
  final NormalizationMethod normalizationMethod=new AlignedCountNormalization();
  calc.evaluate(deCalc,normalizationMethod,results,info,"String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",0.456056540250256,results.getStatistic(info,calc.statisticIds.get(0)),0.001);
  final ChiSquareTest chisquare=new ChiSquareTestImpl();
  final double[] expected={30,12};
  final long[] observed={0,100};
  double chiPValue=0;
  chiPValue=chisquare.chiSquareTest(expected,observed);
  assertTrue("String_Node_Str" + chiPValue,chiPValue < 0.001);
}

Fixed version (ground truth):
@Test public void testChiSquare() throws MathException {
  final DifferentialExpressionCalculator deCalc=new DifferentialExpressionCalculator();
  final int numReplicates=2;
  deCalc.defineElement("String_Node_Str");
  deCalc.defineElement("String_Node_Str");
  deCalc.defineGroup("String_Node_Str");
  deCalc.defineGroup("String_Node_Str");
  deCalc.reserve(2,numReplicates * 2);
  for (int i=1; i <= numReplicates; i++) {
    deCalc.associateSampleToGroup("String_Node_Str" + i,"String_Node_Str");
    deCalc.associateSampleToGroup("String_Node_Str" + i,"String_Node_Str");
  }
  deCalc.observe("String_Node_Str","String_Node_Str",7);
  deCalc.observe("String_Node_Str","String_Node_Str",3);
  deCalc.observe("String_Node_Str","String_Node_Str",15);
  deCalc.observe("String_Node_Str","String_Node_Str",5);
  deCalc.observe("String_Node_Str","String_Node_Str",15);
  deCalc.observe("String_Node_Str","String_Node_Str",15);
  deCalc.observe("String_Node_Str","String_Node_Str",20);
  deCalc.observe("String_Node_Str","String_Node_Str",20);
  final DifferentialExpressionInfo info=new DifferentialExpressionInfo("String_Node_Str");
  final DifferentialExpressionResults results=new DifferentialExpressionResults();
  final ChiSquareTestCalculator calc=new ChiSquareTestCalculator(results);
  final NormalizationMethod normalizationMethod=new AlignedCountNormalization();
  calc.evaluate(deCalc,normalizationMethod,results,info,"String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",0.456056540250256,results.getStatistic(info,calc.statisticIds.get(0)),0.001);
  final ChiSquareTest chisquare=new ChiSquareTestImpl();
  final double[] expected={30,12};
  final long[] observed={0,100};
  final double chiPValue=chisquare.chiSquareTest(expected,observed);
  assertTrue("String_Node_Str" + chiPValue,chiPValue < 0.001);
}