From d6a85971cc432c589c740d7566397d4626771fed Mon Sep 17 00:00:00 2001 From: Ryan Lim Date: Wed, 26 Apr 2023 11:42:30 -0700 Subject: [PATCH] handle empty output from fastp --- src/stats.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/stats.cpp b/src/stats.cpp index deca75c..986069b 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -850,7 +850,14 @@ void Stats::reportHtmlContents(ofstream& ofs, string filteringType, string readN } else { count = mBaseContents['G' & 0x07] + mBaseContents['C' & 0x07] ; } - string percentage = to_string((double)count * 100.0 / mBases); + + string percentage; + if (mBases != 0) { + percentage = to_string((double)count * 100.0 / mBases); + } else { + percentage = "-nan"; + } + if(percentage.length()>5) percentage = percentage.substr(0,5); string name = base + "(" + percentage + "%)";