def david_results_iterator(fn, verbose=False):
first = True<EOL>for line in open(fn):<EOL><INDENT>line = line.strip()<EOL>if line == "<STR_LIT>":<EOL><INDENT>continue<EOL><DEDENT>if first:<EOL><INDENT>first = False<EOL>continue<EOL><DEDENT>parts = line.split("<STR_LIT:\t>")<EOL>if len(parts) != NUM_FIELDS_IN_DAVID_RECORD:<EOL><INDENT>raise IOError("<STR_LIT>" + fn + "<STR_LIT>"<EOL>+ "<STR_LIT>" + str(NUM_FIELDS_IN_DAVID_RECORD) + "<STR_LIT:U+0020>"<EOL>+ "<STR_LIT>"<EOL>+ str(len(parts)) + "<STR_LIT>")<EOL><DEDENT>n_parts = parts[<NUM_LIT:1>].split("<STR_LIT>")<EOL>name = n_parts[-<NUM_LIT:1>].strip()<EOL>identifier = n_parts[<NUM_LIT:0>] if len(n_parts) > <NUM_LIT:1> else None<EOL>catagory = parts[<NUM_LIT:0>].strip()<EOL>try:<EOL><INDENT>p_val = float(parts[PVAL_FIELD_NUM])<EOL><DEDENT>except ValueError:<EOL><INDENT>raise IOError("<STR_LIT>" + fn + "<STR_LIT>"<EOL>+ "<STR_LIT>" + str(PVAL_FIELD_NUM) + "<STR_LIT:U+0020>"<EOL>+ "<STR_LIT>"<EOL>+ "<STR_LIT>"<EOL>+ str(parts[PVAL_FIELD_NUM]))<EOL><DEDENT>yield GeneOntologyEnrichmentResult(name, p_val, identifier, catagory)<EOL><DEDENT>
Iterate over a DAVID result set and yeild GeneOntologyTerm objects
representing each of the terms reported. The expected format for a DAVID
result file is tab-seperated format. The following fields should be present:

===  ===============  ==========  ====================================
Num  Field                 Type        Example
===  ===============  ==========  ====================================
0    Category         string      GOTERM_BP_FAT
1    Term             string      GO:0046907~intracellular transport
2    Count            int         43
3    Percent          float       11.345646437994723
4    PValue           float       1.3232857694449546E-9
5    Genes            string      ARSB, KPNA6, GNAS
6    List Total       int         310
7    Pop Hits         int         657
8    Pop Total        int         13528
9    Fold Enrichment  float       2.8561103746256196
10   Bonferroni       float       2.6293654579179204E-6
11   Benjamini        float       2.6293654579179204E-6
12   FDR              float       2.2734203852792234E-6
===  ===============  ==========  ====================================

The first line is a header giving the field names -- this is ignored though,
and we expect them in the order given above.

Most of the fields are ignored at present; we take fields 0,1, and 11 (as the
significance/p-value). When parsing the term field, we try to extract a term
ID by splitting on tilde, but if we can't then this is set to None.

:param fn: the file to parse
:param verbose: if True, output progress to stderr.