本文整理汇总了Python中Helper.Helper.printResultHtml方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.printResultHtml方法的具体用法?Python Helper.printResultHtml怎么用?Python Helper.printResultHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helper.Helper
的用法示例。
在下文中一共展示了Helper.printResultHtml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createDiagramms
# 需要导入模块: from Helper import Helper [as 别名]
# 或者: from Helper.Helper import printResultHtml [as 别名]
#.........这里部分代码省略.........
file.write("\t".join([str(keyAlu),str(counts1[keyAlu]),str(counts2[keyAlu])])+"\n")
stats.baseCountHTMLTable+="<tr><td>%s</td><td>%s</td><td>%s</td></tr>"%(keyAlu,str(counts1[keyAlu]),str(counts2[keyAlu]))
file.close()
stats.baseCountHTMLTable+="</table>"
fileName=stats.outdir+"html/"+stats.sampleName+"_baseCounts.png"
valueMatrix=[counts1.values(),counts2.values()]
Helper.createBarplot(valueMatrix, fileName, counts1.keys(), ("Alu","non-Alu"),width=0.4,title="Variants per Base", barText=False, yText="Number",)
#################################################
#### Editing per Position Plot ####
#################################################
fileName=stats.outdir+"html/"+stats.sampleName+"_EditingPositions.png"
fileNamePercentage=stats.outdir+"html/"+stats.sampleName+"_EditingPositions(Percentage).png"
counts1=Helper.countOccurrences(output+".editingSites.alu.gvf", 2, logFile, textField)
counts2=Helper.countOccurrences(output+".editingSites.nonAlu.gvf", 2, logFile, textField)
file=open(stats.outdir+"html/"+stats.sampleName+"_editingSites.txt","w")
file.write("\t".join(["Position","alu","nonAlu"])+"\n")
for key in counts1.keys():
if key in counts2.keys():
file.write("\t".join([str(key),str(counts1[key]),str(counts2[key])])+"\n")
else:
file.write("\t".join([str(key), str(counts1[key]), "--"]) + "\n")
for key in counts2.keys():
if key not in counts1.keys():
file.write("\t".join([str(key), "--", str(counts2[key])]) + "\n")
file.close()
#set values to 0 if they dont exist in the opposite file
orderList = ["3'UTR","5'UTR","coding-exon","noncoding-exon","intron","intergenic"]
aluPositions,nonAluPositions = [],[]
for key in orderList:
aluPositions.append(counts1[key]) if key in counts1.keys() else aluPositions.append(0.000000001)
nonAluPositions.append(counts2[key]) if key in counts2.keys() else nonAluPositions.append(0.00000001)
"""if key in counts1.keys():
aluPositions.append(counts1[key])
else:
aluPositions.append(0)
for key in orderList:
nonAluPositions.append(counts2[key])
"""
sumAlu,sumNonAlu = sum(aluPositions),sum(nonAluPositions)
#aluPositions=[counts1["3'UTR"],counts1["5'UTR"],counts1["coding-exon"],counts1["noncoding-exon"],counts1["intron"],counts1["intergenic"]]
#nonAluPositions=[counts2["3'UTR"],counts2["5'UTR"],counts2["coding-exon"],counts2["noncoding-exon"],counts2["intron"],counts2["intergenic"]]
barNames=["3'UTR","5'UTR","coding-exon","noncoding-exon","intron","intergenic"]
valueMatrix=[aluPositions,nonAluPositions]
Helper.createBarplot(valueMatrix, fileName, barNames, ("Alu","non-Alu"),width=0.4,title="Editing Sites per Position", barText=False, yText="Total Counts")
valueMatrixPercentage=[Helper.getPercentage(aluPositions),Helper.getPercentage(nonAluPositions)]
Helper.createBarplot(valueMatrixPercentage, fileNamePercentage, barNames, ("Alu","non-Alu"),width=0.4,title="Editing Sites per Position",yLim=100,yText="Precentage")
#make String for the HTML Table and write to a table for Ecxel
file=open(stats.outdir+"html/"+stats.sampleName+"_editingSites.txt","w")
file.write("\t".join(["Position","alu","nonAlu"])+"\n")
stats.editingPositionHTMLTable="<table><tr><th>Editing Position</th><th>Total Alu</th><th>Alu Percentage</th><th>Total Non Alu</th><th>Non Alu Percentage</th></tr>"
for key in orderList:
alu = counts1[key] if key in counts1.keys() else 0
nonAlu = counts2[key] if key in counts2.keys() else 0
aluNumber=str(counts1[key]) if key in counts1.keys() else "0"
nonAluNumber=str(counts2[key]) if key in counts2.keys() else "0"
aluPercentage= str(round(float(alu)/sumAlu,3)*100)+" %"
nonAluPercentage= str(round(float(nonAlu)/sumNonAlu,3)*100)+" %"
file.write("\t".join([str(key),aluNumber,nonAluNumber])+"\n")
stats.editingPositionHTMLTable+="<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>"%(key,aluNumber, aluPercentage,nonAluNumber, nonAluPercentage)
file.close()
stats.editingPositionHTMLTable+="</table>"
#################################################
#### Edited Genes Plot ####
#################################################
sumDict,totalGenes=parseSummaryFile(output+".editingSites.summary", logFile, textField)
stats.percentageEditing = round(float(len(sumDict))/float(totalGenes)*100.0, 2)
if "intergenic" in sumDict.keys():
del sumDict["intergenic"]
fileName=stats.outdir+"html/"+stats.sampleName+".editedGenes(3UTR).png"
stats.utr3HtmlTable = topGenesDict = topGenes(sumDict,fileName, geneNumber, 1)
fileName=stats.outdir+"html/"+stats.sampleName+".editedGenes(5UTR).png"
stats.utr5HtmlTable = topGenes(sumDict,fileName, geneNumber, 2)
fileName=stats.outdir+"html/"+stats.sampleName+".editedGenes(Exon).png"
stats.exonHtmlTable = topGenes(sumDict,fileName, geneNumber, 3)
fileName=stats.outdir+"html/"+stats.sampleName+".editedGenes(Intron).png"
stats.intronHtmlTable = topGenes(sumDict,fileName, geneNumber, 4)
if "intergenic" in sumDict.keys():
del sumDict["-"] #delete intergenics, because we only we only want to show highly edited Genes!!!
fileName=stats.outdir+"html/"+stats.sampleName+".editedGenes(Total).png"
stats.totalHtmlTable = topGenes(sumDict,fileName, geneNumber, 5)
Helper.printResultHtml(stats, logFile, textField)