【问题标题】:Show only dna alignment score in biopython在 biopython 中仅显示 dna 对齐分数
【发布时间】:2019-03-24 17:38:04
【问题描述】:

我有 DNA 序列数据。 例如,

X="ACGGGT"
Y="ACGGT"

我想知道对齐分数,因此我使用了 biopython pairwise2 函数。 例如,

from Bio import pairwise2
from Bio.pairwise2 import format_alignment

alignments = pairwise2.align.globalxx(X, Y)
for a in alignments:
    print(format_alignment(*a))

这成功显示了 DNA 比对,但我只需要如下分数。 有没有办法只显示分数?

我使用了 biopython,但如果有更好的方法,将不胜感激。

【问题讨论】:

    标签: python bioinformatics biopython dna-sequence pairwise


    【解决方案1】:

    获取每个对齐元组的第 3 项(或为获得最佳分数,仅解析 score_only 参数):

    >>> from Bio import pairwise2
    >>> X="ACGGGT"
    >>> Y="ACGGT"
    >>> alignments = pairwise2.align.globalxx(X, Y)
    >>> [a[2] for a in alignments]
    [5.0, 5.0, 5.0]
    >>> pairwise2.align.globalxx(X, Y, score_only=True)
    5.0
    

    另请参阅较新的 Bio.Align 模块,该模块对于许多用例可能具有更高的性能。如果你只想要最好的分数,你可以使用aligner.score()作为Markus cmets:

    >>> from Bio import Align
    >>> aligner = Align.PairwiseAligner()
    >>> alignments = aligner.align(X,Y)
    >>> [a.score for a in alignments]
    [5.0, 5.0, 5.0]
    >>> aligner.score(X, Y)
    5.0
    

    如果您想要分数,那么避免生成完整对齐是两个模块最快且最节省内存的方法。

    【讨论】:

    • 对于PairwiseAligner 而不是aligner.align(X, Y) 你可以只做aligner.score(X, Y)。请注意,仅计算分数(在pairwise2score_only=True 中,在PairwiseAlignerscore 中)更快并且节省内存。因此,当您对对齐本身不感兴趣时​​,您应该始终这样做。
    • 首先非常感谢。我在第一个 = 20803 和第二个 = 30386 的 2 个基因上测试了这两种方法。 pairwise2score_only=True 大约需要 11 秒,但 aligner.score 大约需要 3 秒,这几乎快 4 倍。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多