示例#1
0
        private CanvasOutput GetCanvasOutput(string sampleId, IDirectoryLocation sampleSandbox)
        {
            var           cnvVcf                        = new Vcf(sampleSandbox.GetFileLocation("CNV.vcf.gz"));
            var           tempCnvDirectory              = sampleSandbox.GetDirectoryLocation($"TempCNV_{sampleId}");
            var           variantFrequencies            = tempCnvDirectory.GetFileLocation($"VFResults{sampleId}.txt.gz");
            var           variantFrequenciesBaf         = tempCnvDirectory.GetFileLocation($"VFResults{sampleId}.txt.gz.baf");
            IFileLocation coverageAndVariantFrequencies = sampleSandbox.GetFileLocation("CNV.CoverageAndVariantFrequency.txt");
            IFileLocation tempStub                      = tempCnvDirectory.GetFileLocation($"{sampleId}");
            IFileLocation partitioned                   = tempStub.AppendName(".partitioned");

            return(new CanvasOutput(cnvVcf, coverageAndVariantFrequencies, variantFrequencies,
                                    variantFrequenciesBaf, partitioned));
        }
        /// <summary>
        ///  Write out the ploidy bed file if ploidy information is available from the vcf header
        /// Only create the normal XX or XY ploidy bed file so that Canvas can properly classify any abnormalities as variant.
        /// If ploidy Y is > 1 produce the XY ploidy bed file, otherwise produce the XX ploidy bed file
        /// </summary>
        public IFileLocation CreateGermlinePloidyBed(Vcf vcf, GenomeMetadata genomeMetadata, IDirectoryLocation sampleSandbox)
        {
            string sexKaryotype = PloidyCorrector.GetSexChromosomeKaryotypeFromVcfHeader(vcf.VcfFile.FullName);

            if (sexKaryotype == null)
            {
                _logger.Warn($"Sex chromosome ploidy not found in {vcf.VcfFile} header. No ploidy will be provided to Canvas.");
                return(null);
            }
            _logger.Info($"Found sex chromosome ploidy {PloidyCorrector.PrintPloidy(sexKaryotype)} in {vcf.VcfFile}");
            var           ploidyInfo = new SamplePloidyInfo();
            IFileLocation ploidyBed  = sampleSandbox.GetFileLocation("ploidy.bed.gz");

            if (sexKaryotype.ToLower().Contains("y"))
            {
                ploidyInfo.ProvidedPloidy = SexPloidyInfo.NormalMale;
                _logger.Info($"Creating male ploidy bed file at {ploidyBed}.");
            }
            else
            {
                ploidyInfo.ProvidedPloidy = SexPloidyInfo.NormalFemale;
                _logger.Info($"Creating female ploidy bed file at {ploidyBed}.");
            }
            string headerLine = $"{PloidyCorrector.ReferenceSexChromosomeKaryotype}={PloidyCorrector.PrettyPrintPloidy(ploidyInfo.ProvidedPloidyX.Value, ploidyInfo.ProvidedPloidyY.Value)}";

            _ploidyFixer.WritePloidyBedFile(ploidyInfo, genomeMetadata, _ploidyFixer.GetParRegions(genomeMetadata),
                                            ploidyBed.FullName, headerLine, ploidy => true);
            return(ploidyBed);
        }
        private IFileLocation WriteManifest(NexteraManifest manifest, IDirectoryLocation sandbox)
        {
            var path = sandbox.GetFileLocation(manifest.Name);

            NexteraManifestUtils.WriteNexteraManifests(manifest, path.FullName);
            return(path);
        }
        private IFileLocation CreateDbSnpVcfForManifest(IFileLocation fullDbSnpVcf, NexteraManifest manifest, IDirectoryLocation sandBox)
        {
            IFileLocation targetedDbSnpVcf = sandBox.GetFileLocation($"{manifest.Name}_{fullDbSnpVcf.Name}");

            Isas.Manifests.NexteraManifest.VcfUtilities.IntersectVcfWithManifest(fullDbSnpVcf.FullName, targetedDbSnpVcf.FullName, manifest);
            return(targetedDbSnpVcf);
        }
示例#5
0
        public CanvasCallset(
            IFileLocation bam,
            string sampleName,
            IDirectoryLocation wholeGenomeFastaFolder,
            IDirectoryLocation outputFolder,
            IFileLocation kmerFasta,
            IFileLocation filterBed,
            IFileLocation ploidyBed,
            IFileLocation normalVcfPath,
            bool isDbSnpVcf,
            IEnumerable<IFileLocation> normalBamPaths,
            NexteraManifest manifest,
            IFileLocation somaticVcfPath,
            IFileLocation outputVcfPath)
        {
            Bam = new Bam(bam);
            SampleName = sampleName;
            WholeGenomeFastaFolder = wholeGenomeFastaFolder;
            OutputFolder = outputFolder;
            KmerFasta = kmerFasta;
            FilterBed = filterBed;
            PloidyBed = ploidyBed;
            NormalVcfPath = normalVcfPath;
            IsDbSnpVcf = isDbSnpVcf;
            Manifest = manifest;
            SomaticVcfPath = somaticVcfPath;
            OutputVcfPath = outputVcfPath;
            NormalBamPaths = normalBamPaths.Select(file => new Bam(file));

            var genomeSizeXml = WholeGenomeFastaFolder.GetFileLocation("GenomeSize.xml");
            GenomeMetadata = new GenomeMetadata();
            GenomeMetadata.Deserialize(genomeSizeXml.FullName);
        }
示例#6
0
        /// <summary>
        /// Write out the ploidy vcf file if ploidy information is available from the vcf header
        /// </summary>
        public Vcf CreatePloidyVcf(SampleSet <SexPloidyInfo> ploidyInfos, GenomeMetadata genomeMetadata, IDirectoryLocation sampleSandbox)
        {
            var ploidyVcf = new Vcf(sampleSandbox.GetFileLocation(PloidyVcfName));

            _ploidyFixer.WritePloidyVcfFile(ploidyVcf, ploidyInfos, genomeMetadata);
            return(ploidyVcf);
        }
示例#7
0
        public CanvasCallset(
            IFileLocation bam,
            string sampleName,
            IDirectoryLocation wholeGenomeFastaFolder,
            IDirectoryLocation outputFolder,
            IFileLocation kmerFasta,
            IFileLocation filterBed,
            IFileLocation ploidyBed,
            IFileLocation normalVcfPath,
            bool isDbSnpVcf,
            IEnumerable <IFileLocation> normalBamPaths,
            NexteraManifest manifest,
            IFileLocation somaticVcfPath,
            IFileLocation outputVcfPath)
        {
            Bam                    = new Bam(bam);
            SampleName             = sampleName;
            WholeGenomeFastaFolder = wholeGenomeFastaFolder;
            OutputFolder           = outputFolder;
            KmerFasta              = kmerFasta;
            FilterBed              = filterBed;
            PloidyBed              = ploidyBed;
            NormalVcfPath          = normalVcfPath;
            IsDbSnpVcf             = isDbSnpVcf;
            Manifest               = manifest;
            SomaticVcfPath         = somaticVcfPath;
            OutputVcfPath          = outputVcfPath;
            NormalBamPaths         = normalBamPaths.Select(file => new Bam(file));

            var genomeSizeXml = WholeGenomeFastaFolder.GetFileLocation("GenomeSize.xml");

            GenomeMetadata = new GenomeMetadata();
            GenomeMetadata.Deserialize(genomeSizeXml.FullName);
        }
示例#8
0
        public int Run(string[] args, TextWriter standardOutput, TextWriter standardError)
        {
            if (IsMissingMode(args))
            {
                return(HandleMissingMode(args, standardOutput, standardError));
            }

            var commonOptionsResult = ParseCommonOptions(args);

            if (!commonOptionsResult.Success)
            {
                return(Parse(args, standardOutput.WriteLine, standardError.WriteLine));
            }
            var commonOptions = commonOptionsResult.Result;

            if (AnyBaseOptions(args, out BaseOptions baseOptions))
            {
                HandleBaseOptions(baseOptions, standardOutput.WriteLine, GetMode(args));
                return(0);
            }
            IDirectoryLocation outFolder = commonOptions.OutputDirectory;
            var log   = outFolder.GetFileLocation("CanvasLog.txt");
            var error = outFolder.GetFileLocation("CanvasError.txt");
            IDirectoryLocation genomeRoot = commonOptions.WholeGenomeFasta?.Parent?.Parent?.Parent?.Parent?.Parent;
            int returnValue = 0;

            IsasFrameworkFactory.RunWithLogger(log, error, logger =>
            {
                ISettings settings = new ProgrammaticSettingsBuilder()
                                     .WithSetting(IsasConfigurationSettings.GenomeRepositoryPath, genomeRoot)
                                     .ToSettings();
                settings = new NestedSettingsProcessor(settings, IsasConfigurationSettings.GetConfigSettings());
                IsasFrameworkFactory.RunWithWorkDoer(logger, settings, outFolder, workDoer =>
                {
                    IsasFrameworkFactory.RunWithCheckpointer(logger, outFolder, settings, commonOptions.StartCheckpoint,
                                                             commonOptions.StopCheckpoint, checkpointer =>
                    {
                        var result  = Parse(logger, settings, checkpointer, workDoer, args, standardOutput, standardError);
                        returnValue = result.Success ? result.Result.Launch() : -1;
                    });
                });
            });

            return(returnValue);
        }
        private CanvasEnrichmentOutput GetCanvasOutput(string sampleId, IDirectoryLocation sampleSandbox)
        {
            var           cnvVcf                        = new Vcf(sampleSandbox.GetFileLocation("CNV.vcf.gz"));
            var           tempCnvDirectory              = sampleSandbox.GetDirectoryLocation($"TempCNV_{sampleId}");
            var           variantFrequencies            = tempCnvDirectory.GetFileLocation($"VFResults{sampleId}.txt.gz");
            var           variantFrequenciesBaf         = tempCnvDirectory.GetFileLocation($"VFResults{sampleId}.txt.gz.baf");
            IFileLocation coverageAndVariantFrequencies = sampleSandbox.GetFileLocation("CNV.CoverageAndVariantFrequency.txt");
            IFileLocation tempStub                      = tempCnvDirectory.GetFileLocation($"{sampleId}");
            IFileLocation partitioned                   = tempStub.AppendName(".partitioned");
            var           canvasOutput                  = new CanvasOutput(cnvVcf, coverageAndVariantFrequencies, variantFrequencies,
                                                                           variantFrequenciesBaf, partitioned);
            IFileLocation binSize       = tempStub.AppendName(".binsize");
            IFileLocation normalBinned  = tempStub.AppendName(".normal.binned");
            IFileLocation unsmoothedCnd = tempStub.AppendName(".ratio.binned.cnd");

            if (!binSize.Exists)
            {
                binSize = null;
            }
            return(new CanvasEnrichmentOutput(canvasOutput, binSize, normalBinned, unsmoothedCnd));
        }
示例#10
0
        public int Launch()
        {
            CommonOptions      commonOptions = _modeRunner.CommonOptions;
            IDirectoryLocation outFolder     = commonOptions.OutputDirectory;
            var log   = outFolder.GetFileLocation("CanvasLog.txt");
            var error = outFolder.GetFileLocation("CanvasError.txt");

            using (ILogger logger = new Logger(log, error))
            {
                try
                {
                    logger.Info($"Running Canvas {_mode} {_version}");
                    logger.Info($"Command-line arguments: {string.Join(" ", _args)}");
                    var checkpointRunner =
                        GetCheckpointRunner(
                            logger,
                            outFolder,
                            commonOptions.StartCheckpoint,
                            commonOptions.StopCheckpoint,
                            commonOptions.WholeGenomeFasta);
                    using (var manager = checkpointRunner.Manager)
                    {
                        IDirectoryLocation loggingFolder = outFolder.CreateSubdirectory("Logging");
                        IsasConfiguration  config        = IsasConfiguration.GetConfiguration();
                        IWorkManager       workManager   = new LocalWorkManager(logger, loggingFolder, 0, config.MaximumMemoryGB, config.MaximumHoursPerProcess);
                        _modeRunner.Run(logger, checkpointRunner, workManager);
                        manager.CheckFinalState();
                    }
                }
                catch (StopCheckpointFoundException) { }
                catch (Exception e)
                {
                    logger.Error($"Canvas workflow error: {e}");
                    return(-1);
                }
            }
            return(0);
        }
示例#11
0
        public AnalysisDetails(IDirectoryLocation outputFolder, IDirectoryLocation wholeGenomeFastaFolder,
                               IFileLocation kmerFasta, IFileLocation filterBed, IFileLocation ploidyVcf, IFileLocation commonCnvsBed)
        {
            WholeGenomeFastaFolder = wholeGenomeFastaFolder;
            OutputFolder           = outputFolder;
            KmerFasta     = kmerFasta;
            FilterBed     = filterBed;
            PloidyVcf     = ploidyVcf;
            CommonCnvsBed = commonCnvsBed;
            var genomeSizeXml = WholeGenomeFastaFolder.GetFileLocation("GenomeSize.xml");

            GenomeMetadata = new GenomeMetadata();
            GenomeMetadata.Deserialize(genomeSizeXml);
        }
示例#12
0
        public int Launch()
        {
            CommonOptions      commonOptions = _modeRunner.CommonOptions;
            IDirectoryLocation outFolder     = commonOptions.OutputDirectory;
            var log   = outFolder.GetFileLocation("CanvasLog.txt");
            var error = outFolder.GetFileLocation("CanvasError.txt");
            IsasConfiguration  config     = IsasConfiguration.GetConfiguration();
            IDirectoryLocation genomeRoot = commonOptions.WholeGenomeFasta?.Parent?.Parent?.Parent?.Parent?.Parent;
            int returnValue = 0;

            IsasFrameworkFactory.RunWithIsasFramework(outFolder, log, error, commonOptions.StartCheckpoint, commonOptions.StopCheckpoint, 0,
                                                      config.MaximumMemoryGB, config.MaximumHoursPerProcess, false, genomeRoot,
                                                      frameworkServices =>
            {
                var logger = frameworkServices.Logger;
                try
                {
                    var executableProcessor = new ExecutableProcessor(new NullSampleSettings(), logger);
#if DotNetCore
                    var runtimeExecutable = new FileLocation(executableProcessor.GetEnvironmentExecutablePath("dotnet"));
#else
                    var runtimeExecutable = CrossPlatform.IsThisLinux() ? new FileLocation(executableProcessor.GetMonoPath()) : null;
#endif
                    frameworkServices.Logger.Info($"Running Canvas {_mode} {_version}");
                    logger.Info($"Command-line arguments: {string.Join(" ", _args)}");
                    _modeRunner.Run(logger, frameworkServices.Checkpointer, frameworkServices.WorkManager, runtimeExecutable);
                    returnValue = 0;
                }
                catch (Exception e)
                {
                    logger.Error($"Canvas workflow error: {e}");
                    returnValue = -1;
                }
            });
            return(returnValue);
        }
        private CanvasSmallPedigreeOutput GetCanvasOutput(SampleSet <Bam> pedigreeBams, IDirectoryLocation sampleSandbox)
        {
            var readGroupSamples    = pedigreeBams.SelectData(GetReadGroupSample);
            var intermediateResults = readGroupSamples.SelectData(readGroupSample =>
            {
                var variantFrequencies            = SingleSampleCallset.GetVfSummaryPath(sampleSandbox, readGroupSample);
                var variantFrequenciesBaf         = SingleSampleCallset.GetVfSummaryBafPath(sampleSandbox, readGroupSample);
                var partitioned                   = SingleSampleCallset.GetPartitionedPath(sampleSandbox, readGroupSample);
                var coverageAndVariantFrequencies = SingleSampleCallset.GetCoverageAndVariantFrequencyOutput(sampleSandbox, readGroupSample);
                return(new IntermediateOutput(coverageAndVariantFrequencies, variantFrequencies, variantFrequenciesBaf, partitioned));
            });
            var cnvVcf = new Vcf(sampleSandbox.GetFileLocation("CNV.vcf.gz"));

            return(new CanvasSmallPedigreeOutput(cnvVcf, intermediateResults));
        }
示例#14
0
        /// <summary>
        /// Write out the ploidy bed file if ploidy information is available from the vcf header
        /// </summary>
        public IFileLocation CreatePloidyBed(Vcf vcf, GenomeMetadata genomeMetadata, IDirectoryLocation sampleSandbox)
        {
            IFileLocation ploidyBed = sampleSandbox.GetFileLocation("ploidy.bed.gz");
            string        fastaPath = genomeMetadata.Sequences.First().FastaPath;

            if (_ploidyFixer.GeneratePloidyBedFileFromVcf(
                    genomeMetadata,
                    fastaPath,
                    vcf.VcfFile.FullName,
                    ploidyBed.FullName, sampleSandbox.FullName, _logger, _workManager))
            {
                return(ploidyBed);
            }
            _logger.Warn($"Sex chromosome ploidy not found in {vcf.VcfFile} header. No ploidy will be provided to Canvas.");
            return(null);
        }
        private CanvasSmallPedigreeOutput GetCanvasOutput(SampleSet <CanvasPedigreeSample> pedigreeSamples, IDirectoryLocation sampleSandbox)
        {
            var intermediateResults = pedigreeSamples.SelectSamples(sampleInfo =>
            {
                var sampleId                      = sampleInfo.Id;
                var variantFrequencies            = SingleSampleCallset.GetVfSummaryPath(sampleSandbox, sampleId);
                var variantFrequenciesBaf         = SingleSampleCallset.GetVfSummaryBafPath(sampleSandbox, sampleId);
                var partitioned                   = SingleSampleCallset.GetPartitionedPath(sampleSandbox, sampleId);
                var coverageAndVariantFrequencies = SingleSampleCallset.GetCoverageAndVariantFrequencyOutput(sampleSandbox, sampleId);
                var singleSampleVcf               = SingleSampleCallset.GetVcfOutput(sampleSandbox, sampleId);
                var coverageBigwig                = SingleSampleCallset.GetCoverageBigWig(sampleSandbox, sampleId);
                var bAlleleBedgraph               = SingleSampleCallset.GetBAlleleBedGraph(sampleSandbox, sampleId);
                var copyNumberBedgraph            = SingleSampleCallset.GetCopyNumberBedGraph(sampleSandbox, sampleId);
                return(new IntermediateOutput(new Vcf(singleSampleVcf), coverageAndVariantFrequencies, variantFrequencies, variantFrequenciesBaf,
                                              partitioned, coverageBigwig, bAlleleBedgraph, copyNumberBedgraph));
            });
            var cnvVcf = new Vcf(sampleSandbox.GetFileLocation("CNV.vcf.gz"));

            return(new CanvasSmallPedigreeOutput(cnvVcf, intermediateResults));
        }
示例#16
0
        public IFileLocation Write(IReadOnlyList <CanvasSegment> segments, IDirectoryLocation output,
                                   double normalizationFactor)
        {
            _logger.Info($"Begin writing bedgraph file at '{output}'");
            var benchmark = new Benchmark();
            var bedGraph  = output.GetFileLocation("coverage.bedgraph");

            _writer.Write(segments, bedGraph, normalizationFactor);
            _logger.Info($"Finished writing bedgraph file at '{bedGraph}'. Elapsed time: {benchmark.GetElapsedTime()}");
            _logger.Info($"Begin conversion of '{bedGraph}' to bigwig file");
            benchmark = new Benchmark();
            var bigWigConverterOutput = output.CreateSubdirectory("BigWigConverter");
            var bigwigFile            = _converter.Convert(bedGraph, _genome, bigWigConverterOutput);

            if (bigwigFile != null)
            {
                _logger.Info(
                    $"Finished conversion from bedgraph file at '{bedGraph}' to bigwig file at '{bigwigFile}'. Elapsed time: {benchmark.GetElapsedTime()}");
            }
            return(bigwigFile);
        }
示例#17
0
        private static void ComputeCallability(ILogger logger, Dictionary <string, List <CnvCall> > callsByContig,
                                               EvaluateCnvOptions options, IDirectoryLocation output)
        {
            var kmerFasta           = new FileLocation(options.KmerFa);
            var canvasAnnotationDir = kmerFasta.Directory;
            var filterBed           = canvasAnnotationDir.GetFileLocation("filter13.bed");

            if (!filterBed.Exists)
            {
                throw new ArgumentException($"Missing file at {filterBed}");
            }
            var annotationDir   = canvasAnnotationDir.Parent;
            var buildDir        = annotationDir.Parent;
            var genome          = new ReferenceGenome(buildDir).GenomeMetadata;
            var computer        = CallabilityMetricsComputer.Create(logger, genome, filterBed, options.PloidyInfo.SexPloidyInfo.PloidyY == 0);
            var callability     = computer.CalculateMetric(callsByContig.SelectValues(calls => calls.Where(call => call.PassFilter).ToList()));
            var callabilityFile = output.GetFileLocation($"{options.BaseFileName}_callability.txt");

            File.WriteAllLines(callabilityFile.FullName, callability.GetMetrics().Select(metric => metric.ToCsv().Replace(",", "\t")));
            logger.Info($"Callability: {callability.Callability}. Called bases: {callability.CalledBases}. Total bases: {callability.TotalBases}.");
        }
示例#18
0
        /// <summary>
        /// Copy a directory to a new location. Input is the directory location for the resulting copied directory and not the parent directory. 
        /// If newDirectoryLocation already exists it is first removed. 
        /// Returns newDirectoryLocation to enable chaining
        /// </summary>
        public IDirectoryLocation CopyTo(IDirectoryLocation newDirectoryLocation)
        {
            if (newDirectoryLocation.FullName == FullName) return this;
            newDirectoryLocation.CreateClean();

            foreach (IFileLocation file in EnumerateFiles())
            {
                file.CopyTo(newDirectoryLocation.GetFileLocation(file.Name));
            }
            foreach (IDirectoryLocation subdir in EnumerateDirectories())
            {
                subdir.CopyInto(newDirectoryLocation);
            }
            return newDirectoryLocation;
        }
        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));
        }
示例#20
0
        /// <summary>
        /// Moves an existing file into a parent directory, overwriting any existing file.
        /// </summary>
        /// <param name="destination">The parent directory for the new location of the file.</param>
        /// <returns>
        /// The new location of the file
        /// </returns>
        public IFileLocation MoveInto(IDirectoryLocation destination)
        {
            if (Directory.FullName.Equals(destination.FullName)) // Doesn't handle symlinks...
                return this;

            var result = destination.GetFileLocation(Name);
            MoveTo(result);
            return result;
        }
示例#21
0
 public static IFileLocation SymlinkInto(this IFileLocation sourceFile, IDirectoryLocation destFolder)
 {
     IFileLocation dest = destFolder.GetFileLocation(sourceFile.Name);
     return sourceFile.SymlinkTo(dest);
 }
示例#22
0
 public static IFileLocation MoveAndLinkInto(this IFileLocation source, IDirectoryLocation destination)
 {
     return source.MoveAndLink(destination.GetFileLocation(source.Name));
 }