use of com.hartwig.pipeline.calling.sage.SageApplication in project pipeline5 by hartwigmedical.
the class SageRerunOld method execute.
@Override
public VirtualMachineJobDefinition execute(final InputBundle inputs, final RuntimeBucket runtimeBucket, final BashStartupScript commands, final RuntimeFiles executionFlags) {
// Inputs
final String set = inputs.get("set").inputValue();
final String tumorSampleName = inputs.get("tumor_sample").inputValue();
final String referenceSampleName = inputs.get("ref_sample").inputValue();
final InputFileDescriptor remoteTumorFile = inputs.get("tumor_cram");
final InputFileDescriptor remoteReferenceFile = inputs.get("ref_cram");
final InputFileDescriptor remoteTumorIndex = remoteTumorFile.index();
final InputFileDescriptor remoteReferenceIndex = remoteReferenceFile.index();
final String localTumorFile = localFilename(remoteTumorFile);
final String localReferenceFile = localFilename(remoteReferenceFile);
final String localTumorBam = CONVERT_TO_BAM ? localTumorFile.replace("cram", "bam") : localTumorFile;
final String localReferenceBam = CONVERT_TO_BAM ? localReferenceFile.replace("cram", "bam") : localReferenceFile;
final ResourceFiles resourceFiles = ResourceFilesFactory.buildResourceFiles(RefGenomeVersion.V37);
// Download tumor
commands.addCommand(() -> remoteTumorFile.toCommandForm(localTumorFile));
commands.addCommand(() -> remoteTumorIndex.toCommandForm(localFilename(remoteTumorIndex)));
// Download normal
commands.addCommand(() -> remoteReferenceFile.toCommandForm(localReferenceFile));
commands.addCommand(() -> remoteReferenceIndex.toCommandForm(localFilename(remoteReferenceIndex)));
final SageCommandBuilder sageCommandBuilder = new SageCommandBuilder(resourceFiles).addReference(referenceSampleName, localReferenceBam).addTumor(tumorSampleName, localTumorBam);
if (PANEL_ONLY) {
sageCommandBuilder.panelOnly();
}
if (inputs.contains("rna")) {
final InputFileDescriptor remoteRnaBam = inputs.get("rna");
final InputFileDescriptor remoteRnaBamIndex = remoteRnaBam.index();
final String localRnaBam = localFilename(remoteRnaBam);
// Download rna
commands.addCommand(() -> remoteRnaBam.toCommandForm(localRnaBam));
commands.addCommand(() -> remoteRnaBamIndex.toCommandForm(localFilename(remoteRnaBamIndex)));
// Add to sage application
sageCommandBuilder.addReference(referenceSampleName + "NA", localRnaBam);
}
// Convert to bam if necessary
if (!localTumorFile.equals(localTumorBam)) {
commands.addCommands(cramToBam(localTumorFile));
}
if (!localReferenceFile.equals(localReferenceBam)) {
commands.addCommands(cramToBam(localReferenceFile));
}
SageApplication sageApplication = new SageApplication(sageCommandBuilder);
SageSomaticPostProcess sagePostProcess = new SageSomaticPostProcess(tumorSampleName, resourceFiles);
SubStageInputOutput sageOutput = sageApplication.andThen(sagePostProcess).apply(SubStageInputOutput.empty(tumorSampleName));
commands.addCommands(sageOutput.bash());
// 8. Archive targeted output
final GoogleStorageLocation archiveStorageLocation = sageArchiveDirectory(set);
final OutputFile filteredOutputFile = sageOutput.outputFile();
final OutputFile filteredOutputFileIndex = filteredOutputFile.index(".tbi");
final OutputFile unfilteredOutputFile = sageApplication.apply(SubStageInputOutput.empty(tumorSampleName)).outputFile();
final OutputFile unfilteredOutputFileIndex = unfilteredOutputFile.index(".tbi");
commands.addCommand(() -> filteredOutputFile.copyToRemoteLocation(archiveStorageLocation));
commands.addCommand(() -> filteredOutputFileIndex.copyToRemoteLocation(archiveStorageLocation));
commands.addCommand(() -> unfilteredOutputFile.copyToRemoteLocation(archiveStorageLocation));
commands.addCommand(() -> unfilteredOutputFileIndex.copyToRemoteLocation(archiveStorageLocation));
commands.addCommand(() -> bqrFile(tumorSampleName, "png").copyToRemoteLocation(archiveStorageLocation));
commands.addCommand(() -> bqrFile(tumorSampleName, "tsv").copyToRemoteLocation(archiveStorageLocation));
commands.addCommand(() -> bqrFile(referenceSampleName, "png").copyToRemoteLocation(archiveStorageLocation));
commands.addCommand(() -> bqrFile(referenceSampleName, "tsv").copyToRemoteLocation(archiveStorageLocation));
// Store output
commands.addCommand(new OutputUpload(GoogleStorageLocation.of(runtimeBucket.name(), "sage"), executionFlags));
return VirtualMachineJobDefinition.sageSomaticCalling(commands, ResultsDirectory.defaultDirectory());
}
use of com.hartwig.pipeline.calling.sage.SageApplication in project pipeline5 by hartwigmedical.
the class SageCreatePonData method execute.
@Override
public VirtualMachineJobDefinition execute(final InputBundle inputs, final RuntimeBucket runtimeBucket, final BashStartupScript startupScript, final RuntimeFiles executionFlags) {
final ResourceFiles resourceFiles = ResourceFilesFactory.buildResourceFiles(RefGenomeVersion.V37);
final InputFileDescriptor remoteReferenceFile = inputs.get("reference");
final InputFileDescriptor remoteReferenceIndex = remoteReferenceFile.index();
final String localReferenceFile = localFilename(remoteReferenceFile);
final String localReferenceBam = localReferenceFile.replace("cram", "bam");
final String referenceSampleName = inputs.get("referenceSample").inputValue();
// Download latest jar file
// startupScript.addCommand(() -> format("gsutil -u hmf-crunch cp %s %s",
// "gs://batch-sage-validation/resources/sage.jar",
// "/opt/tools/sage/" + Versions.SAGE + "/sage.jar"));
// Download normal
startupScript.addCommand(() -> remoteReferenceFile.toCommandForm(localReferenceFile));
startupScript.addCommand(() -> remoteReferenceIndex.toCommandForm(localFilename(remoteReferenceIndex)));
final SageCommandBuilder sageCommandBuilder = new SageCommandBuilder(resourceFiles).ponMode(referenceSampleName, localReferenceBam);
final SageApplication sageApplication = new SageApplication(sageCommandBuilder);
// Convert to bam if necessary
if (!localReferenceFile.equals(localReferenceBam)) {
startupScript.addCommands(cramToBam(localReferenceFile));
}
// Run post processing (NONE for germline)
final SubStageInputOutput postProcessing = sageApplication.apply(SubStageInputOutput.empty(referenceSampleName));
startupScript.addCommands(postProcessing.bash());
// Store output
startupScript.addCommand(new OutputUpload(GoogleStorageLocation.of(runtimeBucket.name(), "sage"), executionFlags));
return VirtualMachineJobDefinition.sageSomaticCalling(startupScript, ResultsDirectory.defaultDirectory());
}
Aggregations