Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
First version
  • Loading branch information
dritoshi committed Nov 12, 2008
1 parent 319eb01 commit 8debdcb
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README
@@ -0,0 +1,4 @@
Simple Gene Expression Database on Google App Engine.
The software can be distributed and modified under the terms of GPL.

Itoshi NIKAIDO <dritoshi at gmail dot com>
12 changes: 12 additions & 0 deletions app.yaml
@@ -0,0 +1,12 @@
application: gaexpr2
version: 1
runtime: python
api_version: 1

handlers:
- url: /load
script: myloader.py
login: admin

- url: /.*
script: gaexpr2.py
100 changes: 100 additions & 0 deletions data/expressions.table.100.txt

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions gaexpr2.py
@@ -0,0 +1,69 @@
import wsgiref.handlers

from google.appengine.ext import webapp
from google.appengine.ext import search
from google.appengine.ext.webapp.util import run_wsgi_app

class MainPage(webapp.RequestHandler):
def get(self):

url = "http://chart.apis.google.com/chart?cht=lc&chco=1E5692,3E9A3B&chs=200x125&chxt=x,y&chxl=0:|0|2|4|6|8|10|1:|2|4|6|8|10&chds=2,10&chd=t:"
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write('<html><body>')

# I use the webapp framework to retrieve the keyword
keyword = self.request.get('keyword')

if not keyword:
self.response.out.write("No keyword has been set")
else:
# Search the 'Expression' Entity based on our keyword
query = search.SearchableQuery('Expression')
query.Search(keyword)
for result in query.Run():
# Annotation
self.response.out.write('<div><pre>')
self.response.out.write('Affy ID: %s\n' % result['affy_id'])
self.response.out.write('Gene Symbol: %s\n' % result['gene_symbol'])
self.response.out.write('Gene Name: %s\n' % result['gene_name'])
self.response.out.write('Entrez Gene: <a href="http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Retrieve&dopt=full_report&list_uids=%s">' % result['entrezid'] + "%s</a>\n" % result['entrezid'])
self.response.out.write('</pre></div>')

# Graph (Using Google Chart API)
evector = ",".join([`result['evector_day' + suffix]` for suffix in ["0", "2", "4", "10"]])
ppargox = ",".join([`result['ppargox_day' + suffix]` for suffix in ["0", "2", "4", "10"]])
graph = url + evector + "|" + ppargox
self.response.out.write('<img src="%s">' % graph)

self.response.out.write('<div><a href="search">Back</a></div>')
self.response.out.write('</body></html>')

class IdSearchForm(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write("""
<html>
<body>
<h1>Gene Expression Database</h1>
<form action="/" method="get">
<div>
Keyword: <input type="text" name="keyword" rows="1" cols="12">
<input type="submit" value="Search"> (ex. 100005_at, Traf4)
</div>
</form>
<hr/>
<a href="http://itoshi.tv/">Itoshi NIKAIDO, Ph. D.</a>, dritoshi at gmail dot com
</body>
</html>""")


application = webapp.WSGIApplication(
[('/', MainPage),
('/search', IdSearchForm)],
debug=True)

def main():
run_wsgi_app(application)

if __name__ == "__main__":
main()
11 changes: 11 additions & 0 deletions index.yaml
@@ -0,0 +1,11 @@
indexes:

# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED"). If you want to manage some indexes
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.
29 changes: 29 additions & 0 deletions myloader.py
@@ -0,0 +1,29 @@
from google.appengine.api import users
from google.appengine.ext import bulkload
from google.appengine.api import datastore_types
from google.appengine.ext import search

class ExpressionLoader(bulkload.Loader):
def __init__(self):
# Our 'Expression' entity contains a affyid string and an expression float data
bulkload.Loader.__init__(self, 'Expression',
[('affy_id', str),
('gene_symbol', str),
('entrezid', str),
('gene_name', str),
('evector_day0', float),
('evector_day2', float),
('evector_day4', float),
('evector_day10', float),
('ppargox_day0', float),
('ppargox_day2', float),
('ppargox_day4', float),
('ppargox_day10', float),
])

def HandleEntity(self, entity):
ent = search.SearchableEntity(entity)
return ent

if __name__ == '__main__':
bulkload.main(ExpressionLoader())

0 comments on commit 8debdcb

Please sign in to comment.