If your database doesn’t support pivots, here is a quick technique to get pivot columns with sqlalchemy
import operator
from sqlalchemy.sql import case, func, select
def pivot_report(report, pivot_on=None, pivot_columns=None, pivot_func=func.sum,
non_pivot_columns=None, group_by=None):
“”" produce a pivot [...]
Categories: python
- Published:
- October 30, 2009 – 6:23 pm
- Author:
- By James Casbon
The reason most people end up using a dynamic language is to avoid the boilerplate associated with object creation. You know, typing “FileWriter fout = new FileWriter(”fred.txt”);” gets boring quickly. I think this is a good enough reason to move to another language on its own. This boilerplate is also sometimes called [...]
Categories: python
- Published:
- October 28, 2009 – 5:54 pm
- Author:
- By James Casbon
I recently started using cogent – the COmparative GENomics Toolkit and discovered that it is an excellent piece of kit. A google search for ‘python ensembl‘ doesn’t even show it at all, yet it definitely has the best bindings for ensembl avaiable in python – they’re based on sqlalchemy making it easy enough to [...]
Categories: bioinformatics, ensembl, python
- Published:
- October 27, 2009 – 4:57 pm
- Author:
- By James Casbon
Python seems to have developed a decent set of tools for quickly building development environments. I want to store my notes on how to get a good environment for bioinformatics set up quickly.
First of all, if you haven’t already, install virtualenv and pip. Both are easy installable. Now install virtualenv wrapper.
Now we [...]
Categories: bioinformatics, python
- Published:
- July 11, 2009 – 1:56 pm
- Author:
- By James Casbon
I needed to use MailChimp from a Django app, so I have knocked up a wrapper for their API. Come on over to the google code site for chimpy if it is useful to you.
Categories: python
- Published:
- September 21, 2008 – 5:17 pm
- Author:
- By James Casbon
If you want to use nose as your test runner while developing with TextMate, then you need the nosexml plugin. Install and then follow these instructions.
Categories: nose, python, textmate
- Published:
- September 4, 2008 – 9:54 am
- Author:
- By James Casbon
I’ve been playing with the excellent pyjamas and I thought i’d share my experiences of using pylons to create a simple json service for the pyjamas client.
Categories: python
- Published:
- December 10, 2006 – 4:57 pm
- Author:
- By James Casbon
As part of my current obsession with visualising test coverage for my huge app at work (I have a sneaky suspicion that other coders are not testing their code) I have been playing around with tree visualisation. My first port of call, graphviz, works ok for a small app but cant handle the huge [...]
Categories: python
- Published:
- July 29, 2006 – 11:27 pm
- Author:
- By James Casbon
I use eclipse with the excellent pydev for my coding. Yes, I know I should be using emacs but at work I’m forced to use windows so I like the way eclipse insulates me from the OS. Also, I could never get over the ugliness of emacs default fonts (anyone know to make it [...]
Categories: python
- Published:
- July 29, 2006 – 1:33 pm
- Author:
- By James Casbon