Objective: Write a program that counts the number of A's in a DNA sequence. The input is one sequence in FASTA format in a file called 'dna.txt'.
My input file:
>Human
AGCATGCATCGATCGATCGACTAGCTAGCG
>Chimp
GATATGTCGAGATCGTCAGCTCGATCAGCT
>Gorilla
TGTGTCGATCTCGAGCTGAGTCGTCTATCA
Output: I don't need to create only print output info
My code so far:
DNA_list = []
with open('dna.fasta.py') as f_in:
lines = f_in.read()
if lines[0] == 'A' or 'C' or 'G' or 'T':
DNA_list = DNA_list.append(lines)
else:
pass
What I would like to do and Issue:
After creating the list of DNA sequences/strings , for each sequence, I would like would like to count the 'A's using the count method and then I would just print to IDLE. The problem is that IDLE is saying that there is 'None' in the DNA_list. I don't know why the sequences were not appended to my list.
I have no idea what I'm doing wrong and would like to know if I'm heading in the right direction and how to fix my program.
Thanks.
You're not iterating over the file. Add
and retry.