Search in sources :

Example 1 with Driver

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());
}
Also used : OutputFile(com.hartwig.pipeline.execution.vm.OutputFile) ExportPathCommand(com.hartwig.pipeline.execution.vm.unix.ExportPathCommand) InputFileDescriptor(com.hartwig.batch.input.InputFileDescriptor) Driver(com.hartwig.pipeline.calling.structural.gridss.stage.Driver) SubStageInputOutput(com.hartwig.pipeline.stages.SubStageInputOutput) GridssAnnotation(com.hartwig.pipeline.calling.structural.gridss.stage.GridssAnnotation) RemoteLocationsApi(com.hartwig.batch.api.RemoteLocationsApi) BwaCommand(com.hartwig.pipeline.calling.command.BwaCommand) ResourceFiles(com.hartwig.pipeline.resource.ResourceFiles) SamtoolsCommand(com.hartwig.pipeline.calling.command.SamtoolsCommand) OutputUpload(com.hartwig.pipeline.execution.vm.OutputUpload) InputDownload(com.hartwig.pipeline.execution.vm.InputDownload) GoogleStorageLocation(com.hartwig.pipeline.storage.GoogleStorageLocation)

Example 2 with Driver

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);
}
Also used : Driver(com.hartwig.pipeline.calling.structural.gridss.stage.Driver)

Example 3 with Driver

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);
}
Also used : Driver(com.hartwig.pipeline.calling.structural.gridss.stage.Driver)

Example 4 with Driver

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);
}
Also used : Driver(com.hartwig.pipeline.calling.structural.gridss.stage.Driver)

Aggregations

Driver (com.hartwig.pipeline.calling.structural.gridss.stage.Driver)4 RemoteLocationsApi (com.hartwig.batch.api.RemoteLocationsApi)1 InputFileDescriptor (com.hartwig.batch.input.InputFileDescriptor)1 BwaCommand (com.hartwig.pipeline.calling.command.BwaCommand)1 SamtoolsCommand (com.hartwig.pipeline.calling.command.SamtoolsCommand)1 GridssAnnotation (com.hartwig.pipeline.calling.structural.gridss.stage.GridssAnnotation)1 InputDownload (com.hartwig.pipeline.execution.vm.InputDownload)1 OutputFile (com.hartwig.pipeline.execution.vm.OutputFile)1 OutputUpload (com.hartwig.pipeline.execution.vm.OutputUpload)1 ExportPathCommand (com.hartwig.pipeline.execution.vm.unix.ExportPathCommand)1 ResourceFiles (com.hartwig.pipeline.resource.ResourceFiles)1 SubStageInputOutput (com.hartwig.pipeline.stages.SubStageInputOutput)1 GoogleStorageLocation (com.hartwig.pipeline.storage.GoogleStorageLocation)1