From c4091f5f1dffec4d2678b918f09c4d2261edf55c Mon Sep 17 00:00:00 2001 From: Christian Heckendorf Date: Mon, 21 Mar 2022 14:37:26 -0400 Subject: [PATCH] set NA values to nan --- src/CalculateCoElutionScores.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/CalculateCoElutionScores.py b/src/CalculateCoElutionScores.py index e9af9f7..538a84a 100644 --- a/src/CalculateCoElutionScores.py +++ b/src/CalculateCoElutionScores.py @@ -91,6 +91,12 @@ def getScore(inputQ, outputList): inputQ.task_done() +def toFloat(x): + try: + f=float(x) + return f + except ValueError: + return np.nan @@ -131,7 +137,7 @@ def loadElutionData(self, elutionProfileF, frac_count = 2, max_count_cutoff=1): line = line.rstrip() line = line.split("\t") protID = line[0] - counts = map(float, line[1:]) + counts = map(toFloat, line[1:]) counts_array = np.array(counts) counts_array[np.isnan(counts_array)] = 0.0 if len(list(set(np.where(np.array(counts_array) > 0.0)[0]))) >= frac_count and max(counts_array) >= max_count_cutoff: