Search in sources :

Example 1 with LocalLocations

use of com.hartwig.batch.api.LocalLocations in project pipeline5 by hartwigmedical.

the class LilacBatch method addSampleCommands.

private void addSampleCommands(final InputFileDescriptor runData, final BashStartupScript commands, final String runDirectory, final String sampleId, boolean hasRna) {
    final RemoteLocationsApi locationsApi = new RemoteLocationsApi(runData.billedProject(), sampleId);
    final LocalLocations localInput = new LocalLocations(new BamSliceDecorator(locationsApi));
    final String somaticVcf = localInput.getSomaticVariantsPurple();
    final String geneCopyNumber = localInput.getGeneCopyNumberTsv();
    final String tumorAlignment = localInput.getTumorAlignment();
    final String referenceAlignment = localInput.getReferenceAlignment();
    final String rnaAlignment = hasRna ? String.format("%s.rna.hla.bam", sampleId) : "";
    // download sample input files
    commands.addCommands(localInput.generateDownloadCommands());
    if (hasRna) {
        commands.addCommand(() -> format("gsutil -m cp gs://%s/%s/%s* %s", HLA_BAMS_BUCKET, sampleId, rnaAlignment, 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);
    StringJoiner lilacArgs = new StringJoiner(" ");
    lilacArgs.add(String.format(" -sample %s", sampleId));
    lilacArgs.add(String.format(" -resource_dir %s", VmDirectories.INPUT));
    lilacArgs.add(String.format(" -ref_genome %s", resourceFiles.refGenomeFile()));
    lilacArgs.add(String.format(" -reference_bam %s", referenceAlignment));
    lilacArgs.add(String.format(" -tumor_bam %s", tumorAlignment));
    if (hasRna) {
        lilacArgs.add(String.format(" -rna_bam %s/%s", VmDirectories.INPUT, rnaAlignment));
    }
    lilacArgs.add(String.format(" -output_dir %s", sampleOutputDir));
    lilacArgs.add(String.format(" -gene_copy_number_file %s", geneCopyNumber));
    lilacArgs.add(String.format(" -somatic_variants_file %s", somaticVcf));
    lilacArgs.add(String.format(" -threads %s", Bash.allCpus()));
    commands.addCommand(() -> format("java -Xmx%s -jar %s/%s %s", MAX_HEAP, VmDirectories.TOOLS, LILAC_JAR, lilacArgs.toString()));
    /*
        if(tumorOnly)
        {
            String tumorOutputDir = String.format("%s/%s/tumor", VmDirectories.OUTPUT, sampleId);
            commands.addCommand(() -> format("mkdir -p %s", tumorOutputDir));

            StringBuilder tumorLilacArgs = new StringBuilder();
            tumorLilacArgs.add(String.format(" -sample %s", sampleId));
            tumorLilacArgs.add(String.format(" -resource_dir %s", LOCAL_LILAC_RESOURCES));
            tumorLilacArgs.add(String.format(" -ref_genome %s", resourceFiles.refGenomeFile()));
            tumorLilacArgs.add(String.format(" -reference_bam %s", tumorAlignment));
            tumorLilacArgs.add(" -tumor_only");
            tumorLilacArgs.add(String.format(" -output_dir %s", tumorOutputDir));
            tumorLilacArgs.add(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) LocalLocations(com.hartwig.batch.api.LocalLocations) StringJoiner(java.util.StringJoiner) RemoteLocationsApi(com.hartwig.batch.api.RemoteLocationsApi)

Example 2 with LocalLocations

use of com.hartwig.batch.api.LocalLocations in project pipeline5 by hartwigmedical.

the class PurpleRerun method bashCommands.

public List<BashCommand> bashCommands(RemoteLocations locations) {
    final LocalLocations batchInput = new LocalLocations(locations);
    final List<BashCommand> commands = Lists.newArrayList();
    final ResourceFiles resourceFiles = ResourceFilesFactory.buildResourceFiles(RefGenomeVersion.V37);
    final String tumorSampleName = batchInput.getTumor();
    final String referenceSampleName = batchInput.getReference();
    final String amberLocation = batchInput.getAmber();
    final String cobaltLocation = batchInput.getCobalt();
    final String sageSomaticLocation = batchInput.getSomaticVariantsSage();
    final String sageGermlineLocation = batchInput.getGermlineVariantsSage();
    final String gripssLocation = batchInput.getStructuralVariantsGripss();
    final String gripssRecoveryLocation = batchInput.getStructuralVariantsGripssRecovery();
    commands.addAll(batchInput.generateDownloadCommands());
    PurpleCommandBuilder builder = new PurpleCommandBuilder(resourceFiles, amberLocation, cobaltLocation, tumorSampleName, gripssLocation, gripssRecoveryLocation, sageSomaticLocation).addGermline(sageGermlineLocation);
    commands.add(builder.build());
    return commands;
}
Also used : ResourceFiles(com.hartwig.pipeline.resource.ResourceFiles) LocalLocations(com.hartwig.batch.api.LocalLocations) BashCommand(com.hartwig.pipeline.execution.vm.BashCommand) PurpleCommandBuilder(com.hartwig.pipeline.tertiary.purple.PurpleCommandBuilder)

Example 3 with LocalLocations

use of com.hartwig.batch.api.LocalLocations in project pipeline5 by hartwigmedical.

the class LocalLocationsTest method testSelectFileAfterDownload.

@Test(expected = IllegalStateException.class)
public void testSelectFileAfterDownload() {
    LocalLocations local = new LocalLocations(remoteLocations);
    List<BashCommand> commands = local.generateDownloadCommands();
    String alignment = local.getTumorAlignment();
}
Also used : LocalLocations(com.hartwig.batch.api.LocalLocations) BashCommand(com.hartwig.pipeline.execution.vm.BashCommand) Test(org.junit.Test)

Example 4 with LocalLocations

use of com.hartwig.batch.api.LocalLocations in project pipeline5 by hartwigmedical.

the class SageGermlineOld method execute.

@Override
public VirtualMachineJobDefinition execute(final InputBundle inputs, final RuntimeBucket runtimeBucket, final BashStartupScript commands, final RuntimeFiles executionFlags) {
    // Inputs
    final InputFileDescriptor biopsy = inputs.get("biopsy");
    final LocalLocations localInput = new LocalLocations(new RemoteLocationsApi(biopsy));
    final String tumorSampleName = localInput.getTumor();
    final String referenceSampleName = localInput.getReference();
    final String tumorAlignment = localInput.getTumorAlignment();
    final String referenceAlignment = localInput.getReferenceAlignment();
    final ResourceFiles resourceFiles = ResourceFilesFactory.buildResourceFiles(RefGenomeVersion.V37);
    // Download Inputs
    commands.addCommands(localInput.generateDownloadCommands());
    return VirtualMachineJobDefinition.sageGermlineCalling(commands, ResultsDirectory.defaultDirectory());
}
Also used : ResourceFiles(com.hartwig.pipeline.resource.ResourceFiles) InputFileDescriptor(com.hartwig.batch.input.InputFileDescriptor) LocalLocations(com.hartwig.batch.api.LocalLocations) RemoteLocationsApi(com.hartwig.batch.api.RemoteLocationsApi)

Example 5 with LocalLocations

use of com.hartwig.batch.api.LocalLocations in project pipeline5 by hartwigmedical.

the class LocalLocationsTest method testDownloadTumorAlignmentIndex.

@Test
public void testDownloadTumorAlignmentIndex() {
    LocalLocations local = new LocalLocations(remoteLocations);
    String alignment = local.getTumorAlignment();
    List<BashCommand> commands = local.generateDownloadCommands();
    assertEquals(commands.get(0).asBash(), PREFIX + "gs://alignment/171006_COLO829/COLO929v003T.cram /data/input/COLO929v003T.cram");
    assertEquals(commands.get(1).asBash(), PREFIX + "gs://alignment/171006_COLO829/COLO929v003T.crai /data/input/COLO929v003T.crai");
}
Also used : LocalLocations(com.hartwig.batch.api.LocalLocations) BashCommand(com.hartwig.pipeline.execution.vm.BashCommand) Test(org.junit.Test)

Aggregations

LocalLocations (com.hartwig.batch.api.LocalLocations)7 BashCommand (com.hartwig.pipeline.execution.vm.BashCommand)4 ResourceFiles (com.hartwig.pipeline.resource.ResourceFiles)4 RemoteLocationsApi (com.hartwig.batch.api.RemoteLocationsApi)3 Test (org.junit.Test)3 InputFileDescriptor (com.hartwig.batch.input.InputFileDescriptor)2 StringJoiner (java.util.StringJoiner)2 OutputUpload (com.hartwig.pipeline.execution.vm.OutputUpload)1 PurpleCommandBuilder (com.hartwig.pipeline.tertiary.purple.PurpleCommandBuilder)1