use of com.hartwig.pipeline.calling.germline.GermlineCallerOutput in project pipeline5 by hartwigmedical.
the class SingleSamplePipeline method run.
public PipelineState run(final SingleSampleRunMetadata metadata) throws Exception {
LOGGER.info("Pipeline5 single sample pipeline starting for sample name [{}] with id [{}] {}", metadata.sampleName(), metadata.barcode(), arguments.runId().map(runId -> String.format("using run tag [%s]", runId)).orElse(""));
PipelineState state = new PipelineState();
final ResourceFiles resourceFiles = buildResourceFiles(arguments);
AlignmentOutput alignmentOutput = convertCramsIfNecessary(arguments, metadata, state);
eventListener.alignmentComplete(alignmentOutput);
if (state.shouldProceed()) {
Future<BamMetricsOutput> bamMetricsFuture = executorService.submit(() -> stageRunner.run(metadata, new BamMetrics(resourceFiles, alignmentOutput, persistedDataset, arguments)));
Future<SnpGenotypeOutput> unifiedGenotyperFuture = executorService.submit(() -> stageRunner.run(metadata, new SnpGenotype(resourceFiles, alignmentOutput)));
Future<FlagstatOutput> flagstatOutputFuture = executorService.submit(() -> stageRunner.run(metadata, new Flagstat(alignmentOutput, persistedDataset)));
Future<CramOutput> cramOutputFuture = executorService.submit(() -> stageRunner.run(metadata, new CramConversion(alignmentOutput, metadata.type(), resourceFiles)));
if (metadata.type().equals(SingleSampleRunMetadata.SampleType.REFERENCE)) {
Future<GermlineCallerOutput> germlineCallerFuture = executorService.submit(() -> stageRunner.run(metadata, new GermlineCaller(alignmentOutput, resourceFiles, persistedDataset)));
GermlineCallerOutput germlineCallerOutput = futurePayload(germlineCallerFuture);
germlineCallerOutputQueue.put(germlineCallerOutput);
report.add(state.add(germlineCallerOutput));
}
BamMetricsOutput bamMetricsOutput = futurePayload(bamMetricsFuture);
metricsOutputQueue.put(bamMetricsOutput);
FlagstatOutput flagstatOutput = futurePayload(flagstatOutputFuture);
flagstatOutputQueue.put(flagstatOutput);
report.add(state.add(bamMetricsOutput));
report.add(state.add(futurePayload(unifiedGenotyperFuture)));
report.add(state.add(flagstatOutput));
report.add(state.add(futurePayload(cramOutputFuture)));
report.compose(metadata, "SingleSample");
eventListener.complete(state);
}
return state;
}
use of com.hartwig.pipeline.calling.germline.GermlineCallerOutput in project pipeline5 by hartwigmedical.
the class PipelineMain method start.
public PipelineState start(final Arguments arguments) {
LOGGER.info("Arguments are [{}]", arguments);
Versions.printAll();
try {
GoogleCredentials credentials = CredentialProvider.from(arguments).get();
Storage storage = StorageProvider.from(arguments, credentials).get();
Publisher turquoisePublisher = PublisherProvider.from(arguments, credentials).get("turquoise.events");
Publisher pipelinePublisher = PublisherProvider.from(arguments, credentials).get(PipelineComplete.TOPIC);
SomaticMetadataApi somaticMetadataApi = SomaticMetadataApiProvider.from(arguments, storage, pipelinePublisher).get();
SingleSampleEventListener referenceEventListener = new SingleSampleEventListener();
SingleSampleEventListener tumorEventListener = new SingleSampleEventListener();
SomaticRunMetadata somaticRunMetadata = somaticMetadataApi.get();
InputMode mode = new ModeResolver().apply(somaticRunMetadata);
LOGGER.info("Starting pipeline in [{}] mode", mode);
String ini = somaticRunMetadata.isSingleSample() ? "single_sample" : arguments.shallow() ? "shallow" : "somatic";
PipelineProperties eventSubjects = PipelineProperties.builder().sample(somaticRunMetadata.maybeTumor().map(SingleSampleRunMetadata::sampleName).orElseGet(() -> somaticRunMetadata.reference().sampleName())).runId(arguments.sbpApiRunId()).set(somaticRunMetadata.set()).referenceBarcode(somaticRunMetadata.maybeReference().map(SingleSampleRunMetadata::barcode)).tumorBarcode(somaticRunMetadata.maybeTumor().map(SingleSampleRunMetadata::barcode)).type(ini).build();
somaticMetadataApi.start();
startedEvent(eventSubjects, turquoisePublisher, arguments.publishToTurquoise());
BlockingQueue<BamMetricsOutput> referenceBamMetricsOutputQueue = new ArrayBlockingQueue<>(1);
BlockingQueue<BamMetricsOutput> tumorBamMetricsOutputQueue = new ArrayBlockingQueue<>(1);
BlockingQueue<FlagstatOutput> referenceFlagstatOutputQueue = new ArrayBlockingQueue<>(1);
BlockingQueue<FlagstatOutput> tumorFlagstatOutputQueue = new ArrayBlockingQueue<>(1);
BlockingQueue<GermlineCallerOutput> germlineCallerOutputQueue = new ArrayBlockingQueue<>(1);
StartingPoint startingPoint = new StartingPoint(arguments);
PersistedDataset persistedDataset = arguments.biopsy().<PersistedDataset>map(b -> new ApiPersistedDataset(SbpRestApi.newInstance(arguments.sbpApiUrl()), ObjectMappers.get(), b, arguments.project())).orElse(new NoopPersistedDataset());
PipelineState state = new FullPipeline(singleSamplePipeline(arguments, credentials, storage, referenceEventListener, somaticRunMetadata, referenceBamMetricsOutputQueue, germlineCallerOutputQueue, referenceFlagstatOutputQueue, startingPoint, persistedDataset, mode), singleSamplePipeline(arguments, credentials, storage, tumorEventListener, somaticRunMetadata, tumorBamMetricsOutputQueue, germlineCallerOutputQueue, tumorFlagstatOutputQueue, startingPoint, persistedDataset, mode), somaticPipeline(arguments, credentials, storage, somaticRunMetadata, referenceBamMetricsOutputQueue, tumorBamMetricsOutputQueue, referenceFlagstatOutputQueue, tumorFlagstatOutputQueue, startingPoint, persistedDataset, mode), Executors.newCachedThreadPool(), referenceEventListener, tumorEventListener, somaticMetadataApi, CleanupProvider.from(arguments, storage).get()).run();
completedEvent(eventSubjects, turquoisePublisher, state.status().toString(), arguments.publishToTurquoise());
VmExecutionLogSummary.ofFailedStages(storage, state);
return state;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations