Mercurial > repos > miller-lab > genome_diversity
annotate add_fst_column.py @ 24:248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
author | Richard Burhans <burhans@bx.psu.edu> |
---|---|
date | Tue, 28 May 2013 16:24:19 -0400 |
parents | 2c498d40ecde |
children | 8997f2ca8c7a |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
2 | |
3 # <command interpreter="python"> | |
4 # add_fst_column.py "$input" "$p1_input" "$p2_input" "$data_source.choice" "$data_source.min_value" "$retain" "$discard_fixed" "$biased" "$output" | |
5 # #for $individual, $individual_col in zip($input.dataset.metadata.individual_names, $input.dataset.metadata.individual_columns) | |
6 # #set $arg = '%s:%s' % ($individual_col, $individual) | |
7 # "$arg" | |
8 # #end for | |
9 # </command> | |
10 | |
11 import sys | |
12 import subprocess | |
13 from Population import Population | |
14 | |
15 ################################################################################ | |
16 | |
17 if len(sys.argv) < 12: | |
18 print >> sys.stderr, "Usage" | |
19 sys.exit(1) | |
20 | |
24
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
21 input, p1_input, p2_input, input_type, genotypes, min_reads, min_qual, retain, discard_fixed, biased, output = sys.argv[1:12] |
248b06e86022
Added gd_genotype datatype. Modified tools to support new datatype.
Richard Burhans <burhans@bx.psu.edu>
parents:
0
diff
changeset
|
22 individual_metadata = sys.argv[12:] |
0 | 23 |
24 p_total = Population() | |
25 p_total.from_tag_list(individual_metadata) | |
26 | |
27 p1 = Population() | |
28 p1.from_population_file(p1_input) | |
29 if not p_total.is_superset(p1): | |
30 print >> sys.stderr, 'There is an individual in population 1 that is not in the SNP table' | |
31 sys.exit(1) | |
32 | |
33 p2 = Population() | |
34 p2.from_population_file(p2_input) | |
35 if not p_total.is_superset(p2): | |
36 print >> sys.stderr, 'There is an individual in population 2 that is not in the SNP table' | |
37 sys.exit(1) | |
38 | |
39 ################################################################################ | |
40 | |
41 prog = 'Fst_column' | |
42 | |
43 args = [] | |
44 args.append(prog) | |
45 args.append(input) | |
46 args.append(genotypes) | |
47 args.append(min_reads) | |
48 args.append(min_qual) | |
49 args.append(retain) | |
50 args.append(discard_fixed) | |
51 args.append(biased) | |
52 | |
53 columns = p1.column_list() | |
54 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
|
55 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
|
56 column = int(column) - 2 |
0 | 57 args.append('{0}:1'.format(column)) |
58 | |
59 columns = p2.column_list() | |
60 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
|
61 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
|
62 column = int(column) - 2 |
0 | 63 args.append('{0}:2'.format(column)) |
64 | |
65 fh = open(output, 'w') | |
66 | |
67 #print "args:", ' '.join(args) | |
68 p = subprocess.Popen(args, bufsize=-1, stdin=None, stdout=fh, stderr=sys.stderr) | |
69 rc = p.wait() | |
70 fh.close() | |
71 | |
72 sys.exit(0) | |
73 |