Mercurial > repos > rico > quote_test
comparison add_fst_column.py @ 0:939c20789501 default tip
Uploaded
| author | rico |
|---|---|
| date | Fri, 06 Apr 2012 10:51:28 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:939c20789501 |
|---|---|
| 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 | |
| 21 input, p1_input, p2_input, genotypes, min_reads, min_qual, retain, discard_fixed, biased, output = sys.argv[1:11] | |
| 22 individual_metadata = sys.argv[11:] | |
| 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: | |
| 55 args.append('{0}:1'.format(column)) | |
| 56 | |
| 57 columns = p2.column_list() | |
| 58 for column in columns: | |
| 59 args.append('{0}:2'.format(column)) | |
| 60 | |
| 61 fh = open(output, 'w') | |
| 62 | |
| 63 #print "args:", ' '.join(args) | |
| 64 p = subprocess.Popen(args, bufsize=-1, stdin=None, stdout=fh, stderr=sys.stderr) | |
| 65 rc = p.wait() | |
| 66 fh.close() | |
| 67 | |
| 68 sys.exit(0) | |
| 69 |
