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();
}
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]));
}
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();
}
Aggregations