【问题标题】:From TextIOWrapper to parse in Biopython从 TextIOWrapper 到 Biopython 解析
【发布时间】:2018-01-29 11:42:07
【问题描述】:

我编写了一个脚本并使用循环创建了一个多对齐 fasta 并将其存储在一个文件中。

concatenation = open ('example.fasta', 'w')
for key, value in concat.items():
    output = '>' + key + '\n' + value + '\n'
    concatenation.write(output)

我想使用 AlignIO 的功能将我的 fasta 转换为 phylip(并打开一个新文件),但我无法找到解析我的“example.fasta”的方法。

最好的方法是什么?

【问题讨论】:

    标签: python dictionary biopython


    【解决方案1】:

    如果你只是想将一个 biopython fasta 对齐转换为 phylip,你可以简单地使用convert 方法。

    from Bio import AlignIO
    
    AlignIO.convert("myFastaInputFile","fasta","myPhylipOutFile","phylip")
    

    如果需要先从文件中读取对齐方式,可以使用parse再转换:

    myAlignment = AlignIO.parse("myFastaAlignment","fasta")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-22
      • 1970-01-01
      相关资源
      最近更新 更多