parse sam file and check mapping quality

def parse_sam(sam, qual):
    """
    parse sam file and check mapping quality
    """
    for line in sam:
        if line.startswith('@'):
            continue
        line = line.strip().split()
        if int(line[4]) == 0 or int(line[4]) < qual:
            continue
        yield line