Skip to content

Commit

Permalink
Merge pull request #128 from KPMP/KPMP-5178_fix_biomarker_counts
Browse files Browse the repository at this point in the history
KPMP-5178: added query to fetch biomarker counts
  • Loading branch information
rlreamy authored Mar 5, 2024
2 parents 42f1d2e + 0440874 commit 6879957
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 32 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/kpmp/dataSummary/DataSummaryRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public interface DataSummaryRepository extends CrudRepository<DataSummaryValue,
@Cacheable("repoDataSummaryCount")
@Query(value = "select count(distinct(dl_file_id)) from repo_file_v where experimental_strategy = :exp_strat and tissue_type = :tissue_type", nativeQuery = true)
Long getRepoDataSummaryCount(@Param("tissue_type") String tissue_type, @Param("exp_strat") String exp_strat);

@Cacheable("repoBiomarkerSummaryCount")
@Query(value = "select count(distinct(dl_file_id)) from repo_file_v where data_category = 'Biomarker' and tissue_type = :tissue_type", nativeQuery = true)
Long getRepoBiomarkerSummaryCount(@Param("tissue_type") String tissue_type);

@Cacheable("dataSummaryLinkCount")
@Query(value = "select count(distinct(redcap_id)) " + "from sv_link_v " + "where data_type = :data_type "
Expand Down
72 changes: 48 additions & 24 deletions src/main/java/org/kpmp/dataSummary/DataSummaryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,54 @@ private AtlasRepositoryLinkInformation getLinkInformation(ExperimentalStrategyVa

private void setCounts(ExperimentalStrategyValue experimentalStrategyValue, AtlasRepoSummaryRow atlasRepoSummaryRow)
throws Exception {
atlasRepoSummaryRow.setAkiCount(
dataSummaryRepository.getRepoDataSummaryCount(
TissueTypeEnum.AKI.getParticipantTissueType(),
experimentalStrategyValue.getExperimentalStrategy()
)
);
atlasRepoSummaryRow.setCkdCount(
dataSummaryRepository.getRepoDataSummaryCount(
TissueTypeEnum.CKD.getParticipantTissueType(),
experimentalStrategyValue.getExperimentalStrategy()
)
);
atlasRepoSummaryRow.setHrtCount(
dataSummaryRepository.getRepoDataSummaryCount(
TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType(),
experimentalStrategyValue.getExperimentalStrategy()
)
);
atlasRepoSummaryRow.setDmrCount(
dataSummaryRepository.getRepoDataSummaryCount(
TissueTypeEnum.DMR.getParticipantTissueType(),
experimentalStrategyValue.getExperimentalStrategy()
)
);
if (experimentalStrategyValue.getDataCategory().equalsIgnoreCase(BIOMARKER)) {
atlasRepoSummaryRow.setAkiCount(
dataSummaryRepository.getRepoBiomarkerSummaryCount(
TissueTypeEnum.AKI.getParticipantTissueType()
)
);
atlasRepoSummaryRow.setCkdCount(
dataSummaryRepository.getRepoBiomarkerSummaryCount(
TissueTypeEnum.CKD.getParticipantTissueType()
)
);
atlasRepoSummaryRow.setHrtCount(
dataSummaryRepository.getRepoBiomarkerSummaryCount(
TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType()
)
);
atlasRepoSummaryRow.setDmrCount(
dataSummaryRepository.getRepoBiomarkerSummaryCount(
TissueTypeEnum.DMR.getParticipantTissueType()
)
);
}
else {
atlasRepoSummaryRow.setAkiCount(
dataSummaryRepository.getRepoDataSummaryCount(
TissueTypeEnum.AKI.getParticipantTissueType(),
experimentalStrategyValue.getExperimentalStrategy()
)
);
atlasRepoSummaryRow.setCkdCount(
dataSummaryRepository.getRepoDataSummaryCount(
TissueTypeEnum.CKD.getParticipantTissueType(),
experimentalStrategyValue.getExperimentalStrategy()
)
);
atlasRepoSummaryRow.setHrtCount(
dataSummaryRepository.getRepoDataSummaryCount(
TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType(),
experimentalStrategyValue.getExperimentalStrategy()
)
);
atlasRepoSummaryRow.setDmrCount(
dataSummaryRepository.getRepoDataSummaryCount(
TissueTypeEnum.DMR.getParticipantTissueType(),
experimentalStrategyValue.getExperimentalStrategy()
)
);
}
}

public List<DataTypeSummary> getSummaryData() {
Expand Down
12 changes: 4 additions & 8 deletions src/test/java/org/kpmp/dataSummary/DataSummaryServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,10 @@ public void testGetAtlasRepoSummary() throws Exception {
strategies.get(3).setDataType("datatype");

when(atlasRepoSummaryRepository.findAll()).thenReturn(strategies);
when(dataSummaryRepository.getRepoDataSummaryCount(TissueTypeEnum.AKI.getParticipantTissueType(),
"abcd")).thenReturn(Long.valueOf(1));
when(dataSummaryRepository.getRepoDataSummaryCount(TissueTypeEnum.CKD.getParticipantTissueType(),
"abcd")).thenReturn(Long.valueOf(2));
when(dataSummaryRepository.getRepoDataSummaryCount(TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType(),
"abcd")).thenReturn(Long.valueOf(3));
when(dataSummaryRepository.getRepoDataSummaryCount(TissueTypeEnum.DMR.getParticipantTissueType(),
"abcd")).thenReturn(4l);
when(dataSummaryRepository.getRepoBiomarkerSummaryCount(TissueTypeEnum.AKI.getParticipantTissueType())).thenReturn(Long.valueOf(1));
when(dataSummaryRepository.getRepoBiomarkerSummaryCount(TissueTypeEnum.CKD.getParticipantTissueType())).thenReturn(Long.valueOf(2));
when(dataSummaryRepository.getRepoBiomarkerSummaryCount(TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType())).thenReturn(Long.valueOf(3));
when(dataSummaryRepository.getRepoBiomarkerSummaryCount(TissueTypeEnum.DMR.getParticipantTissueType())).thenReturn(4l);

when(dataSummaryRepository.getRepoDataSummaryCount(TissueTypeEnum.AKI.getParticipantTissueType(),
"")).thenReturn(Long.valueOf(5));
Expand Down

0 comments on commit 6879957

Please sign in to comment.