Program: 50486
Project: 50486
Buggy source:
@Test public void testFisher() 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 FisherExactTestCalculator fisher=new FisherExactTestCalculator(results);
  final NormalizationMethod normalizationMethod=new AlignedCountNormalization();
  fisher.evaluate(deCalc,normalizationMethod,results,info,"String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",0.5044757698516504,results.getStatistic(info,fisher.statisticIds.get(0)),0.001);
  final Fisher fisherTest=new Fisher();
  final int totalCountInA=1700;
  final int totalCountInB=170;
  final int sumCountInA=90;
  final int sumCountInB=45;
  fisherTest.fisher(totalCountInA,sumCountInA,totalCountInA + totalCountInB,sumCountInA + sumCountInB);
  final double pValue=fisherTest.getTwotail();
  final double proportionTotalA=divide(totalCountInA,(totalCountInA + totalCountInB));
  final double proportionTotalB=divide(totalCountInB,(totalCountInA + totalCountInB));
  final ChiSquareTest chisquare=new ChiSquareTestImpl();
  final double nGroups=2;
  final double[] expected={divide(sumCountInA + sumCountInB,nGroups) * proportionTotalA * nGroups,divide(sumCountInA + sumCountInB,nGroups) * proportionTotalB * nGroups};
  final long[] observed={sumCountInA,sumCountInB};
  double chiPValue=0;
  chiPValue=Math.abs(chisquare.chiSquareTest(expected,observed));
  assertTrue("String_Node_Str" + chiPValue,chiPValue < 0.001);
}

Fixed version (ground truth):
@Test public void testFisher() 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 FisherExactTestCalculator fisher=new FisherExactTestCalculator(results);
  final NormalizationMethod normalizationMethod=new AlignedCountNormalization();
  fisher.evaluate(deCalc,normalizationMethod,results,info,"String_Node_Str","String_Node_Str");
  assertEquals("String_Node_Str",0.5044757698516504,results.getStatistic(info,fisher.statisticIds.get(0)),0.001);
  final Fisher fisherTest=new Fisher();
  final int totalCountInA=1700;
  final int totalCountInB=170;
  final int sumCountInA=90;
  final int sumCountInB=45;
  fisherTest.fisher(totalCountInA,sumCountInA,totalCountInA + totalCountInB,sumCountInA + sumCountInB);
  final double pValue=fisherTest.getTwotail();
  final double proportionTotalA=divide(totalCountInA,(totalCountInA + totalCountInB));
  final double proportionTotalB=divide(totalCountInB,(totalCountInA + totalCountInB));
  final ChiSquareTest chisquare=new ChiSquareTestImpl();
  final double nGroups=2;
  final double[] expected={divide(sumCountInA + sumCountInB,nGroups) * proportionTotalA * nGroups,divide(sumCountInA + sumCountInB,nGroups) * proportionTotalB * nGroups};
  final long[] observed={sumCountInA,sumCountInB};
  final double chiPValue=Math.abs(chisquare.chiSquareTest(expected,observed));
  assertTrue("String_Node_Str" + chiPValue,chiPValue < 0.001);
}