From e5a69ed19772c8cd1208c1ded16872947d6e34a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dernat=20R=C3=A9my?= <remy.dernat@umontpellier.fr> Date: Fri, 22 Nov 2019 11:22:41 +0100 Subject: [PATCH] adding comments --- orthofinder/orthofinder.py | 8 ++++++-- orthofinder/scripts/blast_file_processor.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/orthofinder/orthofinder.py b/orthofinder/orthofinder.py index 2fd34fe..a05a013 100755 --- a/orthofinder/orthofinder.py +++ b/orthofinder/orthofinder.py @@ -298,10 +298,12 @@ scnorm class scnorm: @staticmethod def loglinear(x, a, b): - return a*np.log10(x)+b + # return the loglinear function + return a*np.log10(x)+b @staticmethod def GetLengthArraysForMatrix(m, len_i, len_j): + # return (I,j) positions non zeros values for the m matrix I, J = m.nonzero() scores = [v for row in m.data for v in row] # use fact that it's lil Li = np.array(len_i[I]) @@ -336,15 +338,17 @@ class scnorm: @staticmethod def CalculateFittingParameters(Lf, S): + # curve_fit doc.: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html pars,covar = curve_fit(scnorm.loglinear, Lf, np.log10(S)) return pars - @staticmethod + @staticmethod def NormaliseScoresByLogLengthProduct(b, Lq, Lh, params): rangeq = list(range(len(Lq))) rangeh = list(range(len(Lh))) li_vals = Lq**(-params[0]) lj_vals = Lh**(-params[0]) + # l{i,j}_matrix are built using l{i,j}_vals data using (range{q,h},range{q,h}) positions li_matrix = sparse.csr_matrix((li_vals, (rangeq, rangeq))) lj_matrix = sparse.csr_matrix((lj_vals, (rangeh, rangeh))) return sparse.lil_matrix(10**(-params[1]) * li_matrix * b * lj_matrix) diff --git a/orthofinder/scripts/blast_file_processor.py b/orthofinder/scripts/blast_file_processor.py index f882c1a..232b2f7 100644 --- a/orthofinder/scripts/blast_file_processor.py +++ b/orthofinder/scripts/blast_file_processor.py @@ -104,7 +104,7 @@ def GetBLAST6Scores(seqsInfo, blastDir_list, iSpecies, jSpecies, qExcludeSelfHit return B def WriteNormalizedBlastFile(blastDir_list, B, iSpecies, jSpecies, sep = "_", qDoubleBlast=True): - qSameSpecies = iSpecies==jSpecies + # checking species order to get the right filenames if not qDoubleBlast: qRev = (iSpecies > jSpecies) else: -- GitLab