def split_fasta(f, id2f):
opened = {}<EOL>for seq in parse_fasta(f):<EOL><INDENT>id = seq[<NUM_LIT:0>].split('<STR_LIT:>>')[<NUM_LIT:1>].split()[<NUM_LIT:0>].rsplit('<STR_LIT:_>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>if id not in id2f:<EOL><INDENT>continue<EOL><DEDENT>fasta = id2f[id]<EOL>if fasta not in opened:<EOL><INDENT>opened[fasta] = '<STR_LIT>' % fasta<EOL><DEDENT>seq[<NUM_LIT:1>] += '<STR_LIT:\n>'<EOL>with open(opened[fasta], '<STR_LIT>') as f_out:<EOL><INDENT>f_out.write('<STR_LIT:\n>'.join(seq))<EOL><DEDENT><DEDENT>
split fasta file into separate fasta files based on list of scaffolds
that belong to each separate file