Mercurial > repos > iuc > qiime_make_otu_heatmap
comparison beta_diversity_through_plots_html_generation.py @ 0:a3d1104d090c draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/qiime/ commit c9bf747b23b4a9d6adc20c7740b9247c22654862
author | iuc |
---|---|
date | Thu, 18 May 2017 09:28:39 -0400 |
parents | |
children | a3b69e0b9246 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a3d1104d090c |
---|---|
1 #!/usr/bin/env python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 import argparse | |
5 import os | |
6 import re | |
7 | |
8 | |
9 def generate_index_html(dir_list, args): | |
10 with open(args.html_file, 'w') as index_html_file: | |
11 s = "" | |
12 s += '<html>\n' | |
13 s += '\t<head><title>PCoA beta diversity results</title></head>\n' | |
14 s += '\t<body>\n' | |
15 s += '\t\t<a href="http://www.qiime.org" target="_blank">' | |
16 s += '<img src="http://qiime.org/_static/wordpressheader.png" ' | |
17 s += 'alt="www.qiime.org""/></a>\n' | |
18 s += '\t\t<p>\n' | |
19 s += '\t\t\tBeta diversity metrics\n' | |
20 s += '\t\t\t<ul>\n' | |
21 | |
22 for directory in dir_list: | |
23 regexp_result = re.search( | |
24 '([a-zA-Z\_]*)_emperor_pcoa_plot', | |
25 directory) | |
26 metric = regexp_result.group(1) | |
27 s += '\t\t\t\t<li>' + metric + ': ' | |
28 s += '<a href="' + directory | |
29 s += '/index.html">PCoA results</a></td>\n' | |
30 s += '\t\t\t\t</li>\n' | |
31 | |
32 s += '\t\t\t</ul>\n' | |
33 s += '\t\t</p>\n' | |
34 s += '\t</body>\n' | |
35 s += '</html>\n' | |
36 | |
37 index_html_file.write(s) | |
38 | |
39 | |
40 def build_html(args): | |
41 os.mkdir(args.html_dir) | |
42 | |
43 dir_list = [name for name in os.listdir(args.data_directory) | |
44 if os.path.isdir(os.path.join( | |
45 args.data_directory, | |
46 name))] | |
47 | |
48 generate_index_html(dir_list, args) | |
49 | |
50 for directory in dir_list: | |
51 input_path = os.path.join(args.data_directory, directory) | |
52 cmd = 'cp -r ' + input_path + ' ' + args.html_dir | |
53 os.system(cmd) | |
54 | |
55 | |
56 if __name__ == '__main__': | |
57 parser = argparse.ArgumentParser() | |
58 parser.add_argument('--data_directory', required=True) | |
59 parser.add_argument('--html_file', required=True) | |
60 parser.add_argument('--html_dir', required=True) | |
61 args = parser.parse_args() | |
62 | |
63 build_html(args) |