I'm new to biopython. I can't seem to get nested for loops to iterate properly. Here's a simple example:
from Bio import SeqIO infile = file('testseq.fna') midfile = file('mids.fna') c = 0 for midseq,line in SeqIO.parse(midfile,"fasta"): print midseq.id print midseq.seq for line in SeqIO.parse(infile,"fasta"): print line.seq
I have 12 simple fasta records in testseq.fna, and 96 mid identifiers in mids.fna. I should get a list of 96 mid ids and seqs, each followed by 12 testseq sequences, but what I get is just the first mid and sequences then just the other mids with no sequence... run it and you will see what I mean. I'm pulling my hair out - why doesn't Python run the 'line' loop for each 'mid' loop like it should??
Thanks for any help - I know its surprising but I couldn't find an answer to this anywhere (on python forum they were just rude!).