Skip to content

Commit

Permalink
#279 avoid placing NAN in json if no concordant mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Patro committed Aug 25, 2018
1 parent a02c0e3 commit ef41a8c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions include/ReadExperiment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,16 @@ class ReadExperiment {
}
}
numAgree = numFmt1 + numFmt2;
double ratio = static_cast<double>(numFmt1) / (numFmt1 + numFmt2);
double ratio = numAgree > 0 ? (static_cast<double>(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 "
Expand All @@ -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 {
Expand Down

0 comments on commit ef41a8c

Please sign in to comment.