Skip to content

Commit

Permalink
fixed output
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed Jan 2, 2025
1 parent e4af8ef commit 336515b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,29 @@ public HashMap<String, AlterationCountByGene> getAlterationEnrichmentCounts(List
Map<String, List<String>> clumps = samplesToPanelMap.keySet().stream().collect(Collectors.groupingBy(
sampleId->samplesToPanelMap.get(sampleId).stream().collect(Collectors.joining(","))
));


var alterationCounts = mapper.getAlterationEnrichmentCounts(sampleStableIds);

HashMap<String, AlterationCountByGene> alteredGenesWithCounts = new HashMap();

// we need map of genes to alteration counts
alterationCounts.stream().forEach((alterationCountByGene) -> {
String hugoGeneSymbol = alterationCountByGene.getHugoGeneSymbol();
int count = alterationCountByGene.getNumberOfAlteredCases();
if (!alteredGenesWithCounts.containsKey(hugoGeneSymbol)) {
var acg = new AlterationCountByGene();
acg.setHugoGeneSymbol(hugoGeneSymbol);
acg.setNumberOfAlteredCases(0);
alteredGenesWithCounts.put(hugoGeneSymbol,acg);
}
// add the count to existing tally
alteredGenesWithCounts.get(hugoGeneSymbol).setNumberOfAlteredCases(
count + alteredGenesWithCounts.get(hugoGeneSymbol).getNumberOfAlteredCases()
);


});

var geneCount = new HashMap<String,AlterationCountByGene>();

clumps.entrySet().stream().forEach(entry->{
Expand All @@ -351,36 +372,22 @@ public HashMap<String, AlterationCountByGene> getAlterationEnrichmentCounts(List
var alterationCountByGene = new AlterationCountByGene();
alterationCountByGene.setHugoGeneSymbol(gene);
alterationCountByGene.setNumberOfProfiledCases(entry.getValue().size());
alterationCountByGene.setNumberOfAlteredCases(0);
geneCount.put(gene,alterationCountByGene);
}
});

});


var doo = mapper.getAlterationEnrichmentCounts(sampleStableIds);

HashMap<String, Map<String, Integer>> alteredGenesWithCounts = new HashMap();

// we need map of genes to alteration counts
doo.stream().forEach((alterationCountByGene) -> {
String hugoGeneSymbol = alterationCountByGene.getHugoGeneSymbol();
int count = alterationCountByGene.getNumberOfAlteredCases();
if (!alteredGenesWithCounts.containsKey(hugoGeneSymbol)) {
alteredGenesWithCounts.put(hugoGeneSymbol, new HashMap<>());
alteredGenesWithCounts.get(hugoGeneSymbol).put("count", 0);
alteredGenesWithCounts.entrySet().stream().forEach(n->{
if (geneCount.containsKey(n.getKey())) {
n.getValue().setNumberOfProfiledCases(
geneCount.get(n.getKey()).getNumberOfProfiledCases()
);
}
alteredGenesWithCounts.get(hugoGeneSymbol).put("count", alteredGenesWithCounts.get(hugoGeneSymbol).get("count") + count);
});




// const panelsToGeneMaps = _(panelGenes).groupBy("gene_panel_id")
// .mapValues(arr=>_.keyBy(arr,"gene")).value();


return geneCount;
return alteredGenesWithCounts;
}

public Map<String, Integer> getMutationCounts(StudyViewFilterContext studyViewFilterContext, GenomicDataFilter genomicDataFilter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ public ResponseEntity<List<AlterationEnrichment>> fetchAlterationEnrichmentsNew(
summary.setProfiledCount(
geneCount.getNumberOfProfiledCases()
);
summary.setAlteredCount(
geneCount.getNumberOfAlteredCases()
);
} else {
summary.setProfiledCount(0);
summary.setAlteredCount(0);
}
return summary;
}).collect(Collectors.toList());
Expand Down

0 comments on commit 336515b

Please sign in to comment.