annotate add_fst_column.py @ 36:51cd0307fb70

Phylip's extra ouputs are now stored in the job working directory
author Richard Burhans <burhans@bx.psu.edu>
date Wed, 20 Nov 2013 16:32:01 -0500
parents 8997f2ca8c7a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
1 #!/usr/bin/env python
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
4 import sys
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
5 from Population import Population
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
6
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
7 ################################################################################
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
13
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
16
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
17 p1 = Population()
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
18 p1.from_population_file(p1_input)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
21
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
22 p2 = Population()
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
23 p2.from_population_file(p2_input)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
26
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
27 ################################################################################
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
28
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
29 prog = 'Fst_column'
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
30
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 24
diff changeset
31 args = [ prog ]
0
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
34 args.append(min_reads)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
35 args.append(min_qual)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
36 args.append(retain)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
37 args.append(discard_fixed)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
38 args.append(biased)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
39
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
40 columns = p1.column_list()
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
44 args.append('{0}:1'.format(column))
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
45
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
46 columns = p2.column_list()
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
50 args.append('{0}:2'.format(column))
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
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
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
54
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
55 sys.exit(0)
2c498d40ecde Uploaded
miller-lab
parents:
diff changeset
56