예제 #1
0
        private static ExitCodes ProgramExecution()
        {
            var rootDirectory = new FileInfo(MitoMapFileNames[0]).Directory;

            if (rootDirectory == null)
            {
                return(ExitCodes.PathNotFound);
            }
            var version          = DataSourceVersionReader.GetSourceVersion(Path.Combine(rootDirectory.ToString(), "mitoMapSv"));
            var sequenceProvider = new ReferenceSequenceProvider(FileUtilities.GetReadStream(_compressedReference));
            var chrom            = sequenceProvider.RefNameToChromosome["chrM"];

            sequenceProvider.LoadChromosome(chrom);
            var mitoMapSvReaders      = MitoMapFileNames.Select(mitoMapFileName => new MitoMapSvReader(new FileInfo(mitoMapFileName), sequenceProvider)).ToList();
            var mergedMitoMapVarItems = MitoMapSvReader.MergeAndSort(mitoMapSvReaders);

            string outFileName = $"{version.Name}_{version.Version}";

            using (var nsaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.SiFileSuffix)))
            {
                var nsiWriter = new NsiWriter(new ExtendedBinaryWriter(nsaStream), version, GenomeAssembly.rCRS, SaCommon.MitoMapTag, ReportFor.StructuralVariants, SaCommon.SchemaVersion);
                nsiWriter.Write(mergedMitoMapVarItems);
            }

            return(ExitCodes.Success);
        }
예제 #2
0
        private void CreateMitoMapSvTsv(IReadOnlyList <string> mitoMapSvFileNames)
        {
            if (mitoMapSvFileNames.Count == 0 || mitoMapSvFileNames.Any(string.IsNullOrEmpty))
            {
                return;
            }
            var benchMark        = new Benchmark();
            var rootDirectory    = new FileInfo(mitoMapSvFileNames[0]).Directory;
            var version          = DataSourceVersionReader.GetSourceVersion(Path.Combine(rootDirectory.ToString(), "mitoMapSV"));
            var sequenceProvider =
                new ReferenceSequenceProvider(FileUtilities.GetReadStream(_compressedReferencePath));

            sequenceProvider.LoadChromosome(new Chromosome("chrM", "MT", 24));
            var mitoMapSvReaders = new List <MitoMapSvReader>();

            foreach (var mitoMapFileName in mitoMapSvFileNames)
            {
                mitoMapSvReaders.Add(new MitoMapSvReader(new FileInfo(mitoMapFileName), sequenceProvider));
            }

            var mergedMitoMapItems = MitoMapSvReader.MergeAndSort(mitoMapSvReaders);

            using (var writer = new IntervalTsvWriter(_outputDirectory, version,
                                                      GenomeAssembly.rCRS.ToString(), SaTsvCommon.MitoMapSchemaVersion, InterimSaCommon.MitoMapTag,
                                                      ReportFor.StructuralVariants))
                CreateSvTsv(mergedMitoMapItems, writer);
            var timeSpan = Benchmark.ToHumanReadable(benchMark.GetElapsedTime());

            TsvWriterUtilities.WriteCompleteInfo(InterimSaCommon.MitoMapTag, version.Version, timeSpan);
        }
예제 #3
0
        private void CreateMitoMapVarTsv(IReadOnlyList <string> mitoMapFileNames)
        {
            if (mitoMapFileNames.Count == 0 || mitoMapFileNames.Any(string.IsNullOrEmpty))
            {
                return;
            }
            var benchMark        = new Benchmark();
            var rootDirectory    = new FileInfo(mitoMapFileNames[0]).Directory;
            var version          = DataSourceVersionReader.GetSourceVersion(Path.Combine(rootDirectory.ToString(), "mitoMapVar"));
            var sequenceProvider =
                new ReferenceSequenceProvider(FileUtilities.GetReadStream(_compressedReferencePath));

            sequenceProvider.LoadChromosome(new Chromosome("chrM", "MT", 24));
            var mitoMapVarReaders = new List <MitoMapVariantReader>();

            foreach (var mitoMapFileName in mitoMapFileNames)
            {
                mitoMapVarReaders.Add(new MitoMapVariantReader(new FileInfo(mitoMapFileName), sequenceProvider));
            }
            var          mergedMitoMapVarItems = MitoMapVariantReader.MergeAndSort(mitoMapVarReaders);
            const string outputFilePrefix      = InterimSaCommon.MitoMapTag;

            using (var writer = new MitoMapVarTsvWriter(version, _outputDirectory, outputFilePrefix, sequenceProvider))
                TsvWriterUtilities.WriteSortedItems(mergedMitoMapVarItems, writer);
            var timeSpan = Benchmark.ToHumanReadable(benchMark.GetElapsedTime());

            TsvWriterUtilities.WriteCompleteInfo(InterimSaCommon.MitoMapTag, version.Version, timeSpan);
        }
예제 #4
0
        private static ExitCodes ProgramExecution()
        {
            var rootDirectory = new FileInfo(MitoMapFileNames[0]).Directory;

            if (rootDirectory == null)
            {
                return(ExitCodes.PathNotFound);
            }
            var version          = DataSourceVersionReader.GetSourceVersion(Path.Combine(rootDirectory.ToString(), "mitoMapVar"));
            var sequenceProvider = new ReferenceSequenceProvider(FileUtilities.GetReadStream(_compressedReference));
            var chrom            = sequenceProvider.RefNameToChromosome["chrM"];

            sequenceProvider.LoadChromosome(chrom);
            MitoMapInputDb mitoMapInputDb        = MitoMapDatabaseUtilities.Create(_mitoMapDatabase);
            var            mitoMapVarReaders     = MitoMapFileNames.Select(mitoMapFileName => new MitoMapVariantReader(new FileInfo(mitoMapFileName), mitoMapInputDb, sequenceProvider)).ToList();
            var            mergedMitoMapVarItems = MitoMapVariantReader.GetMergeAndSortedItems(mitoMapVarReaders);

            string outFileName = $"{version.Name}_{version.Version}";

            using (var nsaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.SaFileSuffix)))
                using (var indexStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.SaFileSuffix + SaCommon.IndexSufix)))
                    using (var nsaWriter = new NsaWriter(nsaStream, indexStream, version, sequenceProvider, SaCommon.MitoMapTag, false, true, SaCommon.SchemaVersion, false))
                    {
                        nsaWriter.Write(mergedMitoMapVarItems);
                    }

            return(ExitCodes.Success);
        }