Mercurial > repos > miller-lab > genome_diversity
annotate add_fst_column.py @ 28:184d14e4270d
Update to Miller Lab devshed revision 4ede22dd5500
author | Richard Burhans <burhans@bx.psu.edu> |
---|---|
date | Wed, 17 Jul 2013 12:46:46 -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) != 13: |
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_reads, min_qual, retain, discard_fixed, biased, output, ind_arg = sys.argv[1:] |
0 | 13 |
14 p_total = Population() | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
15 p_total.from_wrapped_dict(ind_arg) |
0 | 16 |
17 p1 = Population() | |
18 p1.from_population_file(p1_input) | |
19 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
|
20 gd_util.die('There is an individual in population 1 that is not in the SNP table') |
0 | 21 |
22 p2 = Population() | |
23 p2.from_population_file(p2_input) | |
24 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
|
25 gd_util.die('There is an individual in population 2 that is not in the SNP table') |
0 | 26 |
27 ################################################################################ | |
28 | |
29 prog = 'Fst_column' | |
30 | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
31 args = [ prog ] |
0 | 32 args.append(input) |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
33 args.append(data_source) |
0 | 34 args.append(min_reads) |
35 args.append(min_qual) | |
36 args.append(retain) | |
37 args.append(discard_fixed) | |
38 args.append(biased) | |
39 | |
40 columns = p1.column_list() | |
41 for column in columns: | |
24
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
42 if input_type == 'gd_genotype': |
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
43 column = int(column) - 2 |
0 | 44 args.append('{0}:1'.format(column)) |
45 | |
46 columns = p2.column_list() | |
47 for column in columns: | |
24
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
48 if input_type == 'gd_genotype': |
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
49 column = int(column) - 2 |
0 | 50 args.append('{0}:2'.format(column)) |
51 | |
27
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
52 with open(output, 'w') as fh: |
8997f2ca8c7a
Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents:
24
diff
changeset
|
53 gd_util.run_program(prog, args, stdout=fh) |
0 | 54 |
55 sys.exit(0) | |
56 |