aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance/dataset/correlations.py
blob: b089e446e4ced9839deb18c88c13b472f2568fea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Author:               Lei Yan
# Create Date:          2014-01-21
# Last Update Date:     2014-01-24

# import
import sys
import os
import re
import MySQLdb
import ConfigParser

def main(argv):

    # load configuration from configuration file
    config = ConfigParser.ConfigParser()
    config.read(argv[1])
    genofile = config.get('configuration', 'genofile')

    # parse genofile
    genotypes = []
    file_geno = open(genofile, 'r')
    for line in file_geno:
        line = line.strip()
        if line.startswith('#'):
            continue
        if line.startswith('@'):
            continue
        cells = line.split()
        if line.startswith("Chr"):
            strains = cells[4:]
            continue
        genotype = {}
        genotype['chr'] = cells[0]
        genotype['locus'] = cells[1]
        genotype['cm'] = cells[2]
        genotype['mb'] = cells[3]
        genotype['values'] = cells[4:]
        genotypes.append(genotype)
    print "get %d strains:\t%s" % (len(strains), strains)
    print "load %d genotypes" % len(genotypes)

    # phenotypes

# main
if __name__ == "__main__":
    main(sys.argv)
    print "exit successfully"