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+="
  • "+symb+"
    \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 %}

    Top addiction related genes


    These genes are ranked by the number of PubMed abstracts that contain the name of the gene and one or more addiction related keyword.
      ''' + html + '''
    {% endblock %} ''' with open("./templates/topAddictionGene.html", "w+") as html_f: html_f.write(htmlout) html_f.close()