def buildGeneMatrix( tracks, analysis, statement, outfile ):

    dbhandle = sqlite3.connect( PARAMS["database"] )
    cc = dbhandle.cursor()

    all_genes = [ x[0] for x in cc.execute( '''SELECT DISTINCT gene_id FROM gene_info''' % locals() )]

    gene2row = dict( [(x[1],x[0]) for x in enumerate( all_genes ) ] )
    matrix = numpy.zeros( (len(all_genes), len( analysis ) * len(tracks) ), numpy.int )

    col = 0
    for track in tracks:
        
        for label, field_where in analysis:
            genes = [ x[0] for x in cc.execute( statement % locals() ) ]
            for gene_id in genes:
                matrix[gene2row[gene_id]][col] = 1
            col += 1
            
    outf = open( outfile, "w")
    outf.write( "gene_id\t%s\n" % "\t".join( "%s_%s" % (x,y[0]) for x,y in itertools.product( tracks, analysis) ) )
    for gene_id in all_genes:
        outf.write( "%s\t%s\n" % (gene_id, "\t".join( map(str, matrix[gene2row[gene_id]] ) ) ) )
    outf.close()

####################################################################
Returns the number of log lines currently buffered.
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_snps.py/buildGeneMatrix--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/logservice/logservice.py/LogsBuffer.lines