From 269aaa551a63386dddcbc946b2f94a54ea3aec7c Mon Sep 17 00:00:00 2001 From: Gert Hulselmans Date: Thu, 28 May 2020 11:07:52 +0200 Subject: [PATCH 1/2] Fix reading datasets from base_list if defined without '/' in the names. Fix reading datasets from base_list if defined without '/' in the names by using os.path.basename instead of trying to get the basename ourself in a hacky way. Fixes the following error when filenames listed in datalist don't contain slashes: File "./NGSCheckMate/ncm.py", line 254, in createDataSetFromList file = link[link.rindex("/")+1:] ValueError: substring not found --- ncm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ncm.py b/ncm.py index 0bff27c..dba4cc3 100644 --- a/ncm.py +++ b/ncm.py @@ -251,7 +251,7 @@ def createDataSetFromList(base_list, bedFile): link = line.strip() f = open(link, "r") dbsnpf= open(bedFile,"r") - file = link[link.rindex("/")+1:] + file = os.path.basename(link) depth = dict() depth[file] = 0 real_count[file] = 0 From d1f5c809f61ac1439d7ae539a510da18fef5052e Mon Sep 17 00:00:00 2001 From: Gert Hulselmans Date: Thu, 28 May 2020 11:14:33 +0200 Subject: [PATCH 2/2] Allow Pearson correlation to be zero. Allow Pearson correlation to be zero. Fixes the following error: File "./NGSCheckMate/ncm.py", line 59, in pearson_def return diffprod / math.sqrt(xdiff2 * ydiff2) ZeroDivisionError: float division by zero --- ncm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ncm.py b/ncm.py index dba4cc3..56c4d03 100644 --- a/ncm.py +++ b/ncm.py @@ -56,7 +56,9 @@ def pearson_def(x, y): xdiff2 += xdiff * xdiff ydiff2 += ydiff * ydiff - return diffprod / math.sqrt(xdiff2 * ydiff2) + sqrt_xdiff2_ydiff2 = math.sqrt(xdiff2 * ydiff2) + + return diffprod / sqrt_xdiff2_ydiff2 if sqrt_xdiff2_ydiff2 != 0.0 else 0.0 # createDataSet # base_dir : directory of files, bedFile: name of the bedFile