Mercurial > repos > miller-lab > genome_diversity
annotate average_fst.py @ 30:4188853b940b
Update to Miller Lab devshed revision eb4e61d024db
author | Richard Burhans <burhans@bx.psu.edu> |
---|---|
date | Fri, 26 Jul 2013 12:51:13 -0400 |
parents | 8997f2ca8c7a |
children |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
2 | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
3 import gd_util |
0 | 4 import sys |
5 from Population import Population | |
6 | |
7 ################################################################################ | |
8 | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
9 if len(sys.argv) != 12: |
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
10 gd_util.die('Usage') |
0 | 11 |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
12 input, p1_input, p2_input, input_type, data_source, min_total_count, discard_fixed, output, shuffles, p0_input, ind_arg = sys.argv[1:] |
0 | 13 |
14 try: | |
15 shuffle_count = int(shuffles) | |
16 except: | |
17 shuffle_count = 0 | |
18 | |
19 p_total = Population() | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
20 p_total.from_wrapped_dict(ind_arg) |
0 | 21 |
22 p1 = Population() | |
23 p1.from_population_file(p1_input) | |
24 if not p_total.is_superset(p1): | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
25 gd_util.die('There is an individual in population 1 that is not in the SNP table') |
0 | 26 |
27 p2 = Population() | |
28 p2.from_population_file(p2_input) | |
29 if not p_total.is_superset(p2): | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
30 gd_util.die('There is an individual in population 2 that is not in the SNP table') |
0 | 31 |
32 p0 = None | |
33 if shuffle_count > 0: | |
34 p0 = Population() | |
35 p0.from_population_file(p0_input) | |
36 if not p_total.is_superset(p0): | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
37 gd_util.die('There is an individual in population 0 that is not in the SNP table') |
0 | 38 |
39 ################################################################################ | |
40 | |
41 prog = 'Fst_ave' | |
42 | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
43 args = [ prog ] |
0 | 44 args.append(input) |
45 args.append(data_source) | |
46 args.append(min_total_count) | |
47 args.append(discard_fixed) | |
48 args.append(shuffles) | |
49 | |
50 columns = p1.column_list() | |
51 for column in columns: | |
24
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
18
diff
changeset
|
52 if input_type == 'gd_genotype': |
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
18
diff
changeset
|
53 column = int(column) - 2 |
0 | 54 args.append('{0}:1'.format(column)) |
55 | |
56 columns = p2.column_list() | |
57 for column in columns: | |
24
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
18
diff
changeset
|
58 if input_type == 'gd_genotype': |
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
18
diff
changeset
|
59 column = int(column) - 2 |
0 | 60 args.append('{0}:2'.format(column)) |
61 | |
62 if p0 is not None: | |
63 columns = p0.column_list() | |
64 for column in columns: | |
24
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
18
diff
changeset
|
65 if input_type == 'gd_genotype': |
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
18
diff
changeset
|
66 column = int(column) - 2 |
0 | 67 args.append('{0}:0'.format(column)) |
68 | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
69 with open(output, 'w') as fh: |
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
70 gd_util.run_program(prog, args, stdout=fh) |
0 | 71 |
72 sys.exit(0) | |
73 |