def pid(col, ignore_gaps=False):
hist = {}<EOL>total = <NUM_LIT:0><EOL>found_non_gap = False<EOL>for v in col.values():<EOL><INDENT>if v == sequence.GAP_CHAR:<EOL><INDENT>if ignore_gaps:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>total += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>found_non_gap = True<EOL>if v not in hist:<EOL><INDENT>hist[v] = <NUM_LIT:0><EOL><DEDENT>hist[v] += <NUM_LIT:1><EOL>total += <NUM_LIT:1><EOL><DEDENT><DEDENT>if not found_non_gap:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return max(hist.values()) / float(total)<EOL>
Compute the percent identity of a an alignment column.

Define PID as the frequency of the most frequent nucleotide in the column.

:param col:         an alignment column; a dictionary where keys are seq.
                    names and values are the nucleotide in the column for
                    that sequence.
:param ignore_gaps: if True, do not count gaps towards the total number of
                    sequences in the column (i.e. the denominator of the
                    fraction).
:raise ValueError: if the column contains only gaps.