Mercurial > repos > yufei-luo > s_mart
comparison SMART/bacteriaRegulatoryRegion_Detection/writeResToHTML.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:b0e8584489e6 | 18:94ab73e8a190 |
---|---|
1 #! /usr/bin/env python | |
2 | |
3 import optparse, os, shutil | |
4 from optparse import OptionParser | |
5 | |
6 | |
7 def image(text, url): | |
8 return "<center>%s</center><img src='%s'>" % (text, url) | |
9 | |
10 | |
11 def __main__(): | |
12 description = "Write all results in one HTML file." | |
13 parser = OptionParser(description = description) | |
14 parser.add_option("", "--input1Gff1", dest="input1Gff3_1", action="store", type="string", help="First gff3 result in the first analyse.(TRANS detection)") | |
15 parser.add_option("", "--input1Gff2", dest="input1Gff3_2", action="store", type="string", help="Second gff3 result in the first analyse. (TRANS detection)") | |
16 parser.add_option("", "--input1PNG1", dest="input1PNG1", action="store", type="string", help="PNG (getSize) result in the first analyse. (TRANS detection)") | |
17 parser.add_option("", "--input1PNG2", dest="input1PNG2", action="store",type="string", help="PNG (plot) result in the first analyse. (TRANS detection)") | |
18 parser.add_option("", "--input2Gff1", dest="input2Gff3_1", action="store", type="string", help="First gff3 result in the second analyse. (ANTISENSE detection)") | |
19 parser.add_option("", "--input2Gff2", dest="input2Gff3_2", action="store", type="string", help="Second gff3 result in the second analyse. (ANTISENSE detection)") | |
20 parser.add_option("", "--input2PNG1", dest="input2PNG1", action="store", type="string", help="PNG (getSize) result in the second analyse. (ANTISENSE detection)") | |
21 parser.add_option("", "--input2PNG2", dest="input2PNG2", action="store", type="string", help="PNG (plot) result in the second analyse. (ANTISENSE detection)") | |
22 parser.add_option("", "--input3Gff1", dest="input3Gff3_1", action="store", type="string", help="First gff3 result in the third analyse. (CIS detection)") | |
23 parser.add_option("", "--input3Gff2", dest="input3Gff3_2", action="store", type="string", help="Second gff3 result in the third analyse. (CIS detection)") | |
24 parser.add_option("", "--input3PNG1", dest="input3PNG1", action="store", type="string", help="PNG (getSize) result in the third analyse. (CIS detection)") | |
25 parser.add_option("", "--input3PNG2", dest="input3PNG2", action="store", type="string", help="PNG (plot) result in the third analyse. (CIS detection)") | |
26 parser.add_option("", "--outHTML", dest="outHTML", action="store", type="string", help="An HTML output.") | |
27 parser.add_option("", "--outImgDir", dest="imgDir", action="store", type="string", help="Copy all result images into imgDir, for Galaxy option.") | |
28 (options, args) = parser.parse_args() | |
29 | |
30 | |
31 if not os.path.exists(options.imgDir): | |
32 os.makedirs(options.imgDir) | |
33 | |
34 shutil.copy(options.input1PNG1, options.imgDir) | |
35 shutil.copy(options.input1PNG2, options.imgDir) | |
36 shutil.copy(options.input2PNG1, options.imgDir) | |
37 shutil.copy(options.input2PNG2, options.imgDir) | |
38 shutil.copy(options.input3PNG1, options.imgDir) | |
39 shutil.copy(options.input3PNG2, options.imgDir) | |
40 | |
41 | |
42 outfile=open(options.outHTML, "w") | |
43 #print >>outfile, "<html><head><title>The results for ncRNAs detections.</title></head><body>" | |
44 print >>outfile, "<h1><center>The results for ncRNAs detections.</center></h1>" | |
45 | |
46 #write results for the first analysis | |
47 print >>outfile, "<B><center><font color=red size=4>The results of intergenic sRNAs detection.(TRANS)</font></center></B>" | |
48 print >>outfile, "<center><strong>The results of comparison to already known ncRNA to validate some candidates.</strong></center><p>" | |
49 input1Gff1 = open(options.input1Gff3_1, "r") | |
50 lines = input1Gff1.readlines() | |
51 input1Gff1.close() | |
52 for line in lines: | |
53 print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line | |
54 print >>outfile, "<p>" | |
55 print >>outfile, "<center><strong>The results of comparison to already known ncRNA to see which ncRNAs are not detected.</strong></center><p>" | |
56 input1Gff2 = open(options.input1Gff3_2, "r") | |
57 lines = input1Gff2.readlines() | |
58 input1Gff2.close() | |
59 for line in lines: | |
60 print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line | |
61 print >>outfile, "<p>" | |
62 img_input1PNG1 = os.path.basename(options.input1PNG1) | |
63 image1=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input1PNG1) | |
64 print >>outfile, "%s" % image1 | |
65 print >>outfile, "<p>" | |
66 img_input1PNG2 = os.path.basename(options.input1PNG2) | |
67 image2=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input1PNG2) | |
68 print >>outfile, "%s" % image2 | |
69 print >>outfile, "<BR><p>" | |
70 | |
71 | |
72 #write results for the second analysis | |
73 print >>outfile, "<B><center><font color=red size=4>The results of asRNAs detection.(ANTISENSE)</font></center></B>" | |
74 print >>outfile, "<center><strong>The results of comparison to already known ncRNA to validate some candidates.</strong></center><p>" | |
75 input2Gff1 = open(options.input2Gff3_1, "r") | |
76 lines = input2Gff1.readlines() | |
77 input2Gff1.close() | |
78 for line in lines: | |
79 print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line | |
80 print >>outfile, "<p>" | |
81 print >>outfile, "<center><strong>The results of comparison to already known ncRNA to see which ncRNAs are not detected.</strong></center><p>" | |
82 input2Gff2 = open(options.input2Gff3_2, "r") | |
83 lines = input2Gff2.readlines() | |
84 input2Gff2.close() | |
85 for line in lines: | |
86 print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line | |
87 print >>outfile, "<p>" | |
88 img_input2PNG1 = os.path.basename(options.input2PNG1) | |
89 image1=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input2PNG1) | |
90 print >>outfile, "%s" % image1 | |
91 print >>outfile, "<p>" | |
92 img_input2PNG2 = os.path.basename(options.input2PNG2) | |
93 image2=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input2PNG2) | |
94 print >>outfile, "%s" % image2 | |
95 print >>outfile, "<BR><p>" | |
96 | |
97 | |
98 #write results for the third analysis | |
99 print >>outfile, "<B><center><font color=red size=4>The results of long 5'UTRs detection.(CIS)</font></center></B>" | |
100 print >>outfile, "<center><strong>The results of comparison to already known ncRNA to validate some candidates.</strong></center><p>" | |
101 input3Gff1 = open(options.input3Gff3_1, "r") | |
102 lines = input3Gff1.readlines() | |
103 input3Gff1.close() | |
104 for line in lines: | |
105 print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line | |
106 print >>outfile, "<p>" | |
107 print >>outfile, "<center><strong>The results of comparison to already known ncRNA to see which ncRNAs are not detected.</strong></center><p>" | |
108 input3Gff2 = open(options.input3Gff3_2, "r") | |
109 lines = input3Gff2.readlines() | |
110 input3Gff2.close() | |
111 for line in lines: | |
112 print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line | |
113 print >>outfile, "<p>" | |
114 img_input3PNG1 = os.path.basename(options.input3PNG1) | |
115 image1=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input3PNG1) | |
116 print >>outfile, "%s" % image1 | |
117 print >>outfile, "<p>" | |
118 img_input3PNG2 = os.path.basename(options.input3PNG2) | |
119 image2=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input3PNG2) | |
120 print >>outfile, "%s" % image2 | |
121 print >>outfile, "<BR><p>" | |
122 | |
123 | |
124 if __name__=="__main__": __main__() |