def test_html(self, file = sys.stdout): print ("Content-Type: text/html\n") # Add the bl sub-directory to the module path # and the directory above to import the config file sys.path.insert(0, "/d/user6/az001/bl/") sys.path.insert(0, "/d/user6/az001/db/") #***************************************************************************************************************************************************************************************** # Grab the content of the form form = cgi.FieldStorage() accession = form.getvalue("accession") gene_id = form.getvalue("gene_id") product = form.getvalue("product") location = form.getvalue("location") entries = blapi.getAllEntries(accession = accession, gene_id = gene_id, product = product,location = location) # Header and navigation html = htmlutils.header() html += htmlutils.navigation() # Gene summary page table html += "<h3>Gene Summary Table:</h3>\n" html += "<div class='summary-page'>\n" html += "<table class ='summary'>\n" html += "<tr>\n" html += "<th>Genbank Accession</th>\n" html += "<th>Gene Identifier</th>\n" html += "<th>Protein Product</th>\n" html += "<th>Chromosomal Location</th>\n" html += "</tr>\n" for _ in entries: html += "<tr>\n" html += "<td><a href='http://student.cryst.bbk.ac.uk/cgi-bin/cgiwrap/az001/search.py?accession={}' method='get'>".format(_['accession'])+ _['accession']+ "</a></td>\n" html += "<td>"+_['gene_id'] + "</td>\n" html += "<td>"+_['product'] + "</td>\n" html += "<td>"+_['location'] + "</td>\n" html += "</tr>\n" html += "</table>\n" html += htmlutils.footer()
df2['Total Freq'] = df2['Codon'].map(entry['total_freq']) df['Codon'] = df['Codon'].str.strip() df2['Codon'] = df2['Codon'].str.strip() df3 = df.merge(df2, left_on='Codon', right_on='Codon') df3 = df3[['Codon', 'Freq', 'Total Freq']] # Frequency of codon usage in chosen gene vs in chromosome six html += "<h4 class= 'table-heading'>Codon usage frequencies in this gene vs in Chromosome Six </h4>\n" html += "<table class= 'codon'>\n" html += "<tr>\n" html += "<th>Codon</th>\n" html += "<th>Frequency</th>\n" html += "<th>Total Frequency</th>\n" for _ in range(0, len(df3)): html += "<tr>\n" html += "<td>" + df3['Codon'][_] + "</td>\n" html += "<td>" + df3['Freq'][_] + "</td>\n" html += "<td>" + df3['Total Freq'][_] + "</td>\n" html += "</tr>\n" html += "</table><!-- end of codon usage table -->\n" # Footer html += htmlutils.footer() print(html)
def test_html(self, file=sys.stdout): sys.path.insert(0, "/d/user6/az001/bl/") sys.path.insert(0, "/d/user6/az001/db/") #Config file saved in db folder # Grab the content of the form form = cgi.FieldStorage() #*********************************************************************************************************************************************************************************************** # MAIN PROGRAMME FOR DETAIL PAGE #*********************************************************************************************************************************************************************************************** accession = form.getvalue("accession") enzyme = form.getvalue("rez") entry = blapi.getEntry(accession, enzyme) # Header and navigation html = htmlutils.header() html += htmlutils.navigation() # detail table html += htmlutils.detailtable() html += "<td>" + entry['accession'] + "</td>\n" html += "<td>" + entry['gene_id'] + "</td>\n" html += "<td>" + entry['product'] + "</td>\n" html += "<td>" + entry['location'] + "</td>\n" html += "<td>" + entry['cds'] + "</td>\n" html += "</tr>\n" html += "</table>\n" #Text area for Amino acid sequences html += "<h4 class= 'table-heading'>Amino Acid Sequence:</h4>\n" html += "<textarea class ='amino-acid' readonly>\n" html += entry['protein_seq'] html += "</textarea>\n" #********************************************************** # DNA sequence and resitriction enzyme #********************************************************** html += "<h4 class= 'table-heading' >DNA Sequence: </h4>\n" html += "<div class = 'dna-info'> Coding region has been highlighted. <br>By choosing a Retriction Enzyme, a star will appear in the DNA sequence below. This star will indicate that the Restriction Enzyme cuts at particular site.</div>\n" html += "<form action='http://student.cryst.bbk.ac.uk/cgi-bin/cgiwrap/az001/search.py' method='get'>\n" html += "<input type='hidden' id='accession' name='accession' value='" + accession + "'>\n" #Restriction Enzyme table html += "<table class = 'reztable'>\n" html += "<tr>\n" html += "<th>Restriction enzyme</th>\n" html += "</tr>\n" html += "<tr>\n" html += "<td>" + entry['rez'] + "</td>\n" html += "</tr>\n" html += "</table>\n" #drop down for restriction enzyme html += " <select name = 'rez'>\n" html += " <option value = 'Restriction enzyme list'>Choose Restriction enzyme</option>\n" html += " <option value = 'EcoRI'>EcoRI</option>\n" html += " <option value = 'BamHI'>BamHI</option>\n" html += " <option value = 'BsuMI'>BsuMI</option>\n" html += " <option value = 'KpnI'>KpnI</option>\n" html += " <option value = 'EcoRV'>EcoRV</option>\n" html += " <option value = 'SmaI'>SmaI</option>\n" html += " <option value = 'MscI'>MscI</option>\n" html += " </select>\n" html += " <input type = 'submit' value = 'Submit'/>\n" html += " </form>\n" #DNA sequence with coding region highlighted html += "<div id = 'dna-seq'>\n" html += entry['dna_seq'] html += "</div>\n" #****************************************************** #Total codon usasge in this Gene vs in chromosome 6 #****************************************************** dictlist = [] for key, value in entry['freq'].items(): cod = key dictlist.append(cod) df = pd.DataFrame() df['Codon'] = dictlist df['Freq'] = df['Codon'].map(entry['freq']) dictlist2 = [] for key, value in entry['total_freq'].items(): cod = key dictlist2.append(cod) df2 = pd.DataFrame() df2['Codon'] = dictlist2 df2['Total Freq'] = df2['Codon'].map(entry['total_freq']) df['Codon'] = df['Codon'].str.strip() df2['Codon'] = df2['Codon'].str.strip() df3 = df.merge(df2, left_on='Codon', right_on='Codon') df3 = df3[['Codon', 'Freq', 'Total Freq']] # Frequency of codon usage in particular gene vs chromosome six html += "<h4 class= 'table-heading'>Codon usage frequencies in this gene vs in Chromosome Six </h4>\n" html += "<table class= 'codon'>\n" html += "<tr>\n" html += "<th>Codon</th>\n" html += "<th>Frequency</th>\n" html += "<th>Total Frequency</th>\n" for _ in range(0, len(df3)): html += "<tr>\n" html += "<td>" + df3['Codon'][_] + "</td>\n" html += "<td>" + df3['Freq'][_] + "</td>\n" html += "<td>" + df3['Total Freq'][_] + "</td>\n" html += "</tr>\n" html += "</table>\n" html += htmlutils.footer()