From 472f47ec88d9056db9d3bf81410f64dcd8c4b303 Mon Sep 17 00:00:00 2001 From: Ruslan Forostianov Date: Fri, 17 May 2024 10:13:14 +0200 Subject: [PATCH] Give error that generic asssay patient level data is not supported --- .../portal/scripts/ImportProfileData.java | 3 + .../TestIncrementalGenericAssayImporter.java | 74 +++++++++++++------ .../data_treatment_ic50_patient_level.txt | 8 ++ .../meta_treatment_ic50_patient_level.txt | 13 ++++ 4 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 src/test/resources/incremental/generic_assay/data_treatment_ic50_patient_level.txt create mode 100644 src/test/resources/incremental/generic_assay/meta_treatment_ic50_patient_level.txt diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java index d5b6241a..0e1ff058 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java @@ -116,6 +116,9 @@ public void run() { // use a different importer for patient level data String patientLevel = geneticProfile.getOtherMetaDataField("patient_level"); if (patientLevel != null && patientLevel.trim().toLowerCase().equals("true")) { + if (overwriteExisting) { + throw new UnsupportedOperationException("Incremental upload for generic assay patient_level data is not supported. Please use sample level instead."); + } ImportGenericAssayPatientLevelData genericAssayProfileImporter = new ImportGenericAssayPatientLevelData(dataFile, geneticProfile.getTargetLine(), geneticProfile.getGeneticProfileId(), genePanel, geneticProfile.getOtherMetaDataField("generic_entity_meta_properties")); genericAssayProfileImporter.importData(); } else { diff --git a/src/test/java/org/mskcc/cbio/portal/integrationTest/incremental/TestIncrementalGenericAssayImporter.java b/src/test/java/org/mskcc/cbio/portal/integrationTest/incremental/TestIncrementalGenericAssayImporter.java index 3162f6a3..e0ef8cf5 100644 --- a/src/test/java/org/mskcc/cbio/portal/integrationTest/incremental/TestIncrementalGenericAssayImporter.java +++ b/src/test/java/org/mskcc/cbio/portal/integrationTest/incremental/TestIncrementalGenericAssayImporter.java @@ -41,6 +41,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; import static org.mskcc.cbio.portal.integrationTest.incremental.GeneticAlterationsTestHelper.assertNoChange; import static org.mskcc.cbio.portal.integrationTest.incremental.GeneticAlterationsTestHelper.assertPriorDataState; import static org.mskcc.cbio.portal.integrationTest.incremental.GeneticAlterationsTestHelper.geneStableIdToEntityId; @@ -58,34 +59,28 @@ @Transactional public class TestIncrementalGenericAssayImporter { + // stable_id: TCGA-A1-A0SB-01 + final int newSampleId = 1; + // stable_id: TCGA-A1-A0SD-01 + final int updateSampleId = 2; + // stable_id: TCGA-A1-A0SE-01 + final int noChangeSampleId = 3; + final Set beforeSampleIds = Set.of(updateSampleId, noChangeSampleId); + + // Stable id that is part of the platform, but absent during the incremental upload + final String absentStableId = "L-685458"; + final Set noChangeStableIds = Set.of("Erlotinib", "Irinotecan", "Lapatinib"); + final Set beforeStableIds = new HashSet<>(noChangeStableIds); + { beforeStableIds.add(absentStableId); } + + private GeneticProfile ic50Profile; + private HashMap> beforeResult; + /** * Test incremental upload of GENERIC_ASSAY */ @Test - public void testGenericAssay() throws DaoException, IOException { - /** - * Prior checks - */ - // Stable id that is part of the platform, but absent during the incremental upload - final String absentStableId = "L-685458"; - final Set noChangeStableIds = Set.of("Erlotinib", "Irinotecan", "Lapatinib"); - final Set beforeStableIds = new HashSet<>(noChangeStableIds); - beforeStableIds.add(absentStableId); - - // stable_id: TCGA-A1-A0SB-01 - final int newSampleId = 1; - // stable_id: TCGA-A1-A0SD-01 - final int updateSampleId = 2; - // stable_id: TCGA-A1-A0SE-01 - final int noChangeSampleId = 3; - final Set beforeSampleIds = Set.of(updateSampleId, noChangeSampleId); - - GeneticProfile ic50Profile = DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_treatment_ic50"); - assertNotNull(ic50Profile); - - HashMap> beforeResult = DaoGeneticAlteration.getInstance().getGeneticAlterationMapForEntityIds(ic50Profile.getGeneticProfileId(), null); - Set beforeEntityIds = geneStableIdsToEntityIds(beforeStableIds); - assertPriorDataState(beforeResult, beforeEntityIds, beforeSampleIds); + public void testGenericAssay() throws DaoException { File dataFolder = new File("src/test/resources/incremental/generic_assay/"); File metaFile = new File(dataFolder, "meta_treatment_ic50.txt"); @@ -128,9 +123,40 @@ public void testGenericAssay() throws DaoException, IOException { assertNotNull("New generic entity has to be added", DaoGeneticEntity.getGeneticEntityByStableId("LBW242")); } + /** + * Test that incremental upload of GENERIC_ASSAY (patient level) is not supported + */ + @Test + public void testGenericAssayPatientLevel() throws DaoException { + + File dataFolder = new File("src/test/resources/incremental/generic_assay/"); + File metaFile = new File(dataFolder, "meta_treatment_ic50_patient_level.txt"); + File dataFile = new File(dataFolder, "data_treatment_ic50_patient_level.txt"); + + /** + * Test + */ + assertThrows("Incremental upload for generic assay patient_level data is not supported. Please use sample level instead.", + RuntimeException.class, () -> { + new ImportProfileData(new String[] { + "--loadMode", "bulkLoad", + "--meta", metaFile.getAbsolutePath(), + "--data", dataFile.getAbsolutePath(), + "--overwrite-existing", + }).run(); + }); + } + @Before public void setUp() throws DaoException { DaoCancerStudy.reCacheAll(); + + ic50Profile = DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_treatment_ic50"); + assertNotNull(ic50Profile); + + beforeResult = DaoGeneticAlteration.getInstance().getGeneticAlterationMapForEntityIds(ic50Profile.getGeneticProfileId(), null); + Set beforeEntityIds = geneStableIdsToEntityIds(beforeStableIds); + assertPriorDataState(beforeResult, beforeEntityIds, beforeSampleIds); } } diff --git a/src/test/resources/incremental/generic_assay/data_treatment_ic50_patient_level.txt b/src/test/resources/incremental/generic_assay/data_treatment_ic50_patient_level.txt new file mode 100644 index 00000000..34753bba --- /dev/null +++ b/src/test/resources/incremental/generic_assay/data_treatment_ic50_patient_level.txt @@ -0,0 +1,8 @@ +ENTITY_STABLE_ID NAME DESCRIPTION URL TCGA-A1-A0SB TCGA-A1-A0SD +Erlotinib Name of Erlotinib Desc of Erlotinib Url of Erlotinib >8 7.5 +Irinotecan Name of Irinotecan Desc of Irinotecan Url of Irinotecan 0.081 +# The database has this entity, but not the file +#L-685458 +Lapatinib Name of Lapatinib Desc of Lapatinib Url of Lapatinib 6.2 7.848 +#The entity will be added +LBW242 Name of LBW242 Desc of LBW242 Url of LBW242 0.1 >~8 diff --git a/src/test/resources/incremental/generic_assay/meta_treatment_ic50_patient_level.txt b/src/test/resources/incremental/generic_assay/meta_treatment_ic50_patient_level.txt new file mode 100644 index 00000000..181899f5 --- /dev/null +++ b/src/test/resources/incremental/generic_assay/meta_treatment_ic50_patient_level.txt @@ -0,0 +1,13 @@ +cancer_study_identifier: study_tcga_pub +genetic_alteration_type: GENERIC_ASSAY +generic_assay_type: TREATMENT_RESPONSE +datatype: LIMIT-VALUE +stable_id: treatment_ic50 +profile_name: IC50 values of compounds on cellular phenotype readout +profile_description: IC50 (compound concentration resulting in half maximal inhibition) of compounds on cellular phenotype readout of cultured mutant cell lines. +data_filename: data_treatment_ic50_patient_level.txt +show_profile_in_analysis_tab: true +pivot_threshold_value: 0.1 +value_sort_order: ASC +generic_entity_meta_properties: NAME,DESCRIPTION,URL +patient_level: true