首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GO术语的生物信息检索及与用户特定术语的比较

GO术语的生物信息检索及与用户特定术语的比较
EN

Stack Overflow用户
提问于 2014-11-13 13:48:20
回答 1查看 232关注 0票数 1

我有以下函数(属于类):

代码语言:javascript
复制
import Bio
from bioservices import KEGGParser, UniProt, QuickGO

def locate_common_GO(self,list_of_genes,GO_term):
    
    #initialize variables and classes
    q = QuickGO()
    a = Retrieve_Data()
    b=[]

    #get the uniprot IDS using hugo2uniprot. hugo2uniprot is a custom method of my Retrieve_Data class (which uses bioservices module) simply for getting a uniprot ID from a gene symbol. 
    for i in range(0,len(list_of_genes)):
        b.append(a.hugo2uniprot(list_of_genes[i],'hsa'))
        print 'Gene: {} \t UniProtID: {}'.format(list_of_genes[i],b[i])


    #search for GO terms and store as dictionary. Keys are the gene name and a list of GO terms are values. 
    GO_dict = {}
    for i in range(0,len(b)):
        q = QuickGO()
        GO_dict[list_of_genes[i]]= q.Annotation(protein=b[i], frmt="tsv", _with=True,tax=9606, source="UniProt", col="goName")
    keys = GO_dict.keys()

    #This bit should search the dictionary values for a term supplied by the user (stored in the variable 'GO_Term'). 
    #If the user supplied term is present in the retrieved list of GO terms I want it to add the dictionary key (i.e. the gene name) to a list named 'matches'. 
    matches = []
    for gene in range(0,len(keys)):
        if GO_term in GO_dict[keys[gene]].splitlines():
            matches.append(keys[i])
    return matches 

问题是,尽管提供了一个已知通用基因术语的基因列表,但该功能的输出始终是相同的基因名称。例如,'TGFB1''COL9A2'都有一个GO术语'proteinaceous extracellular matrix',但是输出是list,['COL9A2','COL9A2']应该是['COL9A2','TGFB1']。有谁对如何修改这个程序有任何建议吗?我想我已经接近了,但我找不到解决办法。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-13 14:14:06

您总是将keys[i]附加到matches,但是i在该循环中不会更改,所以您总是追加相同的项。您可能需要追加keys[gene]

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26910388

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档