Skip to content

Commit

Permalink
TEMPO additional logging (#1142)
Browse files Browse the repository at this point in the history
Added extra logging to help with debugging.
Additonal logs also report whether a cohort attempts to import with
  samples that are unknown to SMILE. The cohort is still imported but incompletely.

Signed-off-by: Angelica Ochoa <[email protected]>
  • Loading branch information
ao508 authored Apr 11, 2024
1 parent d556c5e commit b90e4d5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.mskcc.smile.service.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mskcc.smile.commons.JsonComparator;
Expand Down Expand Up @@ -41,7 +43,8 @@ public class CohortCompleteServiceImpl implements CohortCompleteService {
public Cohort saveCohort(Cohort cohort, Set<String> samplePrimaryIds) throws Exception {
// persist new cohort complete event to the db
cohortCompleteRepository.save(cohort);
// create cohort-smaple relationships
Set<String> unknownSamples = new HashSet<>(); // tracks unknown samples in smile
// create cohort-sample relationships
for (String primaryId : samplePrimaryIds) {
// confirm sample exists by primary id and then link to cohort
if (sampleService.sampleExistsByPrimaryId(primaryId)) {
Expand All @@ -50,8 +53,21 @@ public Cohort saveCohort(Cohort cohort, Set<String> samplePrimaryIds) throws Exc
tempoService.initAndSaveDefaultTempoData(primaryId);
}
cohortCompleteRepository.addCohortSampleRelationship(cohort.getCohortId(), primaryId);
} else {
unknownSamples.add(primaryId);
}
}
// log and report unknown samples for reference
if (!unknownSamples.isEmpty()) {
StringBuilder builder = new StringBuilder();
builder.append("Could not import ")
.append(unknownSamples.size())
.append(" samnples for cohort ")
.append(cohort.getCohortId())
.append(": ")
.append(StringUtils.join(unknownSamples,", "));
LOG.warn(builder.toString());
}
return getCohortByCohortId(cohort.getCohortId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.mskcc.smile.service.TempoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.stereotype.Component;

/**
Expand Down Expand Up @@ -117,8 +118,13 @@ public void run() {
Tempo tempo = tempoService.getTempoDataBySamplePrimaryId(primaryId);
if (tempo == null
|| !tempo.hasBamCompleteEvent(bamComplete)) {
tempoService.mergeBamCompleteEventBySamplePrimaryId(primaryId,
try {
tempoService.mergeBamCompleteEventBySamplePrimaryId(primaryId,
bamComplete);
} catch (IncorrectResultSizeDataAccessException e) {
LOG.error("Encountered error while persisting BAM complete "
+ "event to database: " + bcEvent.toString(), e);
}
}
} else {
LOG.error("Sample with primary id " + primaryId + " does not exist");
Expand Down Expand Up @@ -156,8 +162,13 @@ public void run() {
Tempo tempo = tempoService.getTempoDataBySamplePrimaryId(primaryId);
if (tempo == null
|| !tempo.hasQcCompleteEvent(qcComplete)) {
tempoService.mergeQcCompleteEventBySamplePrimaryId(primaryId,
qcComplete);
try {
tempoService.mergeQcCompleteEventBySamplePrimaryId(primaryId,
qcComplete);
} catch (IncorrectResultSizeDataAccessException e) {
LOG.error("Encountered error while persisting QC complete "
+ "event to database: " + qcEvent.toString(), e);
}
}
} else {
LOG.error("Sample with primary id: " + primaryId + " does not exist");
Expand Down Expand Up @@ -195,8 +206,13 @@ public void run() {
Tempo tempo = tempoService.getTempoDataBySamplePrimaryId(primaryId);
if (tempo == null
|| !tempo.hasMafCompleteEvent(mafComplete)) {
tempoService.mergeMafCompleteEventBySamplePrimaryId(primaryId,
mafComplete);
try {
tempoService.mergeMafCompleteEventBySamplePrimaryId(primaryId,
mafComplete);
} catch (IncorrectResultSizeDataAccessException e) {
LOG.error("Encountered error while persisting MAF complete "
+ "event to database: " + mcEvent.toString(), e);
}
}
} else {
LOG.error("Sample with primary id " + primaryId + " does not exist");
Expand Down

0 comments on commit b90e4d5

Please sign in to comment.