Mercurial > repos > miller-lab > genome_diversity
comparison offspring_heterozygosity.py @ 31:a631c2f6d913
Update to Miller Lab devshed revision 3c4110ffacc3
author | Richard Burhans <burhans@bx.psu.edu> |
---|---|
date | Fri, 20 Sep 2013 13:25:27 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
30:4188853b940b | 31:a631c2f6d913 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import sys | |
4 import gd_util | |
5 | |
6 from Population import Population | |
7 | |
8 ################################################################################ | |
9 | |
10 if len(sys.argv) != 7: | |
11 gd_util.die('Usage') | |
12 | |
13 input, input_type, ind_arg, p1_input, p2_input, output = sys.argv[1:] | |
14 | |
15 p_total = Population() | |
16 p_total.from_wrapped_dict(ind_arg) | |
17 | |
18 p1 = Population() | |
19 p1.from_population_file(p1_input) | |
20 if not p_total.is_superset(p1): | |
21 gd_util.die('There is an individual in the first population that is not in the SNP table') | |
22 | |
23 p2 = Population() | |
24 p2.from_population_file(p2_input) | |
25 if not p_total.is_superset(p2): | |
26 gd_util.die('There is an individual in the second population that is not in the SNP table') | |
27 | |
28 ################################################################################ | |
29 | |
30 prog = 'offspring_heterozygosity' | |
31 | |
32 args = [ prog ] | |
33 args.append(input) # a Galaxy SNP table | |
34 | |
35 for tag in p1.tag_list(): | |
36 column, name = tag.split(':') | |
37 | |
38 if input_type == 'gd_genotype': | |
39 column = int(column) - 2 | |
40 | |
41 tag = '{0}:{1}:{2}'.format(column, 0, name) | |
42 args.append(tag) | |
43 | |
44 for tag in p2.tag_list(): | |
45 column, name = tag.split(':') | |
46 | |
47 if input_type == 'gd_genotype': | |
48 column = int(column) - 2 | |
49 | |
50 tag = '{0}:{1}:{2}'.format(column, 1, name) | |
51 args.append(tag) | |
52 | |
53 with open(output, 'w') as fh: | |
54 gd_util.run_program(prog, args, stdout=fh) | |
55 | |
56 ################################################################################ | |
57 | |
58 sys.exit(0) | |
59 |