split fasta file into separate fasta files based on list of scaffolds
    that belong to each separate file

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