diff SMART/bacteriaRegulatoryRegion_Detection/writeResToHTML.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SMART/bacteriaRegulatoryRegion_Detection/writeResToHTML.py	Tue Apr 30 14:33:21 2013 -0400
@@ -0,0 +1,124 @@
+#! /usr/bin/env python
+
+import optparse, os, shutil
+from optparse import OptionParser
+
+
+def image(text, url):
+	return "<center>%s</center><img src='%s'>" % (text, url)
+
+
+def __main__():
+	description = "Write all results in one HTML file."
+	parser = OptionParser(description = description)
+	parser.add_option("", "--input1Gff1", dest="input1Gff3_1", action="store", type="string", help="First gff3 result in the first analyse.(TRANS detection)")
+	parser.add_option("", "--input1Gff2", dest="input1Gff3_2", action="store", type="string", help="Second gff3 result in the first analyse. (TRANS detection)")
+	parser.add_option("", "--input1PNG1", dest="input1PNG1", action="store", type="string", help="PNG (getSize) result in the first analyse. (TRANS detection)")
+	parser.add_option("", "--input1PNG2", dest="input1PNG2", action="store",type="string", help="PNG (plot) result in the first analyse. (TRANS detection)")	
+	parser.add_option("", "--input2Gff1", dest="input2Gff3_1", action="store", type="string", help="First gff3 result in the second analyse. (ANTISENSE detection)")
+	parser.add_option("", "--input2Gff2", dest="input2Gff3_2", action="store", type="string", help="Second gff3 result in the second analyse. (ANTISENSE detection)")
+	parser.add_option("", "--input2PNG1", dest="input2PNG1", action="store", type="string", help="PNG (getSize) result in the second analyse. (ANTISENSE detection)")
+	parser.add_option("", "--input2PNG2", dest="input2PNG2", action="store", type="string", help="PNG (plot) result in the second analyse. (ANTISENSE detection)")
+	parser.add_option("", "--input3Gff1", dest="input3Gff3_1", action="store", type="string", help="First gff3 result in the third analyse. (CIS detection)")
+	parser.add_option("", "--input3Gff2", dest="input3Gff3_2", action="store", type="string", help="Second gff3 result in the third analyse. (CIS detection)")
+	parser.add_option("", "--input3PNG1", dest="input3PNG1", action="store", type="string", help="PNG (getSize) result in the third analyse. (CIS detection)")
+	parser.add_option("", "--input3PNG2", dest="input3PNG2", action="store", type="string", help="PNG (plot) result in the third analyse. (CIS detection)")
+	parser.add_option("", "--outHTML", dest="outHTML", action="store", type="string", help="An HTML output.")
+	parser.add_option("", "--outImgDir", dest="imgDir", action="store", type="string", help="Copy all result images into imgDir, for Galaxy option.")
+	(options, args) = parser.parse_args()
+
+
+	if not os.path.exists(options.imgDir):
+		os.makedirs(options.imgDir)
+
+	shutil.copy(options.input1PNG1, options.imgDir)
+	shutil.copy(options.input1PNG2, options.imgDir)
+	shutil.copy(options.input2PNG1, options.imgDir)
+	shutil.copy(options.input2PNG2, options.imgDir)
+	shutil.copy(options.input3PNG1, options.imgDir)
+	shutil.copy(options.input3PNG2, options.imgDir)
+	
+
+	outfile=open(options.outHTML, "w")
+	#print >>outfile, "<html><head><title>The results for ncRNAs detections.</title></head><body>"
+	print >>outfile, "<h1><center>The results for ncRNAs detections.</center></h1>"
+	
+	#write results for the first analysis
+	print >>outfile, "<B><center><font color=red size=4>The results of intergenic sRNAs detection.(TRANS)</font></center></B>"
+	print >>outfile, "<center><strong>The results of comparison to already known ncRNA to validate some candidates.</strong></center><p>"
+	input1Gff1 = open(options.input1Gff3_1, "r")
+	lines = input1Gff1.readlines()
+	input1Gff1.close()	  
+	for line in lines:
+		print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line
+	print >>outfile, "<p>"
+	print >>outfile, "<center><strong>The results of comparison to already known ncRNA to see which ncRNAs are not detected.</strong></center><p>"
+	input1Gff2 = open(options.input1Gff3_2, "r")
+	lines = input1Gff2.readlines()
+	input1Gff2.close()	  
+	for line in lines:
+		print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line
+	print >>outfile, "<p>"
+	img_input1PNG1 = os.path.basename(options.input1PNG1)
+	image1=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input1PNG1)
+	print >>outfile, "%s" % image1
+	print >>outfile, "<p>"
+	img_input1PNG2 = os.path.basename(options.input1PNG2)
+	image2=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input1PNG2)
+	print >>outfile, "%s" % image2
+	print >>outfile, "<BR><p>"
+
+
+	#write results for the second analysis
+	print >>outfile, "<B><center><font color=red size=4>The results of asRNAs detection.(ANTISENSE)</font></center></B>"
+	print >>outfile, "<center><strong>The results of comparison to already known ncRNA to validate some candidates.</strong></center><p>"
+	input2Gff1 = open(options.input2Gff3_1, "r")
+	lines = input2Gff1.readlines()
+	input2Gff1.close()	  
+	for line in lines:
+		print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line
+	print >>outfile, "<p>"
+	print >>outfile, "<center><strong>The results of comparison to already known ncRNA to see which ncRNAs are not detected.</strong></center><p>"
+	input2Gff2 = open(options.input2Gff3_2, "r")
+	lines = input2Gff2.readlines()
+	input2Gff2.close()	  
+	for line in lines:
+		print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line
+	print >>outfile, "<p>"
+	img_input2PNG1 = os.path.basename(options.input2PNG1)
+	image1=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input2PNG1)
+	print >>outfile, "%s" % image1
+	print >>outfile, "<p>"
+	img_input2PNG2 = os.path.basename(options.input2PNG2)
+	image2=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input2PNG2)
+	print >>outfile, "%s" % image2
+	print >>outfile, "<BR><p>"
+	
+	
+	#write results for the third analysis
+	print >>outfile, "<B><center><font color=red size=4>The results of long 5'UTRs detection.(CIS)</font></center></B>"
+	print >>outfile, "<center><strong>The results of comparison to already known ncRNA to validate some candidates.</strong></center><p>"
+	input3Gff1 = open(options.input3Gff3_1, "r")
+	lines = input3Gff1.readlines()
+	input3Gff1.close()	  
+	for line in lines:
+		print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line
+	print >>outfile, "<p>"
+	print >>outfile, "<center><strong>The results of comparison to already known ncRNA to see which ncRNAs are not detected.</strong></center><p>"
+	input3Gff2 = open(options.input3Gff3_2, "r")
+	lines = input3Gff2.readlines()
+	input3Gff2.close()	  
+	for line in lines:
+		print >>outfile, "<font size=2><span style=line-height:3px>%s</span></font><p>" % line
+	print >>outfile, "<p>"
+	img_input3PNG1 = os.path.basename(options.input3PNG1)
+	image1=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input3PNG1)
+	print >>outfile, "%s" % image1
+	print >>outfile, "<p>"
+	img_input3PNG2 = os.path.basename(options.input3PNG2)
+	image2=image("<strong>Resulting image : get the candidates sizes distribution.</strong>", img_input3PNG2)
+	print >>outfile, "%s" % image2
+	print >>outfile, "<BR><p>"	
+
+
+if __name__=="__main__": __main__()