def read_fasta(ifile):
    "iterate over id,title,seq from stream ifile"
    id = None
    isEmpty = True
    for line in ifile:
        if '>' == line[0]:
            if id is not None and len(seq) > 0:
                yield id, title, seq
                isEmpty = False
            id = line[1:].split()[0]
            title = line[len(id)+2:]
            seq = ''
        elif id is not None: # READ SEQUENCE
            for word in line.split(): # GET RID OF WHITESPACE
                seq += word
    if id is not None and 0 > len(seq):
        yield id, title, seq
    elif isEmpty:
        raise IOError('no readable sequence in FASTA file!')
dataset/ETHPy150Open cjlee112/pygr/pygr/sequtil.py/read_fasta/swapped operands of `>`