Skip to content

Commit

Permalink
Merge branch '79-fix-zodiac-crashing-with-corrupted-compounds' into '…
Browse files Browse the repository at this point in the history
…stable'

Resolve "Fix ZODIAC crashing with corrupted compounds"

See merge request bright-giant/sirius/sirius-frontend!25
  • Loading branch information
Markus Fleischauer committed Nov 9, 2023
2 parents 5b659d0 + c1c04c4 commit d2b862e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ protected Iterable<Instance> compute() throws Exception {

if (!hasResults || recompute) {
if (hasResults) {
inputInstances.forEach(this::invalidateResults);
inputInstances.forEach(ins->{
//one corrupted instance should not make the whole dataset job fail
try{
invalidateResults(ins);
} catch (Exception e){
logWarn("Cannot invalidate results for "+ins.getID().getDirectoryName()+". Hence, this instance may be ignored in further computations. Error: "+e.getMessage());
}
});
}
updateProgress(Math.round(.9 * inputInstances.size()), "Invalidate existing Results and Recompute!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,27 @@ public ZodiacSubToolJob(ZodiacOptions cliOptions, @NotNull JobSubmitter jobSubmi

@Override
public boolean isAlreadyComputed(@NotNull Instance inst) {
return inst.loadCompoundContainer().hasResults() && inst.loadFormulaResults(FormulaScoring.class).stream().anyMatch(res -> res.getCandidate().getAnnotationOrThrow(FormulaScoring.class).hasAnnotation(ZodiacScore.class));
try {
return inst.loadCompoundContainer().hasResults() && inst.loadFormulaResults(FormulaScoring.class).stream().anyMatch(res -> res.getCandidate().getAnnotationOrThrow(FormulaScoring.class).hasAnnotation(ZodiacScore.class));
} catch (Exception e) {
//only debug output, since the same instance will fail again below in computeAndAnnotateResult
logDebug("Error while reading molecular formula scores for "+inst.getID().getDirectoryName()+". Error: "+e.getMessage());
return false;
}
}

@Override
protected void computeAndAnnotateResult(@NotNull List<Instance> instances) throws Exception {
logInfo("START ZODIAC JOB");
final Map<Ms2Experiment, List<FormulaResult>> input = instances.stream()
.distinct().collect(Collectors.toMap(
Instance::getExperiment,
in -> in.loadFormulaResults(List.of(SiriusScore.class), FormulaScoring.class, FTree.class).stream().map(SScored::getCandidate).collect(Collectors.toList())
Instance::getExperiment, in -> {
try {
return in.loadFormulaResults(List.of(SiriusScore.class), FormulaScoring.class, FTree.class).stream().map(SScored::getCandidate).collect(Collectors.toList());
} catch (Exception e) {
logWarn("Error while reading molecular formula scores for "+in.getID().getDirectoryName()+". Exclude it from ZODIAC computation. Error: "+e.getMessage());
return Collections.emptyList(); //empty lists are filtered below.
}}
));

//remove instances from input which don't have a single FTree
Expand Down

0 comments on commit d2b862e

Please sign in to comment.