我有一个用peewee构建的查询:
nameGoEvidenceEarlier = Protein.select(Protein.entryname ,Evidence.evidencecode ,Go.go_domain, Go.go_term).join(ProteinGo).join(Evidence).switch(ProteinGo).join(Go).where(Evidence.ondate.year == 2013).order_by(Protein.entryname).naive()
然后我遍历查询结果:
for earlier in nameGoEvidenceEarlier.iterator():
earlierDict[earlier.entryname] = earlierDict.get(earlier.entryname,[]) + [(earlier.go_domain,earlier.evidencecode,earlier.go_term)]
列表包含以下项目:
nonexpEvidenceList = ['IEA','ISS','ISO','ISA','ISM','IGC','IBA','IBD','IKR','IRD','RCA','TAS','NAS','IC','ND']
然后我迭代字典earlyDict并比较以查看元组的第一个值(early.evidencecode)是否在nonexpEvidenceList中:
for entryname,earlier_ontologyCodeTermList in earlierDict.items():
for o,c,t in earlier_ontologyCodeTermList:
if c.encode('ascii') in nonexpEvidenceList:
print c
但是这段代码不会打印任何内容。可以做出的一个明显的结论是,在非xxEvidenceList中不存在c,但事实并非如此 - 当我打印c时,列表中可用的所有代码都存在。 我的猜测是类型转换在某处出错了。
我忽略了什么吗?