I have a fasta file that does not contain any return characters. The file looks something like this:
>Sequence_ID(Num1)AAAAAAAAAAAAAAAAAAATTTTTTTAAAAA>Seqence_ID(Num2)AAAAAAATTTTTTTAAAATTTAATTTAATTATTAT>Sequence_ID (Num3)AAATTTTATTAGGAGGGA and so on for many lines.
I would have been trying to make a python program that would read this file, and insert a new line character at the end of every sequence ID and sequence itself. I am hoping the output would look like this:
>Sequence_ID(Num1) AAAAAAAAAAAAAAAAAAATTTTTTTAAAAA
>Seqence_ID(Num2) AAAAAAATTTTTTTAAAATTTAATTTAATTATTAT
>Sequence_ID (Num3)AAATTTTATTAGGAGGGA
So far I have this:
input = open('LG_allseqs.txt', 'r')
output = open('LG_Seqs.txt', 'w')
for line in input.readlines():
if line == '>':
output.write('\n' + line)
else:
output.write(line)
There is no error messages (the syntax is "correct") however I do not generate the particular output I want. Any suggestions would be very much appreciated.