Hi;
I have a file that looks like this:
>title 1
AAATTTGGGCCCATA...
TTAACAAGTTAAAT…
>title 2
AAATTTAAACCCGGGG…
ATATATATA…
…
I wrote the following to count the As, Cs, Gs anTs for each title I wrote the
following
import sys
file = open('file.fna')
data=file.readlines()
for line in data:
line = line.rstrip()
if line.startswith('>') :
print line
if not line.startswith('>') :
seq = line.rstrip()
counters={}
for char in seq:
counters[char] = counters.get(char,0) + 1
Ks = counters.keys()
Ks.sort()
for k in Ks:
print sum(counters.itervalues())
I want to get the following out put:
>title
234
>title 1
3453
….
but what i get
>title 1
60
60
60
60
…
it seems it do counting for each line and print it out.
Can you help me please
Thanks
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor