-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (39 loc) · 1.5 KB
/
Copy pathmain.py
File metadata and controls
52 lines (39 loc) · 1.5 KB
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
#!/usr/bin/env python
import os
import urllib
import cgi
import jinja2
import webapp2
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.autoescape'],
autoescape=True)
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello world!')
class Processor(webapp2.RequestHandler):
def post(self):
input = self.request.get('input')
output = ""
# Remove all carriage returns from the sequence
sequence = input.replace(" ", "").replace("\n", "").replace("\r", "")
######################################################################
##### PRINT OUT *SEQUENCE* THREE NUCLEOTIDES AT A TIME ###############
######################################################################
# Assuming we have a coding sequence, print out each codon
startOfCodon = 0
while (startOfCodon < len(sequence)):
codon = sequence[startOfCodon:startOfCodon+3]
output += codon + "\n"
startOfCodon = startOfCodon + 3
template_values = {
'input': input,
'output': output
}
template = JINJA_ENVIRONMENT.get_template('templates/output.html')
self.response.write(template.render(template_values))
app = webapp2.WSGIApplication([
('/api/', MainHandler),
('/api/process', Processor)
], debug=True)