Mercurial > repos > rico > test_repository
comparison rename_individuals.py @ 0:99a67ac88802 default tip
Uploaded
author | rico |
---|---|
date | Thu, 05 Apr 2012 14:22:50 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:99a67ac88802 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import sys | |
4 from Population import Population | |
5 | |
6 input_file, output_file = sys.argv[1:3] | |
7 tags = sys.argv[3:] | |
8 | |
9 aliases = {} | |
10 | |
11 for tag in tags: | |
12 column, alias = tag.split(':', 1) | |
13 column = column.strip() | |
14 alias = alias.strip() | |
15 if alias: | |
16 aliases[column] = alias | |
17 | |
18 p_total = Population() | |
19 p_total.from_population_file(input_file) | |
20 | |
21 with open(output_file, 'w') as ofh: | |
22 for column in p_total.column_list(): | |
23 individual = p_total.individual_with_column(column) | |
24 real_name = individual.real_name | |
25 rv = [column, real_name, ''] | |
26 if column in aliases: | |
27 alias = aliases[column] | |
28 if alias != real_name: | |
29 rv[2] = alias | |
30 print >> ofh, '\t'.join(rv) | |
31 | |
32 sys.exit(0) | |
33 |