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()); }
public CanvasSmallPedigreeOutput Run(CanvasSmallPedigreeInput input, IDirectoryLocation sampleSandbox) { if (!_annotationFileProvider.IsSupported(input.GenomeMetadata)) { _logger.Info($"Skipping Canvas: unsupported reference genome '{input.GenomeMetadata.Name}'"); return(null); } if (!_annotationFileProvider.CustomDbSnpVcf(input.GenomeMetadata) && input.Vcf == null) { _logger.Info($"Skipping Canvas. A dbSNP VCF file was not provided and no small variant VCF file is available"); return(null); } var commandLine = new StringBuilder("SmallPedigree-WGS"); commandLine.Append(GetMultiSampleCommandLine(input.Samples, input.GenomeMetadata, input.Vcf, 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}\""); var ploidyInfos = input.Samples.SelectData(sample => sample.PloidyInfo); var ploidyVcf = _canvasPloidyVcfCreator.CreatePloidyVcf(ploidyInfos, input.GenomeMetadata, sampleSandbox); if (ploidyVcf != null) { commandLine.Append($" --{SmallPedigreeOptionsParser.PloidyVcfOptionName} \"{ploidyVcf.VcfFile}\""); } var moreCustomParameters = new Dictionary <string, string>(); // common cnv feature disabled by default due to CANV-397 // string canvasPedigreeCallerParam = $@"--commoncnvs {_annotationFileProvider.GetCanvasAnnotationFile(input.GenomeMetadata, "commoncnvs.bed")}"; // moreCustomParameters["CanvasPedigreeCaller"] = canvasPedigreeCallerParam; commandLine.Append(_singleSampleInputCommandLineBuilder.GetCustomParameters(moreCustomParameters)); commandLine = _singleSampleInputCommandLineBuilder.MergeCustomCanvasParameters(commandLine); // use Proband or, when proband is not available, first sample as pedigree id var pedigreeId = input.Samples.Where(x => x.Value.SampleType == SampleType.Proband).Select(x => x.Key.Id).FirstOrDefault(); if (pedigreeId.IsNullOrEmpty()) { pedigreeId = input.Samples.First().Key.Id; } var job = new JobInfo(_runtimeExecutable.FullName, _canvasExe + " " + commandLine, "Canvas_" + pedigreeId); return(_workDoer.DoWork(WorkResourceRequest.CreateExact(1, 8), job, GetCanvasOutput(input.Samples, sampleSandbox)).Await()); }
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()); }