From 7018cf424ad6cdea7b9d98c2b8dee5bc89296e75 Mon Sep 17 00:00:00 2001 From: Bruce Edelman Date: Wed, 15 Nov 2023 20:56:04 +0000 Subject: [PATCH] fix flake8 errors for undefined variables (it cant tell about going through loops or cases that end up defining variables before being called --- diploshic/fvTools.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/diploshic/fvTools.py b/diploshic/fvTools.py index a2faa6f..63f184c 100644 --- a/diploshic/fvTools.py +++ b/diploshic/fvTools.py @@ -252,6 +252,7 @@ def readFa(faFileName, upper=False): fopen = open with fopen(faFileName, "rt") as faFile: reading = False + currChr = None for line in faFile: if line.startswith(">"): if reading: @@ -493,6 +494,10 @@ def readMaskDataForTraining( readingMasks = False isAccessible, isAccessibleArm = [], [] genoMaskInfo = [] + currChr = None + genos = None + positions = None + positions2SnpIndices = None with fopen(maskFileName, "rt") as maskFile: for line in maskFile: if line.startswith(">"): @@ -916,7 +921,7 @@ def calcAndAppendStatValDiplo( - statVals["pi"][instanceIndex][subWinIndex] ) elif statName == "HapCount": - statVals[statName][instanceIndex].append(len(hapsInSubWin.distinct())) + statVals[statName][instanceIndex].append(len(genosInSubWin.distinct())) elif statName == "nDiplos": diplotypeCounts = dps.getHaplotypeFreqSpec(genosNAlt) nDiplos = diplotypeCounts[genosNAlt.shape[1]] @@ -1021,7 +1026,7 @@ def calcAndAppendStatValForScanDiplo( ) elif statName == "HapCount": # AK: undefined variables - statVals[statName].append(len(hapsInSubWin.distinct())) + statVals[statName].append(len(genosInSubWin.distinct())) elif statName == "nDiplos": diplotypeCounts = dps.getHaplotypeFreqSpec(genosNAlt) nDiplos = diplotypeCounts[genosNAlt.shape[1]]