Here is what the list of sequences looks like in the file brca.example.illumina.0.1.fasta
>Frag_1 chr17 (Strand + Offset 106709--107175) 467M 101M
AGGCAGGTCTCAAACTCCTGACCTCAGGTGATCCACCCACCTCAAGCCTCCCAAAGTGCT
GGGATTATAGGCATGAGCCACCATGTCCGGCAAGTTTCTTT
>Frag_2 chr17 (Strand + Offset 5449--5912) 464M 101M
ACTCCTGACAAGTGATCCACCTGCCTCGGCCTCCCAAAGTGCTGGGATTACAGACATGAG
CCACCATGCCCAGCCTCCAGCCCATCATTTCTTGATGATTT
>Frag_3 chr17 (Strand + Offset 82312--82850) 539M 101M
TTTGCCATAAAGTGCCTGCCCTCTAGCCTCTACTCTTCCAGTTGCGGCTTATTGCATCAC
AGTAATTGCTGTACGAAGGTCAGAATCGCTACCTATTGTCC
>Frag_4 chr17 (Strand - Offset 1052--1590) 539M 101M
TTGCAGTGAGCCAAGATCATACCACGGCACTCCAGCCTGGGTGACAGTGAGACTGTGGCT
CAACAAAAAAAAAAAAAAAAGGAAAATGAAACTAGAAGAGA
And so on. I would like to generate the reverse complement for each of these, so here is what I have written
for record in SeqIO.parse("brca.example.illumina.0.1.fasta", "fasta"):
y = record.seq.reverse_complement()
rev_comp2 = open("python_output2.txt", "w")
rev_comp2.write(str(y))
Upon running the script and opening up the text file, it appears to have only generated the reverse complement for the first sequence. Here is the content of the text file
GGCTGGAGTGCAGTGGCATGATCTCGGCTCACTGCAAGCTCTGCCTCCCAGGCTCACACCATTCTCCTGCCTCAGCCTCCCAAGCAGCTGGGACTACAGGC
I thought that including "for record in SeqIO.parse("etc. etc.") would generate the reverse complement for each sequence in the file, but apparently not? What can I write in my script that will generate the reverse complement for each sequence?