Reference no: EM132257473
- These 3 codes are to show how to perform a protein search as an AJAX call that returned and parsed )50N formatted results and display them on the browser. - Read documantation for )Query on the autocomplete function
- After that, please show how to modify these codes to add auto-complete functionality to the search box
- The source of data is the Genbank file
- do not hard-code a list of terms in a )avascript array
- limit the number of rows returned to S so that the large lists are not returned.
1- test.cgi
#!/usr/local/bin/python3
import cgi,json
import os
import mysql.connector
def main()
print("Content-Type:text/html\n\ni print("It worked\n")
if__name--emain__':
main()
2- search.cgi
#!/usr/local/bin/python3
import cgi, json
import os
import mysql.connecting
def main():
print ("Content-Type: application/json\n\n")
form -cgi.FieldStorage()
term -form.getvalue('search_term')
conn - mysql.connector.connect(user - 'any', password-'anything' , host-'host', database -sbiotese) cursor - conn.cursor()
SELECT locus_id, product
FROM genes
WHERE product LIKE %s
cursor.excute(qry, ('%' + term + '%',))
results = {'match_count1:0, 'matches' : list()}
for (locus_id, product) in cursor:
resultsrmatchesl.append({'locus_idl:locus_id, 'product': product}) resultsrmatch_count1+-1
conn.close()
print(json.dumps(results)) if name fls' __main __ . '.
__ __
main()
3- search.html
<!DOCTYPE html>
<html lang =leen"). <head>
<meta charset="utf-8"/>
<title>A3AX demo</title>
<!--[if IE]>
<script src-"https://xxxxxx/xxxx/html5.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="css/search_product.css"/>
<script type-"text/javascript" src-"https://ajax.googleapis.com/ajax/jquery/xxxxxx"></script> <script type="text/javascript" src="js/search.js"></script>
</head>
<body id="main">
<h1>E.coli search </hl>
<form name-"search" id-"search" action-"">
<input name="search_term" type="search value="" autofocus="autofocus" placeholder="Enter a search term"/> </form>
<section id=eresults1>
<p>
<span id='match_countl>0</span> match (es) found.
</p>
<table>
<thead> <tr>
<td>Locus tag</td>
<td>Product</td>
</tr>
</thead> <tbody>
<!--this will be filled in by javascript when there are results -->
</tbody> </section>
</body>
</html>
Attachment:- Programming.rar