use of com.hartwig.pipeline.calling.structural.gridss.stage.Driver in project pipeline5 by hartwigmedical.
the class GridssRerun method execute.
@Override
public VirtualMachineJobDefinition execute(final InputBundle inputs, final RuntimeBucket runtimeBucket, final BashStartupScript commands, final RuntimeFiles executionFlags) {
// Inputs
final ResourceFiles resourceFiles = ResourceFilesFactory.buildResourceFiles(RefGenomeVersion.V37);
final String set = inputs.get("set").inputValue();
final String tumorSampleName = inputs.get("tumor_sample").inputValue();
final String referenceSampleName = inputs.get("reference_sample").inputValue();
final InputFileDescriptor remoteTumorFile = inputs.get("tumor_cram");
final InputFileDescriptor remoteReferenceFile = inputs.get("ref_cram");
final InputFileDescriptor runData = inputs.get();
final RemoteLocationsApi locationsApi = new RemoteLocationsApi(runData.billedProject(), tumorSampleName);
InputDownload tumorBamDownload = new InputDownload(locationsApi.getTumorAlignment());
InputDownload tumorBamIndexDownload = new InputDownload(locationsApi.getTumorAlignmentIndex());
InputDownload referenceBamDownload = new InputDownload(locationsApi.getReferenceAlignment());
InputDownload referenceBamIndexDownload = new InputDownload(locationsApi.getReferenceAlignmentIndex());
final InputFileDescriptor remoteTumorIndex = remoteTumorFile.index();
final InputFileDescriptor remoteReferenceIndex = remoteReferenceFile.index();
final String localTumorFile = localFilename(remoteTumorFile);
final String localReferenceFile = localFilename(remoteReferenceFile);
final String tumorBamPath = localTumorFile.replace("cram", "bam");
final String refBamPath = localReferenceFile.replace("cram", "bam");
Driver driver = new Driver(resourceFiles, VmDirectories.outputFile(tumorSampleName + ".assembly.bam")).tumorSample(tumorSampleName, tumorBamPath).referenceSample(referenceSampleName, refBamPath);
GridssAnnotation viralAnnotation = new GridssAnnotation(resourceFiles, false);
SubStageInputOutput unfilteredVcfOutput = driver.andThen(viralAnnotation).apply(SubStageInputOutput.empty(tumorSampleName));
final OutputFile unfilteredVcf = unfilteredVcfOutput.outputFile();
final OutputFile unfilteredVcfIndex = unfilteredVcf.index(".tbi");
final GoogleStorageLocation unfilteredVcfRemoteLocation = remoteUnfilteredVcfArchivePath(set, tumorSampleName);
final GoogleStorageLocation unfilteredVcfIndexRemoteLocation = index(unfilteredVcfRemoteLocation, ".tbi");
// COMMANDS
commands.addCommand(new ExportPathCommand(new BwaCommand()));
commands.addCommand(new ExportPathCommand(new SamtoolsCommand()));
commands.addCommand(() -> remoteTumorFile.toCommandForm(localTumorFile));
commands.addCommand(() -> remoteTumorIndex.toCommandForm(localFilename(remoteTumorIndex)));
commands.addCommand(() -> remoteReferenceFile.toCommandForm(localReferenceFile));
commands.addCommand(() -> remoteReferenceIndex.toCommandForm(localFilename(remoteReferenceIndex)));
if (!localTumorFile.equals(tumorBamPath)) {
commands.addCommands(cramToBam(localTumorFile));
}
if (!localReferenceFile.equals(refBamPath)) {
commands.addCommands(cramToBam(localReferenceFile));
}
commands.addCommands(unfilteredVcfOutput.bash());
commands.addCommand(() -> unfilteredVcf.copyToRemoteLocation(unfilteredVcfRemoteLocation));
commands.addCommand(() -> unfilteredVcfIndex.copyToRemoteLocation(unfilteredVcfIndexRemoteLocation));
commands.addCommand(new OutputUpload(GoogleStorageLocation.of(runtimeBucket.name(), "gridss"), executionFlags));
return VirtualMachineJobDefinition.structuralCalling(commands, ResultsDirectory.defaultDirectory());
}
use of com.hartwig.pipeline.calling.structural.gridss.stage.Driver in project pipeline5 by hartwigmedical.
the class Gridss method tumorOnlyCommands.
@Override
public List<BashCommand> tumorOnlyCommands(final SomaticRunMetadata metadata) {
String tumorSampleName = metadata.tumor().sampleName();
String tumorBamPath = getTumorBamDownload().getLocalTargetPath();
Driver driver = new Driver(resourceFiles, VmDirectories.outputFile(tumorSampleName + ".assembly.bam")).tumorSample(tumorSampleName, tumorBamPath);
return gridssCommands(driver, tumorSampleName);
}
use of com.hartwig.pipeline.calling.structural.gridss.stage.Driver in project pipeline5 by hartwigmedical.
the class Gridss method referenceOnlyCommands.
@Override
public List<BashCommand> referenceOnlyCommands(final SomaticRunMetadata metadata) {
String referenceSampleName = metadata.reference().sampleName();
String refBamPath = getReferenceBamDownload().getLocalTargetPath();
Driver driver = new Driver(resourceFiles, VmDirectories.outputFile(referenceSampleName + ".assembly.bam")).referenceSample(referenceSampleName, refBamPath);
return gridssCommands(driver, referenceSampleName);
}
use of com.hartwig.pipeline.calling.structural.gridss.stage.Driver in project pipeline5 by hartwigmedical.
the class Gridss method tumorReferenceCommands.
@Override
public List<BashCommand> tumorReferenceCommands(final SomaticRunMetadata metadata) {
String referenceSampleName = metadata.reference().sampleName();
String tumorSampleName = metadata.tumor().sampleName();
String refBamPath = getReferenceBamDownload().getLocalTargetPath();
String tumorBamPath = getTumorBamDownload().getLocalTargetPath();
return gridssCommands(new Driver(resourceFiles, VmDirectories.outputFile(tumorSampleName + ".assembly.bam")).tumorSample(tumorSampleName, tumorBamPath).referenceSample(referenceSampleName, refBamPath), tumorSampleName);
}
Aggregations