diff options
author | Hao Chen | 2019-05-17 19:10:08 -0500 |
---|---|---|
committer | Hao Chen | 2019-05-17 19:10:08 -0500 |
commit | eb51746ce69fb43450b6896e4a71e5052df51115 (patch) | |
tree | d87e36cbf05611010fa19fd78b94b120095cf25a /topGene_step3_generate_html.py | |
parent | a6376a94e137eea0e0d326d6524fe9c2177b1b34 (diff) | |
download | genecup-eb51746ce69fb43450b6896e4a71e5052df51115.tar.gz |
find top genes
Diffstat (limited to 'topGene_step3_generate_html.py')
-rwxr-xr-x | topGene_step3_generate_html.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/topGene_step3_generate_html.py b/topGene_step3_generate_html.py new file mode 100755 index 0000000..dfcd6fe --- /dev/null +++ b/topGene_step3_generate_html.py @@ -0,0 +1,50 @@ +import re + +## generate the html page for the top genes + +## put gene names and alias in a dictionary +geneNames={} +with open ("./ncbi_gene_symb_syno_name_txid9606_absCnt_sorted_absCnt_sorted.txt","r") as f: + for line in f: + (genes, count)=line.strip().split("\t") + gene=genes.split("|") + geneNames[gene[0]]=genes.strip() + +out=str() +html=str() +with open("./topGeneAbstractCount.tab" ,"r") as gc: + cnt=0 + for line in gc: + cnt+=1 + line=re.sub(r'^\s+','',line) + print (line) + pmid_cnt, symb=line.strip().split() + out+= symb+"\t"+geneNames[symb]+"\n" + html+="<li><a href=\"/showTopGene?topGene="+symb+"\">"+symb+"</a><br>\n" + if cnt==500: + break + +with open("topGene_symb_alias.txt", "w+") as tg: + tg.write(out) + tg.close() + + +htmlout=''' +{% extends "layout.html" %} +{% block content %} + +<h3> Top addiction related genes </h3> + +<br> +These genes are ranked by the number of PubMed abstracts that contain the name of the gene and one or more addiction related keyword. +<hr> + +<ol>''' + html + ''' +</ol> +{% endblock %} +''' + +with open("./templates/topAddictionGene.html", "w+") as html_f: + html_f.write(htmlout) + html_f.close() + |