This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
135 lines (103 loc) · 4.25 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import Bio
from Bio.Blast import NCBIWWW
from Bio import SeqIO
from Bio.Blast import NCBIXML
import Bio.Blast.Record as record
from biopython_script.DbConnector import DbConnector
from flask import Flask, request, render_template, url_for, Markup
from Bio.Seq import Seq
app = Flask(__name__)
@app.route('/')
def index():
return render_template("index.html")
@app.route('/forms', methods=["GET","POST"])
def forms_to_dict():
formables = ['seq-id', 'sequence', 'evalue', 'memes']
if request.method == 'POST':
if request.form['button'] == 'submit_forms':
form_results = request.form.to_dict()
print(form_results)
return render_template('forms_to_dict_test.html', formables=formables, form_results=form_results)
elif request.method == 'GET':
return render_template('forms_to_dict_test.html',formables=formables)
@app.route('/',methods =['POST'])
def formpje():
text = request.form["text"]
text = text.upper()
text = text.replace("\n", "")
titel = ""
result_handle = NCBIWWW.qblast("blastp", "nr", text)
with open("my_blast.xml", "w") as out_handle:
out_handle.write(result_handle.read())
result_handle.close()
result_handle = open("my_blast.xml")
blast_records = NCBIXML.read(result_handle)
for alignment in blast_records.alignments:
for hsp in alignment.hsps:
titel += alignment.title + "<br>"
return titel
@app.route('/index')
def home():
return render_template('index.html')
@app.route('/about')
def about():
return render_template("about.html")
@app.route('/FAQ')
def Frequently():
return render_template('FAQ.html')
# test jinja2 variable om data over te brengen of
# 'injecteren' in het javascript in de hmtl
data = ['Pseudomonas','Streptomyces', 'Apteryx','Minicystis', 'Desulfuromonas', 'Segniliparus'
, 'Hydrogenophaga','Woeseia','Thermobifida', 'Chitinophaga','PREDICTED: Paralichthys'
,'Scytonema',
'Minicystis', 'Pusillimonas', 'Methylobacterium','Sphingopyxis', ' Gemmatimonas'
,'Coraliomargarita','PREDICTED: Salmo','Ruminiclostridium', 'Dechloromonas ',
'Rhodopirellula','Truepera ', 'Nitrosococcus', 'Gammaproteobacteria','Herbaspirillum ',
'Steroidobacter', 'Luteimonas', 'Solitalea', 'Pigmentiphaga', 'Aminobacter', 'Micromonospora ',
'Thermaerobacter', 'Parambassis', 'Stenotrophomonas', 'Salmo', 'Halocella',
'Desulfovibrio', 'Brevibacterium', 'Xanthomonas', 'Pseudoxanthomonas',
'Marinithermus', 'Ochrobactrum', 'Limnochorda', 'Nocardioides', 'Nonomuraea'
]
@app.route('/statistieken')
def stats():
return render_template('statistieken.html', data=Markup(data))
@app.route('/zelf_blasten')
def blast():
return render_template('zelf_blasten.html')
@app.route('/selectdemo', methods=["GET","POST"])
def select_results_demo():
if request.method == 'POST':
if request.form['button'] == 'select_results':
connect = DbConnector()
results = connect.select_results()
results_html_table = Markup(createHtmlTable(results))
return render_template('resultaten_demo.html', blast_results=results_html_table)
else:
return render_template('resultaten_demo.html')
else:
return render_template('resultaten_demo.html')
def createHtmlTable(rows):
ts = "<div id = 'complete_tabel'>"
ts += "<div id = 'div1'>"
ts += "<table border = '1' id = 'tabel1'>"
ts += "<tr style= 'padding-right: 15px' ><th>resultaat id</th><th>accessiecode</th><th>e value</th><th>perc. id</th><th>total coverage</th><th>Query coverage</th><th>max scores</th><th>sequentie</th><th>seq. id</th><th>eiwit id</th><th>geslachtsnaam</th></tr>"
ts += "</div>"
ts += "</table>"
ts += "<div id = 'div2'>"
ts += "<table border = '1' id = 'tabel2'>"
for row in rows:
ts += "<tr>"
for column in row:
if column == None:
value = "NULL"
else:
value = str(column)
ts += "<td>" + value + "</td>"
ts += "</tr>"
ts += "</table>"
ts += "</div>"
ts += "</div>"
return ts
if __name__ == '__main__':
print('hello')
app.run(use_reloader=True, debug = True)