public void CreateIndex() { var searchTag = $"\"{SectionToIndex}\":["; const string headerTag = "{\"header\":"; var index = new JasixIndex(); string line; //skipping lines before the sectionToIndex arrives while ((line = _reader.ReadLine()) != null) { if (line.StartsWith(headerTag)) { index.HeaderLine = ExtractHeader(line); } if (line.EndsWith(searchTag)) { break; } } // we need the location before accessing the line var fileLoc = _reader.Position; string previousChr = ""; int previousPos = 0; while ((line = _reader.ReadLine()) != null) { if (line.StartsWith("]")) { break; } line = line.TrimEnd(','); var chrPos = GetChromPosition(line); CheckFileSorted(chrPos.chr, chrPos.position, previousChr, previousPos); index.Add(chrPos.chr, chrPos.position, chrPos.end, fileLoc); fileLoc = _reader.Position; previousChr = chrPos.chr; previousPos = chrPos.position; } index.Write(_writeStream); Console.WriteLine(); var peakMemoryUsageBytes = MemoryUtilities.GetPeakMemoryUsage(); var wallTimeSpan = _benchmark.GetElapsedTime(); Console.WriteLine(); if (peakMemoryUsageBytes > 0) { Console.WriteLine("Peak memory usage: {0}", MemoryUtilities.ToHumanReadable(peakMemoryUsageBytes)); } Console.WriteLine("Time: {0}", Benchmark.ToHumanReadable(wallTimeSpan)); }
public void CreateIndex() { var index = new JasixIndex(); IndexHeader(index); string lastLine = IndexPositions(index); IndexGenes(lastLine, index); index.Write(_writeStream); Console.WriteLine(); long peakMemoryUsageBytes = MemoryUtilities.GetPeakMemoryUsage(); var wallTimeSpan = _benchmark.GetElapsedTime(); Console.WriteLine(); if (peakMemoryUsageBytes > 0) { Console.WriteLine("Peak memory usage: {0}", MemoryUtilities.ToHumanReadable(peakMemoryUsageBytes)); } Console.WriteLine("Time: {0}", Benchmark.ToHumanReadable(wallTimeSpan)); }
/// <summary> /// executes the command-line workflow /// </summary> public void Execute(string[] args) { var bench = new Benchmark(); try { List <string> unsupportedOps = null; if (args == null || args.Length == 0) { SetExitCode(ExitCodes.MissingCommandLineOption); _showHelpMenu = true; } else { try { unsupportedOps = _commandLineOps.Parse(args); if (unsupportedOps.Count > 0) { SetExitCode(ExitCodes.UnknownCommandLineOption); _showHelpMenu = true; } } catch (OptionException oe) { _errorBuilder.AppendFormat("{0}ERROR: {1}\n", _errorSpacer, oe.Message); SetExitCode(ExitCodes.UnknownCommandLineOption); _showHelpMenu = true; } } if (_showVersion) { Console.WriteLine("{0} {1}", _versionProvider.GetProgramVersion(), _versionProvider.GetDataVersion()); SetExitCode(ExitCodes.Success); } else { if (!Console.IsOutputRedirected) { CommandLineUtilities.DisplayBanner(_programAuthors); } if (_showHelpMenu) { Help.Show(_commandLineOps, _commandLineExample, _programDescription); CommandLineUtilities.ShowUnsupportedOptions(unsupportedOps); Console.WriteLine(); Console.WriteLine(_versionProvider.GetDataVersion()); Console.WriteLine(); // print the errors if any were found if (FoundParsingErrors()) { return; } } else { ValidateCommandLine(); // print the errors if any were found if (FoundParsingErrors()) { return; } ProgramExecution(); } } } catch (Exception e) { ExitCode = ExitCodeUtilities.ShowException(e); } _peakMemoryUsageBytes = MemoryUtilities.GetPeakMemoryUsage(); _wallTimeSpan = bench.GetElapsedTime(); if (!_showVersion && !_showHelpMenu && !Console.IsOutputRedirected) { Console.WriteLine(); if (_peakMemoryUsageBytes > 0) { Console.WriteLine("Peak memory usage: {0}", MemoryUtilities.ToHumanReadable(_peakMemoryUsageBytes)); } Console.WriteLine("Time: {0}", Benchmark.ToHumanReadable(_wallTimeSpan)); } }