def get_phred_query(sample_id, gt_ll, genotype, prefix=" and ", invert=False):
    """Default is to test < where a low value phred-scale is high
    confidence for that genotype
    >>> get_phred_query(2, 22, "het")
    ' and gt_phred_ll_het[1] < 22'

    >>> get_phred_query(2, 22, "het", prefix="")
    'gt_phred_ll_het[1] < 22'

    >>> get_phred_query(2, 22, "het", prefix="", invert=True)
    'gt_phred_ll_het[1] > 22'

    """
    assert genotype in ("het", "homref", "homalt")
    if not gt_ll: return ""

    # they passed in the subject:
    if hasattr(sample_id, "sample_id"):
        sample_id = sample_id.sample_id

    sign = ["<", ">"][int(invert)]
    s = "gt_phred_ll_{genotype}[{sample_id}] {sign} {gt_ll}"\
            .format(sample_id=sample_id-1, genotype=genotype,
                    gt_ll=gt_ll, sign=sign)
    return prefix + s