擅长:python、mysql、java
<p>感谢您的帮助;交换循环的洞察力是非常宝贵的。
改进的、更有效的脚本如下所示:(注意:我现在没有了人类基因列表(如上所述),而是有了人类基因的DictOfHumanGenes,其中每个键都是人类基因,值是(1)NumberOfTrials,(2)UnderexpressedSuccess和(3)OverexpressedSuccess的列表;这也加快了代码的其他部分):</p>
<pre><code>for each_file in glob.glob("*.HumanHomologs"):
open_each_file = open(each_file).readlines()[1:]
for line in open_each_file:
line = line.strip().split()
if line[0] in DictOfHumanGenes:
DictOfHumanGenes[line[0]][0] +=1 #This is the Number of trials
if line[-1] != "NA":
if float(line[-1]) < float(0.05):
if float(line[-2]) < float(0):
DictOfHumanGenes[line[0]][1] +=1 #This is the UnexpressedSuccess
elif float(line[-2]) > float(0):
DictOfHumanGenes[line[0]][2] +=1 #This is the OverexpressedSuccess
</code></pre>
<p>我现在正在研究pandas,看看如何整合它,如果我能让pandas的代码更高效,我会把答案贴在这里。你知道吗</p>