Mercurial > repos > iuc > split_libraries_fastq
comparison jackknifed_beta_diversity_output_management.py @ 0:6f55444df744 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/qiime/ commit c9bf747b23b4a9d6adc20c7740b9247c22654862
author | iuc |
---|---|
date | Thu, 18 May 2017 09:37:08 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6f55444df744 |
---|---|
1 #!/usr/bin/env python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 import argparse | |
5 import os | |
6 | |
7 | |
8 def generate_index_html(dir_list, args): | |
9 with open(args.html_file, 'w') as index_html_file: | |
10 s = '<html>\n' | |
11 s += '\t<head>\n' | |
12 s += '\t\t<title>Jackknifed beta diversity results</title>\n' | |
13 s += '\t</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\tEmperor PCoA plot after jacknifed beta diversity\n' | |
20 s += '\t\t\t<ul>\n' | |
21 | |
22 for directory in dir_list: | |
23 if directory == 'rarefaction' or directory == 'unrarefied_bdiv': | |
24 continue | |
25 | |
26 s += '\t\t\t\t<li><a href="' + directory | |
27 s += '/index.html">PCoA plots</a></td></li>\n' | |
28 | |
29 s += '\t\t\t</ul>\n' | |
30 s += '\t\t</p>\n' | |
31 s += '\t</body>\n' | |
32 s += '</html>\n' | |
33 index_html_file.write(s) | |
34 | |
35 | |
36 def build_html(args): | |
37 os.mkdir(args.html_dir) | |
38 | |
39 dir_list = [name for name in os.listdir(args.data_directory) | |
40 if os.path.isdir(os.path.join( | |
41 args.data_directory, | |
42 name))] | |
43 | |
44 generate_index_html(dir_list, args) | |
45 | |
46 os.mkdir(args.data_directory + '/pcoa') | |
47 os.mkdir(args.data_directory + '/rare_dm') | |
48 os.mkdir(args.data_directory + '/rare_upgma') | |
49 os.mkdir(args.data_directory + '/upgma_cmp') | |
50 os.mkdir(args.data_directory + '/rare_upgma_consensus') | |
51 | |
52 for directory in dir_list: | |
53 if directory == 'rarefaction' or directory == 'unrarefied_bdiv': | |
54 continue | |
55 | |
56 input_dir = os.path.join(args.data_directory, directory) | |
57 | |
58 input_path = os.path.join(input_dir, "emperor_pcoa_plots") | |
59 output_path = os.path.join(args.html_dir, directory) | |
60 cmd = 'cp -r ' + input_path + ' ' + output_path | |
61 os.system(cmd) | |
62 | |
63 input_path = os.path.join(input_dir, "pcoa/*") | |
64 output_path = os.path.join(args.data_directory, "pcoa") | |
65 cmd = 'cp -r ' + input_path + ' ' + output_path | |
66 os.system(cmd) | |
67 | |
68 input_path = os.path.join(input_dir, "rare_dm/*") | |
69 output_path = os.path.join(args.data_directory, "rare_dm") | |
70 cmd = 'cp -r ' + input_path + ' ' + output_path | |
71 os.system(cmd) | |
72 | |
73 input_path = os.path.join(input_dir, "rare_upgma/*") | |
74 output_path = os.path.join(args.data_directory, "rare_upgma") | |
75 cmd = 'cp -r ' + input_path + ' ' + output_path | |
76 os.system(cmd) | |
77 | |
78 input_path = os.path.join(input_dir, "upgma_cmp/*") | |
79 output_path = os.path.join(args.data_directory, "upgma_cmp") | |
80 cmd = 'cp -r ' + input_path + ' ' + output_path | |
81 os.system(cmd) | |
82 | |
83 input_path = os.path.join(input_dir, "rare_upgma_consensus.tre") | |
84 output_path = os.path.join( | |
85 args.data_directory, | |
86 "rare_upgma_consensus", | |
87 directory + '.tre') | |
88 cmd = 'cp ' + input_path + ' ' + output_path | |
89 os.system(cmd) | |
90 | |
91 | |
92 if __name__ == '__main__': | |
93 parser = argparse.ArgumentParser() | |
94 parser.add_argument('--data_directory', required=True) | |
95 parser.add_argument('--html_file', required=True) | |
96 parser.add_argument('--html_dir', required=True) | |
97 args = parser.parse_args() | |
98 | |
99 build_html(args) |