From 29819cb5dc838148b8b316ed1387c032121c5dfb Mon Sep 17 00:00:00 2001 From: Michaeljon Miller Date: Wed, 18 May 2022 12:15:42 -0700 Subject: [PATCH] fixing percent complete on read-limited runs --- .vscode/launch.json | 2 ++ Program.cs | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 5315e07..6aa53df 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,6 +14,8 @@ "args": [ "-v", "-d", + "-l", + "1000000", "-f", "sam", "-i", diff --git a/Program.cs b/Program.cs index 80b5bba..6732278 100644 --- a/Program.cs +++ b/Program.cs @@ -64,7 +64,17 @@ private void Run() { if (sequenceReader.SequencesRead % UpdatePeriod == 0) { - Console.Error.WriteLine($"{sequenceReader.SequencesRead.WithSsiUnits()} sequences completed ({sequenceReader.ApproximateCompletion:0.0}%)"); + var approximateCompletion = sequenceReader.ApproximateCompletion; + + // if we're limiting the number of reads then the reader's + // approximation will be incorrect (it's based on file positions), + // so we'll do the math ourselves + if (Settings.ReadLimit < ulong.MaxValue) + { + approximateCompletion = 100.0 * (double)sequenceReader.SequencesRead / (double)Settings.ReadLimit; + } + + Console.Error.WriteLine($"{sequenceReader.SequencesRead.WithSsiUnits()} sequences completed ({approximateCompletion:0.0}%)"); } }); }