def get_window_data(conn, analysis_type, temp_file):
    """
    Create a temp file of the requested statistic for each variant.

    Execute a query against the variants table
    that extracts the requested column for each variant.
    save the results to '.temp.pid', which will be loaded
    into a pybedtools BedTool for use with the bedtools map
    function.  This will compute the requested statistic
    for each variant in the variants table
    """
    if analysis_type == 'hwe':
        column = 'hwe'
    elif analysis_type == 'nucl_div':
        column = 'pi'
    t = open(temp_file, 'w')
    query = ('SELECT chrom,start,end,' + column +
        ' FROM variants ORDER BY chrom,start')
    for row in conn.execute(query):
        if row[column] is not None:
            t.write('%s\t%d\t%d\t%f\n' % (str(row['chrom']), int(row[
                'start']), int(row['end']), float(row[column])))
    t.close()
    return 4
