【问题标题】:Printing translation table from Genbank with BioPython使用 BioPython 从 Genbank 打印翻译表
【发布时间】:2014-11-15 02:27:42
【问题描述】:

我有一个问题,我需要从 Genbank 文件中打印翻译表。我的程序如下所示:

from Bio import SeqIO
record = SeqIO.read("mycoplasma.gb","genbank")
print record.id
print record.description
print "Number of features:", len(record.features)
ct=0
for f in record.features:
    if f.type=="tRNA":
        ct+=1
print "There are ", ct, "tRNa features"

ct2 = 0
for f in record.features:
    if f.type == "gene":
        ct2+=1
print "Therea are", ct2, "gene features"

ct3 = 0
for f in record.features:
    if f.type == "CDS":
        ct3+=1
print "There are", ct3, "CDS features"

print "The following is feature 4:"
print record.features[4]
print "The following information is about feature 21:"
print "It is a", record.features[21].type, "feature"
print "Its location is", record.features[21].location
for feature in record.features[21]:
    print feature.qualifiers["transl_table"]

我只需要最后一部分从文件中打印翻译表。

【问题讨论】:

  • 您能否更明确地说明您需要帮助的问题是什么?

标签: python biopython


【解决方案1】:

这很容易。您首先导入 CodonTables:

from Bio.Data import CodonTable

然后您可以在 Genbank 文件中获取带有编号的 CodonTables:

for feature in record.features:
    t_t = feature.qualifiers.get("transl_table")
        if t_t:
            print CodonTable.unambiguous_dna_by_id[int(t_t[0])]

注意你需要一个整数来使用unambiguous_dna_by_id[],而t_t很可能是一个字符串列表,比如['4']

【讨论】:

    猜你喜欢
    • 2016-12-01
    • 2016-03-05
    • 2014-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-24
    • 2016-03-24
    相关资源
    最近更新 更多