From ef41a8cef9cc77c1c58c2832797e6e8240ba925e Mon Sep 17 00:00:00 2001 From: Rob Patro Date: Sat, 25 Aug 2018 16:05:02 -0400 Subject: [PATCH] #279 avoid placing NAN in json if no concordant mappings --- include/ReadExperiment.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/ReadExperiment.hpp b/include/ReadExperiment.hpp index b08d98c23..ed309fd72 100644 --- a/include/ReadExperiment.hpp +++ b/include/ReadExperiment.hpp @@ -475,9 +475,16 @@ class ReadExperiment { } } numAgree = numFmt1 + numFmt2; - double ratio = static_cast(numFmt1) / (numFmt1 + numFmt2); + double ratio = numAgree > 0 ? (static_cast(numFmt1) / (numFmt1 + numFmt2)) : 0.0; - if (std::abs(ratio - 0.5) > 0.01) { + if (numAgree == 0) { + errstr << "NOTE: Read Lib [" << rl.readFilesAsString() << "] :\n"; + errstr << "\nFound no concordant and consistent mappings. " + "If this is a paired-end library, are you sure the reads are properly paired? " + "check the file: " << opath.string() << " for details\n"; + log->warn(errstr.str()); + errstr.clear(); + } else if (std::abs(ratio - 0.5) > 0.01) { errstr << "NOTE: Read Lib [" << rl.readFilesAsString() << "] :\n"; errstr << "\nDetected a *potential* strand bias > 1\% in an " "unstranded protocol " @@ -498,7 +505,7 @@ class ReadExperiment { oa(cereal::make_nvp("num_assigned_fragments", numAssignedFragments_.load())); - oa(cereal::make_nvp("num_frags_with_consistent_mappings", numAgree)); + oa(cereal::make_nvp("num_frags_with_concordant_consistent_mappings", numAgree)); oa(cereal::make_nvp("num_frags_with_inconsistent_or_orphan_mappings", numDisagree)); oa(cereal::make_nvp("strand_mapping_bias", ratio)); } else {