Log a warning if a large number of cadences are masked out by quality_bitmask
@@ -85,8 +85,17 @@ class QualityFlags(object):
"".format(bitmask, valid_options))
# The bitmask is applied using the bitwise AND operator
quality_mask = (quality_array & bitmask) == 0
- log.info("{} cadences will be ignored (bitmask={})"
- "".format((~quality_mask).sum(), bitmask))
+ # Log the quality masking as info or warning
+ n_cadences = len(quality_array)
+ n_cadences_masked = (~quality_mask).sum()
+ percent_masked = 100. * n_cadences_masked / n_cadences
+ logmsg = "{:.0f}% ({}/{}) of the cadences will be ignored due to the " \
+ "quality mask (quality_bitmask={})." \
+ "".format(percent_masked, n_cadences_masked, n_cadences, bitmask)
+ if percent_masked > 20:
+ log.warning("Warning: " + logmsg)
+ else:
+ log.info(logmsg)
return quality_mask
