所以我试着写一个程序,根据它的位置,给我一个启动子中特定碱基的频率。例如: ACTGCTGATCGTAGC,在seq,A=1中,因为在第一列中,A只出现过一次。这里是“草图”,或未完成的计划,如果你愿意。
import numpy as np
def pfm(x, sequence):
a=0
t=0
c=0
g=0
y=np.array([[]])
for bases in sequence[z]:
if sequence[z]==a:
a+=1
elif sequence[z]==t:
t+=1
elif sequence[z]==c:
c+=1
elif sequence[z]==g:
g+=1
return np.append(y,
a=0
t=0
c=0
g=0
z+=1
x=input("Please enter the number of sequences you wish to analyze: ")
etc...正如你所看到的,我显然没有完成它,因为一个特定的问题。我想将其附加到空集中,但当我将其部分放到shell中时,我仍然会得到错误"ValueError:除了连接轴之外的所有输入数组尺寸必须完全匹配“。所以我想知道我怎么才能把4*1矩阵附加到空集合中。我的想法是,每次这样做时,我都会将基计数设置为0,并继续追加它们的相应列。谢谢。
发布于 2017-05-31 18:48:46
如果序列大小相同,例如:
['atatatg',
'atgcatg',
'acggtaa',
'tagcgta']你可以这样做:
LoS=['atatatg', 'atgcatg','acggtaa', 'tagcgta']
a=[]
t=[]
g=[]
c=[]
for j in range(len(LoS[0])):
a.append([i[j] for i in LoS].count('a'))
t.append([i[j] for i in LoS].count('t'))
g.append([i[j] for i in LoS].count('g'))
c.append([i[j] for i in LoS].count('c'))
print "a", a
print "t", t
print "g", g
print "c", c会给你:
a [3, 1, 1, 0, 2, 1, 2]
t [1, 2, 0, 1, 1, 3, 0]
g [0, 0, 3, 1, 1, 0, 2]
c [0, 1, 0, 2, 0, 0, 0]你有3次a在你所有的顺序中处于第一位,等等.
https://stackoverflow.com/questions/44292132
复制相似问题