Mercurial > repos > miller-lab > genome_diversity
comparison make_phylip_hooks.py @ 35:ea52b23f1141
Bug fixes for Draw variants, Phylip, and gd_d_tools
author | Richard Burhans <burhans@bx.psu.edu> |
---|---|
date | Wed, 20 Nov 2013 13:46:10 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
34:f739a296a339 | 35:ea52b23f1141 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 def exec_before_job(app, inp_data=None, out_data=None, tool=None, param_dict=None): | |
4 pass | |
5 | |
6 def exec_after_process(app, inp_data=None, out_data=None, param_dict=None, tool=None, stdout=None, stderr=None): | |
7 output_name = 'output1' | |
8 | |
9 ## check for output | |
10 try: | |
11 first_output = out_data[output_name] | |
12 except: | |
13 return | |
14 | |
15 ## check for collected datasets | |
16 try: | |
17 collected_dict = param_dict['__collected_datasets__']['primary'][output_name] | |
18 except: | |
19 return | |
20 | |
21 if len(collected_dict.keys()) == 0: | |
22 return | |
23 | |
24 ## check for fasta file | |
25 try: | |
26 fasta_file = inp_data['fasta_input'] | |
27 except: | |
28 return | |
29 | |
30 ## find missing fasta header | |
31 first_output_name = None | |
32 with open(fasta_file.get_file_name()) as fh: | |
33 for line in fh: | |
34 if line[0] != '>': | |
35 continue | |
36 name = line[1:] | |
37 name = name.strip() | |
38 name = name.split()[0] | |
39 name = name.replace('_', '-') | |
40 if name not in collected_dict: | |
41 first_output_name = name | |
42 break | |
43 | |
44 ## fix name | |
45 if first_output_name is not None: | |
46 first_output.name = '%s (%s)' % (first_output.name, first_output_name) | |
47 |