public void CreateBamReader() { // Should return a fully functional bam reader var tempPath = $"TemporaryBamFile_{Guid.NewGuid()}.bam"; if (File.Exists(tempPath)) { File.Delete(tempPath); } using (var bamWriter = new BamWriter(tempPath, "header", new List <GenomeMetadata.SequenceMetadata>())) { var bamWriterHandle = new BamWriterHandle(bamWriter); bamWriterHandle.WriteAlignment(TestHelpers.CreateBamAlignment("ATCG", 8, 10, 30, true)); bamWriterHandle.WriteAlignment(null); } Assert.True(File.Exists(tempPath)); var stitcherOptions = new StitcherOptions(); var factory = new GeminiDataSourceFactory(stitcherOptions, "fakeGenomePath", false); using (var bamReader = factory.CreateBamReader(tempPath)) { BamAlignment alignment = new BamAlignment(); var getNext = bamReader.GetNextAlignment(ref alignment, true); Assert.True(getNext); Assert.Equal(7, alignment.Position); } File.Delete(tempPath); }
public void CreateReadPairSource() { var stitcherOptions = new StitcherOptions(); var factory = new GeminiDataSourceFactory(stitcherOptions, "fakeGenomePath", false); var bamReader = new Mock <IBamReader>(); var readPairSource = factory.CreateReadPairSource(bamReader.Object, new ReadStatusCounter()); Assert.Equal(typeof(PairFilterReadPairSource), readPairSource.GetType()); // TODO maybe I can do some asserts on the configuration of the readpair source by passing through some reads and checking result? that's pretty indirect though. }
private static string ProcessChromosome(Dictionary <string, int> chromRefIds, string outMultiPath, List <string> taskDirectories, string chrom, GeminiMultiOptions options) { // TODO either officially deprecate non-multiprocess-processing and remove this, or consolidate this with the Gemini calling code from Gemini/Program.cs var outdir = Path.Combine(outMultiPath, chrom); var refId = chromRefIds[chrom]; var intermediate = string.IsNullOrEmpty(options.GeminiSampleOptions.IntermediateDir) ? null : Path.Combine(options.GeminiSampleOptions.IntermediateDir, chrom); var geminiSampleOptions = new GeminiSampleOptions { InputBam = options.InputBam, OutputFolder = outdir, OutputBam = Path.Combine(outdir, "out.bam"), IntermediateDir = intermediate, RefId = refId }; // Gemini defaults different than stitcher defaults options.StitcherOptions.NifyUnstitchablePairs = false; // Set stitcher pair-filter-level duplicate filtering if skip and remove dups, to save time options.StitcherOptions.FilterDuplicates = options.GeminiOptions.SkipAndRemoveDups; var dataSourceFactory = new GeminiDataSourceFactory(options.StitcherOptions, options.GeminiOptions.GenomePath, options.GeminiOptions.SkipAndRemoveDups, refId, Path.Combine(outdir, "Regions.txt"), debug: options.GeminiOptions.Debug); var dataOutputFactory = new GeminiDataOutputFactory(options.StitcherOptions.NumThreads); var samtoolsWrapper = new SamtoolsWrapper(options.GeminiOptions.SamtoolsPath, options.GeminiOptions.IsWeirdSamtools); var geminiWorkflow = new GeminiWorkflow(dataSourceFactory, dataOutputFactory, options.GeminiOptions, geminiSampleOptions, options.RealignmentOptions, options.StitcherOptions, options.OutputDirectory, options.RealignmentAssessmentOptions, options.IndelFilteringOptions, samtoolsWrapper); Directory.CreateDirectory(outdir); geminiWorkflow.Execute(); //var logger = new Illumina.CG.Common.Logging.Logger(taskLogDir, $"GeminiTaskLog_{chrom}.txt"); //var task = _taskCreator.GetCliTask(cmdLineList.ToArray(), chrom, exePath, outdir, chromRefIds[chrom], logger, // string.IsNullOrEmpty(_options.GeminiSampleOptions.IntermediateDir) // ? null // : Path.Combine(_options.GeminiSampleOptions.IntermediateDir, chrom)); //tasks.Add(task); Console.WriteLine($"Completed Gemini Workflow for {chrom}"); var path = (Path.Combine(outdir, "merged.bam.sorted.bam")); taskDirectories.Add(outdir); //paths[refId] = path; return(path); }
//wrapper should now handle all throwing and catching.. protected override void ProgramExecution() { _options.GeminiSampleOptions.InputBam = _options.InputBam; _options.GeminiSampleOptions.OutputFolder = _options.OutputDirectory; _options.GeminiSampleOptions.OutputBam = Path.Combine(_options.OutputDirectory, "out.bam"); _options.GeminiOptions.Debug = _options.StitcherOptions.Debug; // Gemini defaults different than stitcher defaults _options.StitcherOptions.NifyUnstitchablePairs = false; // Set stitcher pair-filter-level duplicate filtering if skip and remove dups, to save time _options.StitcherOptions.FilterDuplicates = _options.GeminiOptions.SkipAndRemoveDups; var dataSourceFactory = new GeminiDataSourceFactory(_options.StitcherOptions, _options.GeminiOptions.GenomePath, _options.GeminiOptions.SkipAndRemoveDups, _options.GeminiSampleOptions.RefId, Path.Combine(_options.OutputDirectory, "Regions.txt"), debug: _options.GeminiOptions.Debug); var dataOutputFactory = new GeminiDataOutputFactory(_options.StitcherOptions.NumThreads); var samtoolsWrapper = new SamtoolsWrapper(_options.GeminiOptions.SamtoolsPath, _options.GeminiOptions.IsWeirdSamtools); var geminiWorkflow = new GeminiWorkflow(dataSourceFactory, dataOutputFactory, _options.GeminiOptions, _options.GeminiSampleOptions, _options.RealignmentOptions, _options.StitcherOptions, _options.OutputDirectory, _options.RealignmentAssessmentOptions, _options.IndelFilteringOptions, samtoolsWrapper); geminiWorkflow.Execute(); }