From a5e859c4514ebfb35a57f2b98cb983f04e7e146f Mon Sep 17 00:00:00 2001 From: Sebastian Proost Date: Mon, 29 Aug 2016 09:58:19 +0200 Subject: [PATCH] checks to prevent qc to fail on empty samples --- pipeline/check/quality.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pipeline/check/quality.py b/pipeline/check/quality.py index 31ebf23..64fe6e7 100644 --- a/pipeline/check/quality.py +++ b/pipeline/check/quality.py @@ -53,14 +53,16 @@ def check_htseq(filename, cutoff=0, log=None): else: values[gene] = int(value) - total = sum([mapped_reads, values['__no_feature'], values['__ambiguous']]) + total = sum([mapped_reads, + values['__no_feature'] if '__no_feature' in values.keys() else 0, + values['__ambiguous'] if '__ambiguous' in values.keys() else 0]) - percentage_mapped = (mapped_reads*100)/total + percentage_mapped = ((mapped_reads*100)/total) if total > 0 else 0 if percentage_mapped >= cutoff: return True else: - if log is not None: + if log is not None: print('WARNING:', filename, 'didn\'t pass HTSEQ-Count Quality check!', percentage_mapped , 'reads mapped. Cutoff,', cutoff, file=log)