Skip to content

Commit

Permalink
working better
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed Jan 3, 2025
1 parent baf4516 commit a3378c0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.apache.ibatis.annotations.Param;
import org.cbioportal.model.AlterationCountByGene;
import org.cbioportal.model.AlterationEnrichment;
import org.cbioportal.model.CaseListDataCount;
import org.cbioportal.model.ClinicalAttribute;
import org.cbioportal.model.ClinicalData;
Expand All @@ -26,7 +25,6 @@
import org.cbioportal.web.parameter.GenomicDataBinFilter;
import org.cbioportal.web.parameter.GenomicDataFilter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -91,9 +89,9 @@ public interface StudyViewMapper {

List<MolecularProfile> getFilteredMolecularProfilesByAlterationType(StudyViewFilterHelper studyViewFilterHelper, String alterationType);

List<AlterationCountByGene> getAlterationEnrichmentCounts(List<String> sampleStableIds);
List<AlterationCountByGene> getAlterationEnrichmentCounts(String[] sampleStableIds);

List<SampleToPanel> getSampleToGenePanels(List<String> sampleStableIds);
List<SampleToPanel> getSampleToGenePanels(String[] sampleStableIds);

List<GenePanelToGene> getGenePanelGenes();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public HashMap<String, AlterationCountByGene> getAlterationEnrichmentCounts(List
// we need a map of panels to genes which are profiled by them
var panelToGeneMap = getGenePanelsToGenes();

List<SampleToPanel> sampleToGenePanels = mapper.getSampleToGenePanels(sampleStableIds);
List<SampleToPanel> sampleToGenePanels = mapper.getSampleToGenePanels(sampleStableIds.toArray(String[]::new));

// group the panels by the sample ids which they are associated with
// this tells us for each sample, what gene panels were applied
Expand All @@ -327,7 +327,7 @@ public HashMap<String, AlterationCountByGene> getAlterationEnrichmentCounts(List
));


var alterationCounts = mapper.getAlterationEnrichmentCounts(sampleStableIds);
var alterationCounts = mapper.getAlterationEnrichmentCounts(sampleStableIds.toArray(String[]::new));

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

Expand Down Expand Up @@ -379,17 +379,17 @@ public HashMap<String, AlterationCountByGene> getAlterationEnrichmentCounts(List

});

alteredGenesWithCounts.entrySet().stream().forEach(n->{
if (geneCount.containsKey(n.getKey())) {
n.getValue().setNumberOfProfiledCases(
geneCount.get(n.getKey()).getNumberOfProfiledCases()
);
} else {
n.getValue().setNumberOfProfiledCases(0);
geneCount.entrySet().stream().forEach(
n->{
if (alteredGenesWithCounts.containsKey(n.getKey())) {
n.getValue().setNumberOfAlteredCases(
alteredGenesWithCounts.get(n.getKey()).getNumberOfAlteredCases()
);
}
}
});
);

return alteredGenesWithCounts;
return geneCount;
}

public Map<String, Integer> getMutationCounts(StudyViewFilterContext studyViewFilterContext, GenomicDataFilter genomicDataFilter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,18 @@ public ResponseEntity<List<AlterationEnrichment>> fetchAlterationEnrichmentsNew(
enrichment.setpValue(BigDecimal.valueOf(util.calculatePValue(counts)));
}


return enrichment;

}).collect(Collectors.toList());



var filtered = alterationEnrichments.stream().filter(enrichment->{
// if any group has altered count above zero, let it through
return enrichment.getCounts().stream().anyMatch(c->c.getAlteredCount()>0);
}).collect(Collectors.toList());


// List<AlterationEnrichment> alterationEnrichments = alterationEnrichmentService.getAlterationEnrichments(
// groupCaseIdentifierSet,
// enrichmentType,
// alterationEventTypes);

return new ResponseEntity<>(alterationEnrichments, HttpStatus.OK);
return new ResponseEntity<>(filtered, HttpStatus.OK);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
<select id="getAlterationEnrichmentCounts" resultType="org.cbioportal.model.AlterationCountByGene">
--fudge
SELECT hugo_gene_symbol as hugoGeneSymbol, variant_type, count(DISTINCT sample_unique_id) as numberOfAlteredCases FROM genomic_event_derived
WHERE sample_unique_id IN
<foreach item="sampleId" collection="sampleStableIds" open="(" separator="," close=")">
#{sampleId}
</foreach>
WHERE sample_unique_id IN
(
#{sampleStableIds, typeHandler=org.apache.ibatis.type.ArrayTypeHandler}
)
AND genetic_profile_stable_id IN ('genie_public_mutations','genie_public_cna','genie_public_structural_variants')
GROUP BY (hugo_gene_symbol, variant_type)
</select>

<select id="getSampleToGenePanels" resultType="org.cbioportal.model.SampleToPanel">
SELECT sample_unique_id as sampleUniqueId, gene_panel_id as genePanelId, genetic_profile_id as geneticProfileId
SELECT sample_unique_id as sampleUniqueId, gene_panel_id as genePanelId, genetic_profile_id as geneticProfileId
FROM sample_to_gene_panel_derived
WHERE sample_unique_id IN
<foreach item="sampleId" collection="sampleStableIds" open="(" separator="," close=")">
#{sampleId}
</foreach>

(
#{sampleStableIds, typeHandler=org.apache.ibatis.type.ArrayTypeHandler}
)

</select>

<select id="getGenePanelGenes" resultType="org.cbioportal.model.GenePanelToGene">
Expand Down

0 comments on commit a3378c0

Please sign in to comment.