From 2dd1e62880a2a41cbb241c1285e79d696c5f6141 Mon Sep 17 00:00:00 2001 From: Ruslan Forostianov Date: Fri, 21 Jun 2024 18:02:03 +0200 Subject: [PATCH] Rename and codument better method to updateCaseLists --- .../scripts/UpdateCaseListsSampleIds.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/UpdateCaseListsSampleIds.java b/src/main/java/org/mskcc/cbio/portal/scripts/UpdateCaseListsSampleIds.java index b8ab514e..865cc660 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/UpdateCaseListsSampleIds.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/UpdateCaseListsSampleIds.java @@ -70,7 +70,7 @@ public void run() { this.caseListSampleIdToSampleIds.put(cancerStudyStableId + "_all", this.allSampleIds); Map> readCaseListSampleIds = readCaseListFiles(); this.caseListSampleIdToSampleIds.putAll(readCaseListSampleIds); - updateCaseLists(this.caseListSampleIdToSampleIds); + updateCaseListsForTheStudy(this.caseListSampleIdToSampleIds); } private Map> readCaseListFiles() { @@ -96,7 +96,20 @@ private Map> readCaseListFiles() { return result; } - private void updateCaseLists(Map> caseListSampleIdToSampleIds) { + /** + * Updates the sample lists according to the steps below: + * + * 1. New sample IDs provided in the `caseListSampleIdToSampleIds` map are added to their corresponding case lists. + * 2. These sample IDs are removed from any other case lists within the same study. + * + * @param caseListSampleIdToSampleIds A map where the key is the case list stable ID and the value is a set of sample IDs + * to be added to the corresponding case list. + * Note: This map only includes the case lists that need to be updated with new sample IDs. + * Existing case lists in the study that are not in the map will not be dropped, + * but the provided sample IDs will be removed from these lists if present. + * @throws RuntimeException if any DAO operations fail or if a case list with a specified stable ID is not found. + */ + private void updateCaseListsForTheStudy(Map> caseListSampleIdToSampleIds) { DaoCancerStudy.reCacheAll(); try { for (Map.Entry> caseListStableIdToSampleIds : caseListSampleIdToSampleIds.entrySet()) {