Mercurial > repos > greg > gene_family_classifier
comparison gene_family_classifier.py @ 109:06f121a1974e draft
Uploaded
author | greg |
---|---|
date | Mon, 27 Feb 2017 14:34:41 -0500 |
parents | 82144bc3626a |
children | 6cb3520313b9 |
comparison
equal
deleted
inserted
replaced
108:82144bc3626a | 109:06f121a1974e |
---|---|
83 sys.exit(1) | 83 sys.exit(1) |
84 | 84 |
85 | 85 |
86 def write_html_output(output, title, dir): | 86 def write_html_output(output, title, dir): |
87 with open(output, 'w') as fh: | 87 with open(output, 'w') as fh: |
88 fh.write('<html><head><title>%s</title></head><body><p/><ul>\n' % title) | 88 fh.write('<html><head><title>%s</title></head>\n' % title) |
89 fh.write('<body><p/><table>\n') | |
90 fh.write('<tr><th>Size</th><th>Name</th></tr>\n') | |
89 for fname in os.listdir(dir): | 91 for fname in os.listdir(dir): |
90 fh.write('<li><a type="text/plain" href="%s">%s</a></li>\n' % (fname, fname)) | 92 size = str(os.path.getsixe(fname)) |
91 fh.write('</ul></body></html>\n') | 93 link = '<a href="%s" type="text/plain">%s</a>\n' % (fname, fname) |
94 fh.write('<tr><td>%s</td><td>%s</td></tr>\n' % (size, link)) | |
95 fh.write('</table></body></html>\n') | |
92 | 96 |
93 | 97 |
94 # Define command response buffers. | 98 # Define command response buffers. |
95 tmp_out = tempfile.NamedTemporaryFile().name | 99 tmp_out = tempfile.NamedTemporaryFile().name |
96 tmp_stdout = open(tmp_out, 'wb') | 100 tmp_stdout = open(tmp_out, 'wb') |
140 # Handle orthogroups outputs. | 144 # Handle orthogroups outputs. |
141 if create_ortho_sequences: | 145 if create_ortho_sequences: |
142 if create_corresponding_coding_sequences: | 146 if create_corresponding_coding_sequences: |
143 out_file = args.output_ptorthocs | 147 out_file = args.output_ptorthocs |
144 orthogroups_fasta_dest_dir = args.output_ptorthocs_dir | 148 orthogroups_fasta_dest_dir = args.output_ptorthocs_dir |
145 title = 'Orthogroups with corresponding coding sequences' | 149 title = 'Orthogroups and corresponding coding sequences files' |
146 else: | 150 else: |
147 out_file = args.output_ptortho | 151 out_file = args.output_ptortho |
148 orthogroups_fasta_dest_dir = args.output_ptortho_dir | 152 orthogroups_fasta_dest_dir = args.output_ptortho_dir |
149 title = 'Orthogroups' | 153 title = 'Orthogroups files' |
150 orthogroups_fasta_src_dir = os.path.join(OUTPUT_DIR, 'orthogroups_fasta') | 154 orthogroups_fasta_src_dir = os.path.join(OUTPUT_DIR, 'orthogroups_fasta') |
151 move_directory_files(orthogroups_fasta_src_dir, orthogroups_fasta_dest_dir) | 155 move_directory_files(orthogroups_fasta_src_dir, orthogroups_fasta_dest_dir) |
152 write_html_output(out_file, title, orthogroups_fasta_dest_dir) | 156 write_html_output(out_file, title, orthogroups_fasta_dest_dir) |
153 # Handle single copy orthogroup outputs. | 157 # Handle single copy orthogroup outputs. |
154 if args.output_ptsco is not None: | 158 if args.output_ptsco is not None: |
155 single_copy_fasta_src_dir = os.path.join(OUTPUT_DIR, 'single_copy_fasta') | 159 single_copy_fasta_src_dir = os.path.join(OUTPUT_DIR, 'single_copy_fasta') |
156 single_copy_fasta_dest_dir = args.output_ptsco_dir | 160 single_copy_fasta_dest_dir = args.output_ptsco_dir |
157 title = 'Single copy orthogroups' | 161 title = 'Single copy orthogroups files' |
158 move_directory_files(single_copy_fasta_src_dir, single_copy_fasta_dest_dir) | 162 move_directory_files(single_copy_fasta_src_dir, single_copy_fasta_dest_dir) |
159 write_html_output(args.output_ptsco, title, single_copy_fasta_dest_dir) | 163 write_html_output(args.output_ptsco, title, single_copy_fasta_dest_dir) |