def unmapped(sam, mates):
    """
    get unmapped reads
    """
    for read in sam:
        if read.startswith('@') is True:
            continue
        read = read.strip().split()
        if read[2] == '*' and read[6] == '*':
                yield read
        elif mates is True:
            if read[2] == '*' or read[6] == '*':
                yield read
            for i in read:
                if i == 'YT:Z:UP':
                    yield read
get unmapped reads