Search in sources :

Example 31 with ResourceFiles

use of com.hartwig.pipeline.resource.ResourceFiles in project pipeline5 by hartwigmedical.

the class LilacPcawgBatch method addSampleCommands.

private void addSampleCommands(final InputFileDescriptor runData, final BashStartupScript commands, final String runDirectory, final String sampleId) {
    final String referenceAlignment = String.format("%s/%s_ref.bam", VmDirectories.INPUT, sampleId);
    final String tumorAlignment = String.format("%s/%s_tumor.bam", VmDirectories.INPUT, sampleId);
    // download sample BAM files
    commands.addCommand(() -> format("gsutil -m -u hmf-crunch cp gs://%s/%s/* %s", PCAWG_BAM_BUCKET, sampleId, VmDirectories.INPUT));
    // build Lilac arguments
    String sampleOutputDir = String.format("%s/%s/", VmDirectories.OUTPUT, sampleId);
    commands.addCommand(() -> format("mkdir -p %s", sampleOutputDir));
    final ResourceFiles resourceFiles = ResourceFilesFactory.buildResourceFiles(RefGenomeVersion.V37);
    StringBuilder lilacArgs = new StringBuilder();
    lilacArgs.append(String.format(" -sample %s", sampleId));
    lilacArgs.append(String.format(" -resource_dir %s", VmDirectories.INPUT));
    lilacArgs.append(String.format(" -ref_genome %s", resourceFiles.refGenomeFile()));
    lilacArgs.append(String.format(" -reference_bam %s", referenceAlignment));
    lilacArgs.append(String.format(" -tumor_bam %s", tumorAlignment));
    lilacArgs.append(" -run_id REF");
    lilacArgs.append(String.format(" -output_dir %s", sampleOutputDir));
    // lilacArgs.append(String.format(" -gene_copy_number_file %s", geneCopyNumber));
    // lilacArgs.append(String.format(" -somatic_variants_file %s", somaticVcf));
    lilacArgs.append(" -max_elim_candidates 500");
    lilacArgs.append(String.format(" -threads %s", Bash.allCpus()));
    commands.addCommand(() -> format("java -Xmx%s -jar %s/%s %s", MAX_HEAP, VmDirectories.TOOLS, LILAC_JAR, lilacArgs.toString()));
    // and a tumor-only run
    String tumorOutputDir = String.format("%s/%s/tumor", VmDirectories.OUTPUT, sampleId);
    commands.addCommand(() -> format("mkdir -p %s", tumorOutputDir));
    StringBuilder tumorLilacArgs = new StringBuilder();
    tumorLilacArgs.append(String.format(" -sample %s", sampleId));
    tumorLilacArgs.append(String.format(" -resource_dir %s", VmDirectories.INPUT));
    tumorLilacArgs.append(String.format(" -ref_genome %s", resourceFiles.refGenomeFile()));
    tumorLilacArgs.append(String.format(" -reference_bam %s", tumorAlignment));
    tumorLilacArgs.append(" -run_id TUMOR");
    lilacArgs.append(" -max_elim_candidates 500");
    tumorLilacArgs.append(String.format(" -output_dir %s", tumorOutputDir));
    tumorLilacArgs.append(String.format(" -threads %s", Bash.allCpus()));
    commands.addCommand(() -> format("java -Xmx%s -jar %s/%s %s", MAX_HEAP, VmDirectories.TOOLS, LILAC_JAR, tumorLilacArgs.toString()));
    String sampleRemoteOutputDir = String.format("gs://%s/%s/", LILAC_BATCH_BUCKET, runDirectory);
    commands.addCommand(() -> format("gsutil -m cp -r %s/%s/ %s", VmDirectories.OUTPUT, sampleId, sampleRemoteOutputDir));
}
Also used : ResourceFiles(com.hartwig.pipeline.resource.ResourceFiles)

Example 32 with ResourceFiles

use of com.hartwig.pipeline.resource.ResourceFiles in project pipeline5 by hartwigmedical.

the class PurpleGermline method bashCommands.

public List<BashCommand> bashCommands(final InputBundle inputs) {
    final List<BashCommand> commands = Lists.newArrayList();
    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("ref_sample").inputValue();
    final GoogleStorageLocation sageVcfStorage = sageSomaticFilteredFile(set, tumorSampleName);
    final GoogleStorageLocation sageIndexStorage = index(sageVcfStorage);
    // gripssSomaticFilteredFile(set, tumorSampleName);
    final GoogleStorageLocation gripssVcfStorage = null;
    // index(gripssVcfStorage);
    final GoogleStorageLocation gripssVcfIndexStorage = null;
    // gripssRecoveryFile(set, tumorSampleName);
    final GoogleStorageLocation gripssRecoveryVcfStorage = null;
    final GoogleStorageLocation gripssRecoveryVcfIndexStorage = index(gripssRecoveryVcfStorage);
    final String amberInputDir = VmDirectories.INPUT + "/amber";
    final String cobaltInputDir = VmDirectories.INPUT + "/cobalt";
    final InputDownload amberLocation = new InputDownload(amberArchiveDirectory(set), amberInputDir);
    final InputDownload cobaltLocation = new InputDownload(cobaltArchiveDirectory(set), cobaltInputDir);
    final InputDownload sageLocation = new InputDownload(sageVcfStorage);
    final InputDownload sageLocationIndex = new InputDownload(sageIndexStorage);
    final InputDownload gripssLocation = new InputDownload(gripssVcfStorage);
    final InputDownload gripssLocationIndex = new InputDownload(gripssVcfIndexStorage);
    final InputDownload gripssRecoveryLocation = new InputDownload(gripssRecoveryVcfStorage);
    final InputDownload gripssRecoveryLocationIndex = new InputDownload(gripssRecoveryVcfIndexStorage);
    final String germlineVcf = VmDirectories.INPUT + "/" + tumorSampleName + ".sage.germline.filtered.vcf.gz";
    // gsutil ls gs://batch-sage-germline/*/sage/WIDE01010012T*germline.filtered.vcf.gz*
    commands.add(() -> String.format("gsutil -m cp gs://batch-sage-germline/*/sage/%s*germline.filtered.vcf.gz* %s/", tumorSampleName, VmDirectories.INPUT));
    commands.add(() -> "mkdir -p " + amberInputDir);
    commands.add(() -> "mkdir -p " + cobaltInputDir);
    // commands.add(downloadExperimentalVersion());
    commands.add(amberLocation);
    commands.add(cobaltLocation);
    commands.add(sageLocation);
    commands.add(sageLocationIndex);
    commands.add(gripssLocation);
    commands.add(gripssLocationIndex);
    commands.add(gripssRecoveryLocation);
    commands.add(gripssRecoveryLocationIndex);
    BashCommand purpleCommand = new PurpleCommandBuilder(resourceFiles, amberLocation.getLocalTargetPath(), cobaltLocation.getLocalTargetPath(), tumorSampleName, gripssLocation.getLocalTargetPath(), gripssRecoveryLocation.getLocalTargetPath(), sageLocation.getLocalTargetPath()).addGermline(germlineVcf).build();
    commands.add(purpleCommand);
    return commands;
}
Also used : ResourceFiles(com.hartwig.pipeline.resource.ResourceFiles) BashCommand(com.hartwig.pipeline.execution.vm.BashCommand) InputDownload(com.hartwig.pipeline.execution.vm.InputDownload) ImmutableGoogleStorageLocation(com.hartwig.pipeline.storage.ImmutableGoogleStorageLocation) GoogleStorageLocation(com.hartwig.pipeline.storage.GoogleStorageLocation) PurpleCommandBuilder(com.hartwig.pipeline.tertiary.purple.PurpleCommandBuilder)

Example 33 with ResourceFiles

use of com.hartwig.pipeline.resource.ResourceFiles in project pipeline5 by hartwigmedical.

the class AmberRerun 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);
    // 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 ResourceFiles resourceFiles = ResourceFilesFactory.buildResourceFiles(RefGenomeVersion.V37);
    commands.addCommand(() -> AmberCommandBuilder.newBuilder(resourceFiles).reference(referenceSampleName, localReferenceFile).tumor(tumorSampleName, localTumorFile).build().asBash());
    // Store output
    final GoogleStorageLocation archiveStorageLocation = amberArchiveDirectory(set);
    commands.addCommand(new CopyLogToOutput(executionFlags.log(), "run.log"));
    commands.addCommand(new OutputUpload(archiveStorageLocation));
    return VirtualMachineJobDefinition.amber(commands, ResultsDirectory.defaultDirectory());
}
Also used : ResourceFiles(com.hartwig.pipeline.resource.ResourceFiles) OutputUpload(com.hartwig.pipeline.execution.vm.OutputUpload) InputFileDescriptor(com.hartwig.batch.input.InputFileDescriptor) CopyLogToOutput(com.hartwig.pipeline.execution.vm.CopyLogToOutput) GoogleStorageLocation(com.hartwig.pipeline.storage.GoogleStorageLocation)

Aggregations

ResourceFiles (com.hartwig.pipeline.resource.ResourceFiles)33 OutputUpload (com.hartwig.pipeline.execution.vm.OutputUpload)24 InputFileDescriptor (com.hartwig.batch.input.InputFileDescriptor)23 StringJoiner (java.util.StringJoiner)13 GoogleStorageLocation (com.hartwig.pipeline.storage.GoogleStorageLocation)10 RemoteLocationsApi (com.hartwig.batch.api.RemoteLocationsApi)8 ResourceFilesFactory.buildResourceFiles (com.hartwig.pipeline.resource.ResourceFilesFactory.buildResourceFiles)7 CopyLogToOutput (com.hartwig.pipeline.execution.vm.CopyLogToOutput)5 SubStageInputOutput (com.hartwig.pipeline.stages.SubStageInputOutput)5 LocalLocations (com.hartwig.batch.api.LocalLocations)4 InputDownload (com.hartwig.pipeline.execution.vm.InputDownload)4 RefGenomeVersion (com.hartwig.pipeline.resource.RefGenomeVersion)4 BwaCommand (com.hartwig.pipeline.calling.command.BwaCommand)3 SamtoolsCommand (com.hartwig.pipeline.calling.command.SamtoolsCommand)3 OutputFile (com.hartwig.pipeline.execution.vm.OutputFile)3 AlignmentOutput (com.hartwig.pipeline.alignment.AlignmentOutput)2 SageApplication (com.hartwig.pipeline.calling.sage.SageApplication)2 SageCommandBuilder (com.hartwig.pipeline.calling.sage.SageCommandBuilder)2 GridssAnnotation (com.hartwig.pipeline.calling.structural.gridss.stage.GridssAnnotation)2 PipelineStatus (com.hartwig.pipeline.execution.PipelineStatus)2