human
Complete this python program:
def _augment_blast_hsp(hsp, attr):
assistant
#Here is the Python program you requested.

    """Calculates the given HSP attribute, for writing.
    """
    if (attr == 'aln_span'):
        func = (lambda hsp: ((hsp.ident_num + hsp.mismatch_num) + hsp.gap_num))
    elif attr.startswith('ident'):
        func = (lambda hsp: ((hsp.aln_span - hsp.mismatch_num) - hsp.gap_num))
    elif attr.startswith('gap'):
        func = (lambda hsp: ((hsp.aln_span - hsp.ident_num) - hsp.mismatch_num))
    elif (attr == 'mismatch_num'):
        func = (lambda hsp: ((hsp.aln_span - hsp.ident_num) - hsp.gap_num))
    elif (attr == 'gapopen_num'):
        if ((not hasattr(hsp, 'query')) or (not hasattr(hsp, 'hit'))):
            def mock(hsp):
                raise AttributeError
            func = mock
        else:
            func = _compute_gapopen_num
    if ((not hasattr(hsp, attr)) and (not attr.endswith('_pct'))):
        value = func(hsp)
        setattr(hsp, attr, value)
    if (attr == 'ident_pct'):
        func2 = (lambda hsp: ((hsp.ident_num / float(hsp.aln_span)) * 100))
    elif (attr == 'pos_pct'):
        func = (lambda hsp: ((hsp.pos_num / float(hsp.aln_span)) * 100))
    elif (attr == 'gap_pct'):
        func2 = (lambda hsp: ((hsp.gap_num / float(hsp.aln_span)) * 100))
    else:
        func2 = None
    if (func2 is not None):
        value = func2(hsp)
        setattr(hsp, attr, value)