Search in sources :

Example 1 with PipeCommands

use of com.hartwig.pipeline.execution.vm.unix.PipeCommands in project pipeline5 by hartwigmedical.

the class Bam2Fastq method execute.

@Override
public VirtualMachineJobDefinition execute(InputBundle inputs, RuntimeBucket bucket, BashStartupScript startupScript, RuntimeFiles executionFlags) {
    InputFileDescriptor descriptor = inputs.get();
    String localCopyOfBam = format("%s/%s", VmDirectories.INPUT, new File(descriptor.inputValue()).getName());
    startupScript.addCommand(() -> descriptor.toCommandForm(localCopyOfBam));
    startupScript.addCommand(new PipeCommands(new SambambaCommand("view", "-H", localCopyOfBam), () -> "grep ^@RG", () -> "grep -cP \"_L00[1-8]_\""));
    List<String> picargs = ImmutableList.of("SamToFastq", "ODIR=" + VmDirectories.OUTPUT, "OPRG=true", "RGT=ID", "NON_PF=true", "RC=true", "I=" + localCopyOfBam);
    startupScript.addCommand(new JavaJarCommand("picard", "2.18.27", "picard.jar", "16G", picargs));
    startupScript.addCommand(() -> format("rename 's/(.+)_(.+)_(.+)_(.+)_(.+)__(.+)\\.fastq/$1_$2_$3_$4_R$6_$5.fastq/' %s/*.fastq", VmDirectories.OUTPUT));
    startupScript.addCommand(() -> format("pigz %s/*.fastq", VmDirectories.OUTPUT));
    startupScript.addCommand(new OutputUpload(GoogleStorageLocation.of(bucket.name(), "bam2fastq"), executionFlags));
    return ImmutableVirtualMachineJobDefinition.builder().name("bam2fastq").startupCommand(startupScript).namespacedResults(ResultsDirectory.defaultDirectory()).workingDiskSpaceGb(1800).performanceProfile(VirtualMachinePerformanceProfile.custom(4, 20)).build();
}
Also used : PipeCommands(com.hartwig.pipeline.execution.vm.unix.PipeCommands) OutputUpload(com.hartwig.pipeline.execution.vm.OutputUpload) InputFileDescriptor(com.hartwig.batch.input.InputFileDescriptor) SambambaCommand(com.hartwig.pipeline.execution.vm.SambambaCommand) JavaJarCommand(com.hartwig.pipeline.execution.vm.java.JavaJarCommand) File(java.io.File)

Example 2 with PipeCommands

use of com.hartwig.pipeline.execution.vm.unix.PipeCommands in project pipeline5 by hartwigmedical.

the class BcfToolsCommandListBuilder method bcfCommand.

@VisibleForTesting
BashCommand bcfCommand() {
    if (currentArguments == null) {
        throw new IllegalStateException("No bcftools command added.");
    }
    final List<BashCommand> finalCommands = Lists.newArrayList(pipedCommands);
    final BashCommand finalCommand = new BcfToolsCommand(currentArguments, "-O", "z", "-o", outputVcf);
    finalCommands.add(finalCommand);
    return new PipeCommands(finalCommands.toArray(new BashCommand[0]));
}
Also used : PipeCommands(com.hartwig.pipeline.execution.vm.unix.PipeCommands) BashCommand(com.hartwig.pipeline.execution.vm.BashCommand) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with PipeCommands

use of com.hartwig.pipeline.execution.vm.unix.PipeCommands in project pipeline5 by hartwigmedical.

the class FlagstatGenerator method execute.

@Override
public VirtualMachineJobDefinition execute(final InputBundle inputs, final RuntimeBucket bucket, final BashStartupScript startupScript, final RuntimeFiles executionFlags) {
    InputFileDescriptor input = inputs.get();
    InputFileDescriptor existingFlagstat = InputFileDescriptor.from(input).withInputValue(input.inputValue().replaceAll("\\.bam$", ".flagstat"));
    String localCopyOfOriginalFlagstat = format("%s/%s", VmDirectories.OUTPUT, new File(existingFlagstat.inputValue()).getName());
    String outputFile = VmDirectories.outputFile(new File(input.inputValue()).getName().replaceAll("\\.bam$", ".batch.flagstat"));
    String localInput = format("%s/%s", VmDirectories.INPUT, new File(input.inputValue()).getName());
    startupScript.addCommand(() -> input.toCommandForm(localInput));
    startupScript.addCommand(() -> existingFlagstat.toCommandForm(localCopyOfOriginalFlagstat));
    startupScript.addCommand(new PipeCommands(new VersionedToolCommand("sambamba", "sambamba", Versions.SAMBAMBA, "flagstat", "-t", Bash.allCpus(), localInput), () -> "tee " + outputFile));
    startupScript.addCommand(() -> format("diff %s %s", localCopyOfOriginalFlagstat, outputFile));
    startupScript.addCommand(new OutputUpload(GoogleStorageLocation.of(bucket.name(), "flagstat"), executionFlags));
    return VirtualMachineJobDefinition.builder().name("flagstat").startupCommand(startupScript).namespacedResults(ResultsDirectory.defaultDirectory()).performanceProfile(VirtualMachinePerformanceProfile.custom(4, 6)).build();
}
Also used : PipeCommands(com.hartwig.pipeline.execution.vm.unix.PipeCommands) OutputUpload(com.hartwig.pipeline.execution.vm.OutputUpload) InputFileDescriptor(com.hartwig.batch.input.InputFileDescriptor) File(java.io.File) VersionedToolCommand(com.hartwig.pipeline.calling.command.VersionedToolCommand)

Aggregations

PipeCommands (com.hartwig.pipeline.execution.vm.unix.PipeCommands)3 InputFileDescriptor (com.hartwig.batch.input.InputFileDescriptor)2 OutputUpload (com.hartwig.pipeline.execution.vm.OutputUpload)2 File (java.io.File)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 VersionedToolCommand (com.hartwig.pipeline.calling.command.VersionedToolCommand)1 BashCommand (com.hartwig.pipeline.execution.vm.BashCommand)1 SambambaCommand (com.hartwig.pipeline.execution.vm.SambambaCommand)1 JavaJarCommand (com.hartwig.pipeline.execution.vm.java.JavaJarCommand)1