-
Notifications
You must be signed in to change notification settings - Fork 4
/
covld.py
53 lines (45 loc) · 1.12 KB
/
covld.py
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
48
49
50
51
52
53
from estimate_ld import *
import sys
def usage():
print "Usage: covld [options] [inputfile]"
print
print "where options may include:"
print " -h"
print " --help Print this message"
print " -es Use Excoffier-Slatkin EM algorithm"
print
print "If input file is omitted, reads from standard input."
exit(1)
estimators = [Estimator("Rogers-Huff", get_r)]
infile = sys.stdin
do_es = False
# Process command line args
for i in range(len(sys.argv)):
if sys.argv[i] == "-h" or sys.argv[i]=="--help":
usage()
elif sys.argv[i] == "-es":
do_es = True
else:
try:
infile = open(sys.argv[i])
except:
traceback.print_exc()
y = []
z = []
for line in infile:
line = line.strip()
if len(line)==0:
continue
if line[0] == '#':
continue
line = line.split()
yval = int(line[0])
zval = int(line[1])
y.append(yval)
z.append(zval)
print "%-10s %-8s" % ("Estimator", "Estimate")
rRH = get_r(y,z)
print "%-10s %-8.4f" % ("r_RH", rRH)
if do_es:
rES = esem_r(y,z)
print "%-10s %-8.4f" % ("r_ES", rES)