From 444ea845a89462716e16420f7807cf0a7b420c4d Mon Sep 17 00:00:00 2001 From: proost Date: Tue, 25 Jul 2017 10:47:06 +0200 Subject: [PATCH] fixed qc for hisat2 --- pipeline/check/quality.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/pipeline/check/quality.py b/pipeline/check/quality.py index 0b8c6c6..1097238 100644 --- a/pipeline/check/quality.py +++ b/pipeline/check/quality.py @@ -41,26 +41,19 @@ def check_hisat2(filename, cutoff=0, log=None): :param log: filehandle to write log to, set to None for no log :return: True if the sample passed, false otherwise """ - re_mapped = re.compile('(.*)% overall alignment rate') + re_mapped = re.compile('\t(.*)% overall alignment rate') with open(filename, 'r') as f: lines = '\t'.join(f.readlines()) - for l in lines: - l = l.strip() - print(l) - if "overall alignment" in l: - hits = re_mapped.search(l) - print(hits) - if hits: - value = float(hits.group(1)) - print(value) - if value >= cutoff: - return True - else: - if log is not None: - print('WARNING:', filename, 'didn\'t pass alignment check!', value, 'reads mapped. Cutoff,', - cutoff, file=log) - + hits = re_mapped.search(lines) + if hits: + value = float(hits.group(1)) + if value >= cutoff: + return True + else: + if log is not None: + print('WARNING:', filename, 'didn\'t pass alignment check!', value, 'reads mapped. Cutoff,', + cutoff, file=log) return False