Software review: producing two dimensional diagrams of membrane proteins

E. coli LamB, presented using TMRPres2D. Not that the cytoplasmic/extracellular labels are incorrect, and should say extracellular/periplasmic.

I recently needed to make a simple, two dimensional figure of a beta-barrel membrane protein. I went hunting for programs that might take a sequence and/or structure and produce a pretty looking diagram to save me constructing everything by hand. Here are two I found and tried.

Continue reading

Mako templates in Google App Engine: seems to work for me

For some reason which I can’t really articulate, I’m not a huge fan of Django templating. I’d actually prefer to use Genshi with Google App Engine, but I need to wait until all the kinks are ironed out, since as far as I can tell it’s not quite working painlessly yet. Another templating option is Mako, which I’ve barely used, but I still prefer to Django templates. One nice thing about Mako: it’s faster than most Python templating engines out there. So, here’s a quickie on how I got Mako working with Google App Engine. It wasn’t tricky at all, but I thought I’d document it anyway.

Checkout Mako from SVN and copy the directory mako/lib/mako to the path of your application, eg, on Linux:

$ cp -r mako/lib/mako myapp

(where myapp is the directory that your GAE app lives in).

In your app, obviously you’ll need to import some parts of mako:

from mako.template import Template
 

Then, whenever you want to render a template as output (say, at the end of a ‘get’ or ‘post’ method .. see the GAE templating example for some context), call something like:

# a dictionary of variables to send to the template namespace
foo, bar = "some", "enthralling text"
template_values = {
  ‘some_foo’: foo,
  ‘some_bar’: bar
}

# index.mako is the template file in our GAE app directory
path = os.path.join(os.path.dirname(__file__), ‘index.mako’)
# make a new template instance
templ = Template(filename=path)
# unpack the dictionary to become keyword arguments and render
self.response.out.write(templ.render(**template_values))
 

An example of some template text that could go into index.mako could be:

<html><body>${some_foo} likes the ${some_bar}<br/></body></html>

One possible modification: I need to look into it, but defining your Template class (eg templ in the example above) in the main() function (maybe as a global) rather than instantiating it every time it is rendered would probably give better performance.

ResolveRef updated : now with auto-suggest and source code

I updated ResolveRef last night and checked in the most current sourcecode to svn at Google Code.

New features include:

ResolveRef, now prettier, with comments box by disqus.

  • Suggest/autocomplete for journal title field, using the journal title lists provided by PubMed.
  • A “Verify” button. Allows a ResolveRef URL to be constructed with the web form and verified as working and valid without actually forwarding the user to the article.
  • Some bugfixes (handled the case where there is no DOI in the PubMed record, handled network timeouts to PubMed)
  • Refreshed visuals
  • Disqus comments box for feedback

In the interest of just getting something working quickly, I implemented the suggest feature in the laziest, possibly most RAM and CPU hungry way possible (the “JQuery Suggest” code queries the web app with substrings as you type each character. At the server side, the app uses a regex to scan a ~1.5 Mb list of journal titles held in RAM). I’ve already noticed a few “This request used a high amount of CPU” warnings in the logs, with the threat “High CPU requests have a small quota, and if you exceed this quota, your app will be temporarily disabled“. If my nasty hack starts heating up Google’s datacentre too much, I might have to disable the ‘suggest’ feature until I can implement it “properly”.

Continue reading

ResolveRef : looking at the logs

One of the nice features of Google App Engine is you can easily view logs for your application to quickly see requests generating errors. Browsing the logs of ResolveRef, I’ve been able to identify an few classes of query which for one reason or another, weren’t working.

Continue reading