Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python计算字典中的基因突变_Python_List_Dictionary_Bioinformatics - Fatal编程技术网

使用python计算字典中的基因突变

使用python计算字典中的基因突变,python,list,dictionary,bioinformatics,Python,List,Dictionary,Bioinformatics,我有以下格式的数据: >abc12 ATCGACAG >def34 ACCGACG 等等 我已将每个基因存储到一个字典中,以>开头的行作为值。所以字典就像{'abc12':'atcgacg',等等。} 现在我想能够比较每个基因,这样它就能计算出每个位点的A,T,C或G的数量 我唯一能想到的就是将字典分成每个核苷酸位点的列表,并使用带计数器的zip()。这是最好的方法吗?如果是,我如何将字典分解为每个站点的列表?使用: 使用: 有没有理由不使用Biopython from Bio import A

我有以下格式的数据:

>abc12
ATCGACAG

>def34
ACCGACG

等等

我已将每个基因存储到一个字典中,以>开头的行作为值。所以字典就像{'abc12':'atcgacg',等等。}

现在我想能够比较每个基因,这样它就能计算出每个位点的A,T,C或G的数量

我唯一能想到的就是将字典分成每个核苷酸位点的列表,并使用带计数器的zip()。这是最好的方法吗?如果是,我如何将字典分解为每个站点的列表?

使用:

使用:


有没有理由不使用Biopython

from Bio import AlignIO
alignment =AlignIO.read("alignment.fas", "fasta")
n=0
while n<len(alignment[0]):
    A=alignment[:,n].count('A')
    C=alignment[:,n].count('C')
    G=alignment[:,n].count('G')
    T=alignment[:,n].count('T')
    gap=alignment[:,n].count('-')

    print "at position %s there are %s A's, %s C's, %s G's, %s T's and %s gaps" % (n, A, C, G, T, gap)
    n=n+1

有没有理由不使用Biopython

from Bio import AlignIO
alignment =AlignIO.read("alignment.fas", "fasta")
n=0
while n<len(alignment[0]):
    A=alignment[:,n].count('A')
    C=alignment[:,n].count('C')
    G=alignment[:,n].count('G')
    T=alignment[:,n].count('T')
    gap=alignment[:,n].count('-')

    print "at position %s there are %s A's, %s C's, %s G's, %s T's and %s gaps" % (n, A, C, G, T, gap)
    n=n+1

我希望能够像排列一样数数。例如,在位点一,两个基因都有一个A,但在位点二,一个有一个C,一个有一个T。因此,输出值应该是:1:5 A,2 C的2:3 g,4 A。这有意义吗?我想能够像排列一样计数。例如,在位点一,两个基因都有一个A,但在位点二,一个有一个C,一个有一个T。因此,输出会是:1:5A,2c的2:3g,4A,这有意义吗?
from Bio import AlignIO
alignment =AlignIO.read("alignment.fas", "fasta")
n=0
while n<len(alignment[0]):
    A=alignment[:,n].count('A')
    C=alignment[:,n].count('C')
    G=alignment[:,n].count('G')
    T=alignment[:,n].count('T')
    gap=alignment[:,n].count('-')

    print "at position %s there are %s A's, %s C's, %s G's, %s T's and %s gaps" % (n, A, C, G, T, gap)
    n=n+1
at position 0 there are 2 A's, 0 C's, 0 G's, 0 T's and 0 gaps
at position 1 there are 0 A's, 1 C's, 0 G's, 1 T's and 0 gaps
at position 2 there are 0 A's, 2 C's, 0 G's, 0 T's and 0 gaps
at position 3 there are 0 A's, 0 C's, 2 G's, 0 T's and 0 gaps
at position 4 there are 2 A's, 0 C's, 0 G's, 0 T's and 0 gaps
at position 5 there are 0 A's, 2 C's, 0 G's, 0 T's and 0 gaps
at position 6 there are 1 A's, 0 C's, 0 G's, 0 T's and 1 gaps
at position 7 there are 0 A's, 0 C's, 2 G's, 0 T's and 0 gaps