Skip to content

Commit

Permalink
Fixes divide by zero events on the study view page
Browse files Browse the repository at this point in the history
  • Loading branch information
n1zea144 committed Jan 3, 2022
1 parent d7b33c5 commit ad8f6f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ public void calculate(List<T> alterationCounts,
alterationCountByGene.setNumberOfProfiledCases(totalProfiledSamples);
}
} else {
alterationCountByGene.setNumberOfProfiledCases(casesWithoutPanelData.size());
// we use profiledCasesCount instead of casesWithoutPanelData to
// prevent a divide by zero error which can happen for targeted studies
// in which certain genes have events that are not captured by the panel.
alterationCountByGene.setNumberOfProfiledCases(profiledCasesCount);
}
alterationCountByGene.setMatchingGenePanelIds(allMatchingGenePanelIds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,21 @@ public void calculate() throws Exception {

Assert.assertEquals(Integer.valueOf(3), alterationCounts.get(0).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(2), alterationCounts.get(1).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(1), alterationCounts.get(2).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(3), alterationCounts.get(2).getNumberOfProfiledCases());


profiledSamplesCounter.calculate(alterationCounts, genePanelDataList, false, profiledSamplesCounter.patientUniqueIdentifier);

Assert.assertEquals(Integer.valueOf(2), alterationCounts.get(0).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(2), alterationCounts.get(1).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(1), alterationCounts.get(2).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(2), alterationCounts.get(2).getNumberOfProfiledCases());

profiledSamplesCounter.calculate(alterationCounts, genePanelDataList, true, profiledSamplesCounter.patientUniqueIdentifier);

Assert.assertEquals(4, alterationCounts.size());
Assert.assertEquals(Integer.valueOf(2), alterationCounts.get(0).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(2), alterationCounts.get(1).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(1), alterationCounts.get(2).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(2), alterationCounts.get(2).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(2), alterationCounts.get(3).getNumberOfProfiledCases());
Assert.assertEquals(Integer.valueOf(4), alterationCounts.get(3).getEntrezGeneId());

Expand Down

0 comments on commit ad8f6f5

Please sign in to comment.