这就是我想做的。 我有一个基因名列表,例如:[ITGB1,RELA,NFKBIA]
在查找entrez的biopython帮助和API教程时,我想到了这个:
x = ['ITGB1', 'RELA', 'NFKBIA']
for item in x:
handle = Entrez.efetch(db="nucleotide", id=item ,rettype="gb")
record = handle.read()
out_handle = open('genes/'+item+'.xml', 'w') #to create a file with gene name
out_handle.write(record)
out_handle.close
但这一直在出错。我发现如果id是一个数字id(尽管您必须将其转换为字符串才能使用,'186972394'所以:
^{pr2}$这给了我我想要的信息,包括序列。在
现在我们来回答这个问题: 我怎样才能搜索基因名(因为我没有id号)或者很容易地将我的基因名转换成id来获得我拥有的基因列表的序列。在
谢谢你
首先是基因名,例如:ATK1
现在我们有一个搜索字符串来搜索id
^{pr2}$如果没有找到id,则返回id作为一个列表。现在假设它返回列表中的1项。在
这将为您提供一个fasta字符串,您可以将其保存到文件中
看看本教程的第8.3节,似乎有一个函数可以让您搜索术语并获得相应的id(我对这个库一无所知,对生物学更不了解,因此这可能完全错误:))。在
据我所知,
^{pr2}$id
指的是esearch
函数(在响应的IdList
属性中)返回的实际ID号。但是,如果使用term
关键字,则可以运行搜索并获取匹配项的ID。完全未测试,但假设搜索支持布尔运算符(看起来AND
有效),您可以尝试使用如下查询:要生成要插入的术语,可以执行以下操作:
然后,
record["IdList"]
可以转换为逗号分隔的字符串,并通过如下方法传递给原始查询中的id
参数:相关问题 更多 >
编程相关推荐