Skip to content

Commit

Permalink
Rename upsertSampleProfiles to upsertSampleToProfileMapping
Browse files Browse the repository at this point in the history
method in DaoSampleProfile
  • Loading branch information
forus committed Jun 21, 2024
1 parent df8f7af commit f120f5d
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/mskcc/cbio/portal/dao/DaoSampleProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ private DaoSampleProfile() {}

private static final int NO_SUCH_PROFILE_ID = -1;

public static void upsertSampleProfiles(Collection<Integer> sampleIds, Integer geneticProfileId, Integer panelId) throws DaoException {
upsertSampleProfiles(
public static void upsertSampleToProfileMapping(Collection<Integer> sampleIds, Integer geneticProfileId, Integer panelId) throws DaoException {
upsertSampleToProfileMapping(
sampleIds.stream()
.map(sampleId -> new SampleProfileTuple(geneticProfileId, sampleId, panelId)).toList());
}

public record SampleProfileTuple(int geneticProfileId, int sampleId, Integer panelId) {}

public static void upsertSampleProfiles(Collection<SampleProfileTuple> idTuples) throws DaoException {
public static void upsertSampleToProfileMapping(Collection<SampleProfileTuple> idTuples) throws DaoException {
if (idTuples.isEmpty()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void doImportData() throws Exception {
orderedSampleList = newArrayList(toImport.eventsTable.columnKeySet());
this.geneticAlterationGeneImporter = isIncrementalUpdateMode ? new GeneticAlterationIncrementalImporter(geneticProfileId, orderedSampleList)
: new GeneticAlterationImporter(geneticProfileId, orderedSampleList);
DaoSampleProfile.upsertSampleProfiles(orderedSampleList, geneticProfileId, genePanelId);
DaoSampleProfile.upsertSampleToProfileMapping(orderedSampleList, geneticProfileId, genePanelId);

for (Long entrezId : toImport.eventsTable.rowKeySet()) {
boolean added = storeGeneticAlterations(toImport, entrezId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public void importData() throws IOException, DaoException {
}
}
}
DaoSampleProfile.upsertSampleProfiles(internalSampleIds, geneticProfileId, genePanelId);
DaoSampleProfile.upsertSampleToProfileMapping(internalSampleIds, geneticProfileId, genePanelId);

for (MutationEvent event : newEvents) {
try {
Expand Down Expand Up @@ -611,7 +611,7 @@ private String processMAFHeader(BufferedReader buffer) throws IOException, DaoEx
}
line = buffer.readLine().trim();
}
DaoSampleProfile.upsertSampleProfiles(internalSampleIds, geneticProfileId, genePanelId);
DaoSampleProfile.upsertSampleToProfileMapping(internalSampleIds, geneticProfileId, genePanelId);
return line;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void importData() throws Exception {
sampleProfileTuples.add(new DaoSampleProfile.SampleProfileTuple(geneticProfileId, sampleInternalId, genePanelId));
}

DaoSampleProfile.upsertSampleProfiles(sampleProfileTuples);
DaoSampleProfile.upsertSampleToProfileMapping(sampleProfileTuples);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void importData() throws IOException, DaoException {
}
}
Integer genePanelID = (genePanel == null) ? null : GeneticProfileUtil.getGenePanelId(genePanel);
DaoSampleProfile.upsertSampleProfiles(orderedSampleList, geneticProfileId, genePanelID);
DaoSampleProfile.upsertSampleToProfileMapping(orderedSampleList, geneticProfileId, genePanelID);

ProgressMonitor.setCurrentMessage(" --> total number of data lines: " + (numLines-1));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void importData() throws IOException, DaoException {
}
}

DaoSampleProfile.upsertSampleProfiles(sampleIds, geneticProfileId, genePanelId);
DaoSampleProfile.upsertSampleToProfileMapping(sampleIds, geneticProfileId, genePanelId);
if (isIncrementalUpdateMode) {
DaoStructuralVariant.deleteStructuralVariants(geneticProfileId, sampleIds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ private void doImportData() throws IOException, DaoException {

line = buf.readLine();
}
DaoSampleProfile.upsertSampleProfiles(orderedSampleList, geneticProfileId, genePanelId);
DaoSampleProfile.upsertSampleToProfileMapping(orderedSampleList, geneticProfileId, genePanelId);
geneticAlterationImporter.finalise();
if (MySQLbulkLoader.isBulkLoad()) {
MySQLbulkLoader.flushAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void testDaoSampleProfile() throws DaoException {
Patient patient = DaoPatient.getPatientByCancerStudyAndPatientId(study.getInternalId(), "TCGA-12345");
Sample sample = DaoSample.getSampleByPatientAndSampleId(patient.getInternalId(), "TCGA-12345-01");

DaoSampleProfile.upsertSampleProfiles(List.of(
DaoSampleProfile.upsertSampleToProfileMapping(List.of(
new DaoSampleProfile.SampleProfileTuple(geneticProfileId, sample.getInternalId(), null)));

boolean exists = DaoSampleProfile.sampleExistsInGeneticProfile(sample.getInternalId(), geneticProfileId);
Expand All @@ -115,7 +115,7 @@ public void testDaoSampleProfile() throws DaoException {
assertEquals(geneticProfileId, DaoSampleProfile.getProfileIdForSample(sample.getInternalId()));

sample = DaoSample.getSampleByPatientAndSampleId(patient.getInternalId(), "TCGA-123456-01");
DaoSampleProfile.upsertSampleProfiles(List.of(
DaoSampleProfile.upsertSampleToProfileMapping(List.of(
new DaoSampleProfile.SampleProfileTuple(geneticProfileId, sample.getInternalId(), genePanel.getInternalId())));

boolean existsByPanelId = DaoSampleProfile.sampleProfileMappingExistsByPanel(genePanel.getInternalId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void testIncrementalUpload() throws DaoException {
structuralVariant.setComments("This record has to be overwritten");
DaoStructuralVariant.addStructuralVariantToBulkLoader(structuralVariant);
MySQLbulkLoader.flushAll();
DaoSampleProfile.upsertSampleProfiles(List.of(
DaoSampleProfile.upsertSampleToProfileMapping(List.of(
new DaoSampleProfile.SampleProfileTuple(svGeneticProfile.getGeneticProfileId(), svDataSample.getInternalId(), null)));

File singleTcgaSampleFolder = new File("src/test/resources/incremental/structural_variants/");
Expand Down

0 comments on commit f120f5d

Please sign in to comment.