private CanvasOutput RunSingleSample(string sampleId, CanvasTumorNormalEnrichmentInput input, IFileLocation bAlleleVcf, bool isDbSnpVcf, IFileLocation manifest, IDirectoryLocation sampleSandbox) { if (!_annotationFileProvider.IsSupported(input.GenomeMetadata)) { _logger.Info($"Skipping Canvas for sample {sampleId}: unsupported reference genome '{input.GenomeMetadata.Name}'"); return(null); } StringBuilder commandLine = new StringBuilder("Tumor-normal-enrichment"); commandLine.Append(_singleSampleInputCommandLineBuilder.GetSingleSampleCommandLine(sampleId, input.TumorBam, input.GenomeMetadata, sampleSandbox)); commandLine.Append($" --normal-bam \"{input.NormalBam.BamFile}\""); commandLine.Append($" --manifest \"{manifest}\""); var bAlleleVcfOptionName = isDbSnpVcf ? SingleSampleCommonOptionsParser.PopulationBAlleleVcfOptionName : SingleSampleCommonOptionsParser.SampleBAlleleVcfOptionName; commandLine.Append($" --{bAlleleVcfOptionName} {bAlleleVcf.WrapWithShellQuote()}"); commandLine.Append($" --somatic-vcf \"{input.SomaticVcf.VcfFile}\""); AddPloidyVcf(commandLine, SingleSampleCommonOptionsParser.PloidyVcfOptionName, input, sampleId, sampleSandbox); commandLine.Append(_singleSampleInputCommandLineBuilder.GetCustomParameters()); commandLine = _singleSampleInputCommandLineBuilder.MergeCustomCanvasParameters(commandLine); var job = new JobInfo(_runtimeExecutable.FullName, _canvasExe + " " + commandLine, "Canvas_" + sampleId); return(_workDoer.DoWork(WorkResourceRequest.CreateExact(1, 8), job, GetCanvasOutput(sampleId, sampleSandbox)).Await()); }
private CanvasOutput RunSingleSample(string sampleId, CanvasResequencingInput input, IDirectoryLocation sampleSandbox) { if (!_annotationFileProvider.IsSupported(input.GenomeMetadata)) { _logger.Info($"Skipping Canvas for sample {sampleId}: unsupported reference genome '{input.GenomeMetadata.Name}'"); return(null); } if (!_annotationFileProvider.CustomDbSnpVcf(input.GenomeMetadata) && input.Vcf == null) { _logger.Info($"Skipping Canvas for sample {sampleId}. A dbSNP VCF file was not provided and no small variant VCF file is available"); return(null); } StringBuilder commandLine = new StringBuilder("Germline-WGS"); commandLine.Append(_singleSampleInputCommandLineBuilder.GetSingleSampleCommandLine(sampleId, input.Bam, input.GenomeMetadata, sampleSandbox)); // use sample vcf by default (performance could be similar with dbSNP vcf though) var bAlleleVcf = input.Vcf.VcfFile; var bAlleleVcfOptionName = SingleSampleCommonOptionsParser.SampleBAlleleVcfOptionName; if (_annotationFileProvider.CustomDbSnpVcf(input.GenomeMetadata)) { bAlleleVcf = _annotationFileProvider.GetDbSnpVcf(input.GenomeMetadata); bAlleleVcfOptionName = SingleSampleCommonOptionsParser.PopulationBAlleleVcfOptionName; } commandLine.Append($" --{bAlleleVcfOptionName} \"{bAlleleVcf}\""); IFileLocation ploidyBed = _canvasPloidyBedCreator.CreateGermlinePloidyBed(input.Vcf, input.GenomeMetadata, sampleSandbox); if (ploidyBed != null) { commandLine.Append($" --{SingleSampleCommonOptionsParser.PloidyBedOptionName} \"{ploidyBed}\""); } var canvasPartitionParam = $@"--commoncnvs {_annotationFileProvider.GetCanvasAnnotationFile(input.GenomeMetadata, "commoncnvs.bed")}"; var moreCustomParameters = new Dictionary <string, string>(); moreCustomParameters["CanvasPartition"] = canvasPartitionParam; commandLine.Append(_singleSampleInputCommandLineBuilder.GetCustomParameters(moreCustomParameters)); commandLine = _singleSampleInputCommandLineBuilder.MergeCustomCanvasParameters(commandLine); UnitOfWork singleSampleJob = new UnitOfWork() { ExecutablePath = CrossPlatform.IsThisLinux() ? _runtimeExecutable.FullName : _canvasExe.FullName, CommandLine = CrossPlatform.IsThisLinux() ? _canvasExe + " " + commandLine : commandLine.ToString(), LoggingFolder = _workManager.LoggingFolder.FullName, LoggingStub = "Canvas_" + sampleId, }; _workManager.DoWorkSingleThread(singleSampleJob); return(GetCanvasOutput(sampleId, sampleSandbox)); }
private CanvasOutput RunSingleSample(string sampleId, CanvasTumorNormalEnrichmentInput input, IFileLocation bAlleleVcf, bool isDbSnpVcf, IFileLocation manifest, IDirectoryLocation sampleSandbox) { if (!_annotationFileProvider.IsSupported(input.GenomeMetadata)) { _logger.Info($"Skipping Canvas for sample {sampleId}: unsupported reference genome '{input.GenomeMetadata.Name}'"); return(null); } StringBuilder commandLine = new StringBuilder("Tumor-normal-enrichment"); commandLine.Append(_singleSampleInputCommandLineBuilder.GetSingleSampleCommandLine(sampleId, input.TumorBam, input.GenomeMetadata, sampleSandbox)); commandLine.Append($" --normal-bam \"{input.NormalBam.BamFile}\""); commandLine.Append($" --manifest \"{manifest}\""); var bAlleleVcfOptionName = isDbSnpVcf ? SingleSampleCommonOptionsParser.PopulationBAlleleVcfOptionName : SingleSampleCommonOptionsParser.SampleBAlleleVcfOptionName; commandLine.Append($" --{bAlleleVcfOptionName} {bAlleleVcf.WrapWithShellQuote()}"); commandLine.Append($" --somatic-vcf \"{input.SomaticVcf.VcfFile}\""); IFileLocation ploidyBed = _canvasPloidyBedCreator.CreatePloidyBed(input.NormalVcf, input.GenomeMetadata, sampleSandbox); if (ploidyBed != null) { commandLine.Append($" --{SingleSampleCommonOptionsParser.PloidyBedOptionName} \"{ploidyBed}\""); } commandLine.Append(_singleSampleInputCommandLineBuilder.GetCustomParameters()); commandLine = _singleSampleInputCommandLineBuilder.MergeCustomCanvasParameters(commandLine); UnitOfWork singleSampleJob = new UnitOfWork { ExecutablePath = CrossPlatform.IsThisLinux() ? _runtimeExecutable.FullName : _canvasExe.FullName, CommandLine = CrossPlatform.IsThisLinux() ? _canvasExe + " " + commandLine : commandLine.ToString(), LoggingFolder = _workManager.LoggingFolder.FullName, LoggingStub = "Canvas_" + sampleId, }; _workManager.DoWorkSingleThread(singleSampleJob); return(GetCanvasOutput(sampleId, sampleSandbox)); }
private CanvasOutput RunSingleSample(string sampleId, CanvasTumorNormalWgsInput input, IDirectoryLocation sampleSandbox) { if (!_annotationFileProvider.IsSupported(input.GenomeMetadata)) { _logger.Info($"Skipping Canvas for sample {sampleId}: unsupported reference genome '{input.GenomeMetadata.Name}'"); return(null); } StringBuilder commandLine = new StringBuilder("Somatic-WGS"); commandLine.Append(_singleSampleInputCommandLineBuilder.GetSingleSampleCommandLine(sampleId, input.TumorBam, input.GenomeMetadata, sampleSandbox)); commandLine.Append($" --{SingleSampleCommonOptionsParser.SampleBAlleleVcfOptionName} \"{input.NormalVcf.VcfFile}\""); commandLine.Append($" --somatic-vcf \"{input.SomaticVcf.VcfFile}\""); if (input.SexPloidy == null) { _logger.Warn("Sex chromosome ploidy not available. No ploidy will be provided to Canvas."); } else { _canvasPloidyVcfCreator.AddPloidyVcfOption(commandLine, SingleSampleCommonOptionsParser.PloidyVcfOptionName, input.GenomeMetadata, input.SexPloidy, sampleId, sampleSandbox); } commandLine.Append(_singleSampleInputCommandLineBuilder.GetCustomParameters()); commandLine = _singleSampleInputCommandLineBuilder.MergeCustomCanvasParameters(commandLine); UnitOfWork singleSampleJob = new UnitOfWork() { ExecutablePath = _runtimeExecutable.FullName, CommandLine = _canvasExe + " " + commandLine, LoggingStub = "Canvas_" + sampleId, }; var job = new JobInfo(_runtimeExecutable.FullName, _canvasExe + " " + commandLine, "Canvas_" + sampleId); return(_workDoer.DoWork(WorkResourceRequest.CreateExact(1, 8), job, GetCanvasOutput(sampleId, sampleSandbox)).Await()); }
private CanvasEnrichmentOutput RunSingleSample(string sampleId, CanvasEnrichmentInput input, IFileLocation dbSnpVcf, IFileLocation manifest, IDirectoryLocation sampleSandbox) { if (!_annotationFileProvider.IsSupported(input.GenomeMetadata)) { _logger.Info($"Skipping Canvas for sample {sampleId}: unsupported reference genome '{input.GenomeMetadata.Name}'"); return(null); } var moreCustomParameters = new Dictionary <string, string>(); StringBuilder commandLine = new StringBuilder("Somatic-Enrichment"); commandLine.Append(_singleSampleInputCommandLineBuilder.GetSingleSampleCommandLine(sampleId, input.Bam, input.GenomeMetadata, sampleSandbox)); string sexChromosomeKaryotype = null; if (input.PloidyInfo.IsPloidyAvailable) { sexChromosomeKaryotype = input.PloidyInfo.IsXYMale.Value ? PloidyCorrector.PrettyPrintPloidy(1, 1) : (input.PloidyInfo.IsXXFemale.Value ? PloidyCorrector.PrettyPrintPloidy(2, 0) : null); } string controlSexChromosomeKaryotype = null; if (input.IsCanvasNormalizePcaMode && input.PloidyInfo.IsPloidyAvailable) { IFileLocation pcaModelFile = input.PloidyInfo.IsXYMale.Value ? input.PcaModels.MaleModelFile : (input.PloidyInfo.IsXXFemale.Value ? input.PcaModels.FemaleModelFile : null); if (pcaModelFile == null) { string sampleSex = input.PloidyInfo.IsXYMale.Value ? "male" : (input.PloidyInfo.IsXXFemale.Value ? "female" : "sex unknown"); _logger.Info($"Skipping Canvas for sample {sampleId}: PCA model file not available for {sampleSex} samples."); return(null); } moreCustomParameters["CanvasNormalize"] = "-m PCA"; commandLine.Append($" --control-binned \"{pcaModelFile}\""); commandLine.Append($" --control-bin-size 100"); // use a dummy bin size for now controlSexChromosomeKaryotype = sexChromosomeKaryotype; } else if (input.PrecomputedControl?.BinnedPath != null) { commandLine.Append($" --control-binned \"{input.PrecomputedControl.BinnedPath}\""); commandLine.Append($" --control-bin-size {input.PrecomputedControl.BinSize}"); controlSexChromosomeKaryotype = input.PrecomputedControl.SexChromosomeKaryotype; } else { foreach (var normalBam in input.NormalBamPaths) { commandLine.Append($" --control-bam \"{normalBam.BamFile}\""); } } AddControlPloidyVcf(commandLine, input, controlSexChromosomeKaryotype, sampleId, sampleSandbox); commandLine.Append($" --{SingleSampleCommonOptionsParser.PopulationBAlleleVcfOptionName} \"{dbSnpVcf}\""); commandLine.Append($" --manifest \"{manifest}\""); AddSamplePloidyVcf(commandLine, input, sexChromosomeKaryotype, sampleId, sampleSandbox); if (input.PredefinedBinsFile != null) { moreCustomParameters["CanvasBin"] = $"-n={input.PredefinedBinsFile.WrapWithEscapedShellQuote()}"; } commandLine.Append(_singleSampleInputCommandLineBuilder.GetCustomParameters(moreCustomParameters)); commandLine = _singleSampleInputCommandLineBuilder.MergeCustomCanvasParameters(commandLine); var job = new JobInfo(_runtimeExecutable.FullName, _canvasExe + " " + commandLine, "Canvas_" + sampleId); return(_workDoer.DoWork(WorkResourceRequest.CreateExact(1, 8), job, GetCanvasOutput(sampleId, sampleSandbox)).Await()); }
private CanvasEnrichmentOutput RunSingleSample(string sampleId, CanvasEnrichmentInput input, IFileLocation dbSnpVcf, IFileLocation manifest, IDirectoryLocation sampleSandbox) { if (!_annotationFileProvider.IsSupported(input.GenomeMetadata)) { _logger.Info($"Skipping Canvas for sample {sampleId}: unsupported reference genome '{input.GenomeMetadata.Name}'"); return(null); } var moreCustomParameters = new Dictionary <string, string>(); StringBuilder commandLine = new StringBuilder("Somatic-Enrichment"); commandLine.Append(_singleSampleInputCommandLineBuilder.GetSingleSampleCommandLine(sampleId, input.Bam, input.GenomeMetadata, sampleSandbox)); string sexChromosomeKaryotype = null; if (input.PloidyInfo.IsPloidyAvailable) { sexChromosomeKaryotype = input.PloidyInfo.IsXYMale.Value ? PloidyCorrector.PrettyPrintPloidy(1, 1) : (input.PloidyInfo.IsXXFemale.Value ? PloidyCorrector.PrettyPrintPloidy(2, 0) : null); } string controlSexChromosomeKaryotype = null; if (input.IsCanvasNormalizePcaMode && input.PloidyInfo.IsPloidyAvailable) { IFileLocation pcaModelFile = input.PloidyInfo.IsXYMale.Value ? input.PcaModels.MaleModelFile : (input.PloidyInfo.IsXXFemale.Value ? input.PcaModels.FemaleModelFile : null); if (pcaModelFile == null) { string sampleSex = input.PloidyInfo.IsXYMale.Value ? "male" : (input.PloidyInfo.IsXXFemale.Value ? "female" : "sex unknown"); _logger.Info($"Skipping Canvas for sample {sampleId}: PCA model file not available for {sampleSex} samples."); return(null); } moreCustomParameters["CanvasNormalize"] = "-m PCA"; commandLine.Append($" --control-binned \"{pcaModelFile}\""); commandLine.Append($" --control-bin-size 100"); // use a dummy bin size for now controlSexChromosomeKaryotype = sexChromosomeKaryotype; } else if (input.PrecomputedControl?.BinnedPath != null) { commandLine.Append($" --control-binned \"{input.PrecomputedControl.BinnedPath}\""); commandLine.Append($" --control-bin-size {input.PrecomputedControl.BinSize}"); controlSexChromosomeKaryotype = input.PrecomputedControl.SexChromosomeKaryotype; } else { foreach (var normalBam in input.NormalBamPaths) { commandLine.Append($" --control-bam \"{normalBam.BamFile}\""); } } if (controlSexChromosomeKaryotype != null) { var controlPloidyBed = sampleSandbox.GetFileLocation("control-ploidy.bed.gz"); if (_canvasPloidyBedCreator.GeneratePloidyBedFileFromSexChromosomeKaryotype(input.GenomeMetadata, input.GenomeMetadata.Sequences.First().FastaPath, controlSexChromosomeKaryotype, controlPloidyBed.FullName, sampleSandbox.FullName)) { commandLine.Append($" --{SomaticEnrichmentOptionsParser.ControlPloidyBedOptionName} \"{controlPloidyBed}\""); } } commandLine.Append($" --{SingleSampleCommonOptionsParser.PopulationBAlleleVcfOptionName} \"{dbSnpVcf}\""); commandLine.Append($" --manifest \"{manifest}\""); if (sexChromosomeKaryotype != null) { var ploidyBed = sampleSandbox.GetFileLocation("ploidy.bed.gz"); if (_canvasPloidyBedCreator.GeneratePloidyBedFileFromSexChromosomeKaryotype(input.GenomeMetadata, input.GenomeMetadata.Sequences.First().FastaPath, sexChromosomeKaryotype, ploidyBed.FullName, sampleSandbox.FullName)) { commandLine.Append($" --{SingleSampleCommonOptionsParser.PloidyBedOptionName} \"{ploidyBed}\""); } } if (input.PredefinedBinsFile != null) { moreCustomParameters["CanvasBin"] = $"-n={input.PredefinedBinsFile.WrapWithEscapedShellQuote()}"; } commandLine.Append(_singleSampleInputCommandLineBuilder.GetCustomParameters(moreCustomParameters)); commandLine = _singleSampleInputCommandLineBuilder.MergeCustomCanvasParameters(commandLine); UnitOfWork singleSampleJob = new UnitOfWork() { ExecutablePath = CrossPlatform.IsThisLinux() ? _runtimeExecutable.FullName : _canvasExe.FullName, CommandLine = CrossPlatform.IsThisLinux() ? _canvasExe + " " + commandLine : commandLine.ToString(), LoggingFolder = _workManager.LoggingFolder.FullName, LoggingStub = "Canvas_" + sampleId, }; _workManager.DoWorkSingleThread(singleSampleJob); return(GetCanvasOutput(sampleId, sampleSandbox)); }