Skip to content

Commit

Permalink
Give error that generic asssay patient level data is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
forus committed May 17, 2024
1 parent e5ccc3e commit 472f47e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Integer> 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<String> noChangeStableIds = Set.of("Erlotinib", "Irinotecan", "Lapatinib");
final Set<String> beforeStableIds = new HashSet<>(noChangeStableIds);
{ beforeStableIds.add(absentStableId); }

private GeneticProfile ic50Profile;
private HashMap<Integer, HashMap<Integer, String>> 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<String> noChangeStableIds = Set.of("Erlotinib", "Irinotecan", "Lapatinib");
final Set<String> 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<Integer> beforeSampleIds = Set.of(updateSampleId, noChangeSampleId);

GeneticProfile ic50Profile = DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_treatment_ic50");
assertNotNull(ic50Profile);

HashMap<Integer, HashMap<Integer, String>> beforeResult = DaoGeneticAlteration.getInstance().getGeneticAlterationMapForEntityIds(ic50Profile.getGeneticProfileId(), null);
Set<Integer> 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");
Expand Down Expand Up @@ -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<Integer> beforeEntityIds = geneStableIdsToEntityIds(beforeStableIds);
assertPriorDataState(beforeResult, beforeEntityIds, beforeSampleIds);
}

}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 472f47e

Please sign in to comment.