通过相应的Ensembl Gene ID批量检索EMBL-Bank ID

时间:2013-06-17 12:23:26

标签: python-2.7 biopython

我从Gene Expression Atlas获得了大约5000个基因的列表作为搜索结果。从结果页面我可以将所有结果下载到一个文件中。该文件包含每个基因的基因标识符(Ensembl Gene ID)。所以现在我想为每个Ensembl基因ID提供相应的EMBL-Bank ID,以便我可以从Dbfetch批量下载它们的核苷酸序列。 谁知道我们怎么能实现这一目标? 我们可以使用biopython实现这一目标吗?

1 个答案:

答案 0 :(得分:0)

您可以下载的文件采用自定义制表符分隔格式(Biopython的解析器无法处理)。

相反,您可以使用csv模块来提取您想要的内容:

import csv


with open("listd1.tab") as tab_file:
    data_lines = (line for line in csv_file if not line.startswith("#"))
    csv_data = csv.reader(data_lines, delimiter="\t")
    header = csv_data.next()  # ['Gene name', 'Gene identifier', ...]
    gene_id_index = header.find("Gene identifier")

    for line in csv_data:
        gene_id = line[gene_id_index]  # Do whatever you'd like with this