我找到了解析 fasta frmated 文件的代码。我需要计算每个序列中有多少个A、T、G等,例如:
>gi|7290019|gb|AAF45486.1| (AE003417) EG:BACR37P7.1 gene product [Drosophila melanogaster]
MRMRGRRLLPIIL
在这个序列中:
M - 2
R - 4
G - 1
L - 3
I - 2
P - 1
代码非常简单:
def FASTA(filename):
try:
f = file(filename)
except IOError:
print "The file, %s, does not exist" % filename
return
order = []
sequences = {}
for line in f:
if line.startswith('>'):
name = line[1:].rstrip('\n')
name = name.replace('_', ' ')
order.append(name)
sequences[name] = ''
else:
sequences[name] += line.rstrip('\n').rstrip('*')
print "%d sequences found" % len(order)
return order, sequences
x, y = FASTA("drosoph_b.fasta")
但是我怎样才能计算那些氨基酸呢?我不想使用 BioPython,我想知道如何使用,例如count
...