use of com.hartwig.events.Pipeline in project pipeline5 by hartwigmedical.
the class StagedOutputPublisher method publish.
public void publish(final PipelineState state, final SomaticRunMetadata metadata) {
if (state.status() != PipelineStatus.FAILED && run.isPresent()) {
List<AddDatatype> addDatatypes = state.stageOutputs().stream().map(StageOutput::datatypes).flatMap(List::stream).collect(Collectors.toList());
SampleSet set = setResolver.resolve(metadata.set(), useOnlyDBSets);
Optional<String> tumorSampleName = metadata.maybeTumor().map(SingleSampleRunMetadata::sampleName);
Optional<String> refSampleName = metadata.maybeReference().map(SingleSampleRunMetadata::sampleName);
ImmutableAnalysis.Builder alignedReadsAnalysis = eventBuilder(Type.ALIGNMENT);
ImmutableAnalysis.Builder somaticAnalysis = eventBuilder(Type.SOMATIC);
ImmutableAnalysis.Builder germlineAnalysis = eventBuilder(Type.GERMLINE);
OutputIterator.from(blob -> {
Optional<AddDatatype> dataType = addDatatypes.stream().filter(d -> blob.getName().endsWith(d.path())).findFirst();
Blob blobWithMd5 = sourceBucket.get(blob.getName());
if (isSecondary(blobWithMd5)) {
alignedReadsAnalysis.addOutput(createBlob(tumorSampleName, refSampleName, dataType, blobWithMd5));
} else {
if (isGermline(blobWithMd5)) {
germlineAnalysis.addOutput(createBlob(tumorSampleName, refSampleName, dataType, blobWithMd5));
} else if (notSecondary(blobWithMd5)) {
somaticAnalysis.addOutput(createBlob(tumorSampleName, refSampleName, dataType, blobWithMd5));
}
}
}, sourceBucket).iterate(metadata);
publish(PipelineComplete.builder().pipeline(ImmutablePipeline.builder().sample(tumorSampleName.orElseGet(() -> refSampleName.orElseThrow())).bucket(sourceBucket.getName()).runId(run.get().getId()).setId(set.getId()).context(context).addAnalyses(alignedReadsAnalysis.build(), somaticAnalysis.build(), germlineAnalysis.build()).version(Versions.pipelineMajorMinorVersion()).build()).build());
}
}
Aggregations