Iterator that yields tuples containing a sequence label and the sequence itself
    @param fastaFN - the FASTA filename to open and parse
    @return - an iterator yielding tuples of the form (label, sequence) from the FASTA file

def fastaIterator(fastaFN):
    '''
    Iterator that yields tuples containing a sequence label and the sequence itself
    @param fastaFN - the FASTA filename to open and parse
    @return - an iterator yielding tuples of the form (label, sequence) from the FASTA file
    '''
    if fastaFN[len(fastaFN)-3:] == '.gz':
        fp = gzip.open(fastaFN, 'r')
    else:
        fp = open(fastaFN, 'r')
    
    label = ''
    segments = []
    line = ''
    
    for line in fp:
        if line[0] == '>':
            if label != '':
                yield (label, ''.join(segments))
            label = (line.strip('\n')[1:]).split(' ')[0]
            segments = []
        else:
            segments.append(line.strip('\n'))
            
    if label != '' and len(segments) > 0:
        yield (label, ''.join(segments))
    
    fp.close()