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