def convert_fasta(handle):
    """
    Taken from gotoh2 by artpoon
    Parse FASTA file as a list of header, sequence list objects
    :param handle:  open file stream
    :return:  List of [header, sequence] records
    """
    result = []
    h, sequence = None, ''

    for line in handle:
        if line.startswith('$'):  # skip comment
            continue
        elif line.startswith('>') or line.startswith('#'):
            if len(sequence) > 0:
                result.append([h, sequence])
                sequence = ''
            h = line.lstrip('>').rstrip()
        else:
            sequence += line.strip().upper()

    result.append([h, sequence])  # handle last entry
    return result