Wednesday, December 16, 2009

Drip drip drip

Drip drip drip, originally uploaded by afflictedmonkey.

Saline bag in the hospital. Not mine luckily.

By The Shipyard

By The Shipyard, originally uploaded by afflictedmonkey.

Perhaps the last pictures of the docks didn't do full justice. This is the docks/ship fit out works on West Coast park in Singapore. It's a neat place, and I was lucky to be there when the sun went down.

Sunday, September 27, 2009

Singapore's natural resources.

It's a common refrain in Singapore that the country has no natural resources.


This is not true, and has never been true. Singapore has several natural resources, but the one that occupies prime position is the docks. Singapore has one of the finest deep-water docks in the world. Often taking the busiest port in the world title.




Friday, September 18, 2009

Google is fast

45 minutes to index and report. Possibly less - that's just the first time I checked.

(See the previous entry for details)

Chinese Country Names

Chinese, of course, doesn't have an alphabet, instead it uses ideograms each one unique and represents some sort of meaning. There are several tens of thousands of characters. Although for every day speech and to be considered fluent you need to be conversant in about 3000 characters (which seems some sort of magic number, about 3000 English words gets you to fluent, 5000 you are learned and educated whereas 10,000 and you are a smart arse).

But, this poses something of a problem. In English when you need a word you just stitch together a bunch of Latin or root words or, hell, you just make it up (gruzbumble - there, a new word for you, 0 hits in google, it means "a bumble bee who's really pissed off"). But what do you do in Chinese? Well, you can actually transliterate - converting the sound, from say, English, into a set of Chinese characters. This works quite okay, although the pronunciation can be quite a bit off it's usually recognisable.

However, that new transliterated word will be made up of characters that are separate from the new word - they have their own inherent meaning.

So (and this is a round about way of getting to my point), for example, when China makes up a name for a country, what do they do? Well they transliterate the sound, but they inadvertently (and some times, uh, vertantly) leave behind a meaning in the characters, for example:

英国, pronounced 'ying guo' means literally 'hero country' = United Kingdom
美国 = meiguo = beautiful country = USA.
法国 = Fa guo = Law Country = France
泰国 = Tai Guo = Lucky Country = Thailand

But some times ironic or silly meanings can be left behind, one example:

德国 = De Guo = Moral Country = Germany
日本 = Ri ben = Sunny book = Japan
黑山 = Hei Shan = Black Mountain = Montenegro

But then sometimes, by accident really silly stuff gets left behind in the characters:

匈牙利 = Xiong ya li = Hungary = Fearsome Teeth Are sharp!
柬埔寨 = Jian Pu Jia = Cambodia = Crappy Village (Okay, this is a pun, actually)
马来西亚 = Ma Lai Xi Ya = Malaysia = Horse comes to West Asia (?!?!)
葡萄牙 = Pu Tao Ya = Portugal = Grape Teeth (?!?!!)
马里 = ma li = Mali = Horse Inside (?)
索马里 = Suo Ma li = Somalia = Search for horse Inside
多哥 = Duo Ge = Togo = Many brothers

Heh, sometimes it also goes wrong with other things. My home town (Northampton) is transliterated as Bei am dun, the 'bei' means literally 'North'. There are two major problems with this name - Northampton is not in the North, it's in the middle, (the midlands, to be exact, the home of rugby, but little else). And crucially, the 'North' in Northampton doesn't mean 'North'. It means 'Norse' as in Norse hampton = Norse town = People from Scandinavia live here in a town.

Monday, September 14, 2009

It only stops when you get to Bangkok

Railway line near Buona Vista. It's technically part of Malaysia so I suppose I was trespassing.

There's a ruined building just to the right of the picture, and occasionally trains traveling at about 20 mph go by. Embarrassingly I nearly got run over by one once! (It's the fastest way to Colbar)

Wednesday, September 9, 2009

Cat on the Path

Cat on the Path, originally uploaded by afflictedmonkey.

There's a load of cats at the condo here, they tend to hang out around the base of our block waiting for food. Each cat has its own territory. One day I should map it out and see which cat owns which part of the condo.

Our block belongs to the white cat relaxing near the path light.

Saturday, August 22, 2009

Fingers and Claws

Fingers and Claws
Originally uploaded by afflictedmonkey

Transit Hub

Transit Hub
Originally uploaded by afflictedmonkey
Playing with my camera, a few shots from flickr.

To War!

To War!
Originally uploaded by afflictedmonkey
At the Turtle museum in Chinese Garden, they all live free in the pool and go crazy when people feed them.

Saturday, August 15, 2009

On the folly of investors advice.

Teh Hooi Ling in this mornings Business Times reiterates many of the common investment advice for novice investors (like myself). I guess, this morning my mind finally snapped and I just couldn't take the mindless thoughtless advice constantly repeated as if it is mantra from these professionals. Actually, I'm being a little unfair in singling out Teh Hooi Ling, who's column I often enjoy, but to distill it to it's base, investment advice commonly boils down to this simple set of vague pointers:

1. Compound interest is miraculous, at 8-10% you will be a millionaire in your 50's!
2. Research and think in detail about the stocks you buy,
3. Sell when things are too risky!

The first one really pisses me off, but I'll come back to that one, so I'll deal with objection 1 first: I think a lot of this sort of advice is really lacking in specifics - you know really practical specifics, e.g. buy a stock when the PE goes below 10, or buy the market after 3 straight days of losses. I can understand this totally - there are no specifics to give. Every rigid investment strategy known to man has at some time found wanting (value investing, dividend yield, technical, fundamental etc.), so there are no specifics to give. Then, you base your research on a companies last quarter of results (assuming it's available, and for the Singapore Exchange it often isn't). But that is in the past, and the exchange prices the share *on future earnings*. So, what, at the end of the day is research - it all comes down to a gut feeling on whether a share is good or not.

Objection 3 is easy to dismiss - risk is obvious in hindsight. I know a lot of people who got out of the market in 2005 as it appeared too risky. It was, for sure, but in the meantime it continued to run up until 2008, only then did it crash. Risk and value are easy in hindsight. Examples from the past are meaningless. Currently as I write this I think that risk has possibly never been higher in the world, due to a variety of factors, essentially between China and the US, but perhaps in another entry.

Objection 1 is the one that always gets me though. Not because it is untrue, it is true - 100,000 units of currency invested at 8-10 % will become 1,000,000 units in about 30 years. That's maths. My objection is - where can I find and purchase these investment vehicles that pay me 8-10 % per year with little to no risk? Or, perhaps even with a lot of risk? The local banks pay a shocking 0.125% interest, whilst their 'special' 'super' 'amazing' accounts pay a whopping 0.8%! Oh. my. god. Hold the front page! The Straits Time Index (an index of approx 70% of the turnover on the singapore exchange) pays a dividend yield of around 3.7% (as of 2009, it's probably going to be lower in the near future due to reduced profitability).

I suppose you could buy preference shares, DBS will give you 6% and UOB 5%, or you could get into some of the REITs, which do start to get near the magical 8-10% (Suntec Reit pays ~7%, although it's share price is rising). And finally you could buy some of the really wierd esoteric dividend yield vehicles - like the shipping trusts, some of which pay ~12%. But you would be a fool to put your trust in such horrifyingly volatile instruments, they pay 12% or more for a reason (er... because sometimes, they don't pay anything at all).

Then there is the old chestnut that the stock exchange grows at 10% on average per year. But these measurements always seem to choose good windows for measurement. Let's look at the STI from 1987 to today. In 1987 it was ~800. Today it hovers around 2600 after a pretty robust rebound (despite Singapore still being in a recession). That's a gain of 69%. Or, 3.13% per year (actually it's less than that due to compounding, which I can't be bothered to work out). So, adding in a generous dividend yield of 3.7% (it has not always been so high) and the generous growth of 3.13%, that still only makes 6.9%. Still a couple of percents short of the magical 8-10%. Actually there is a reason it's 6.9%, and it's terribly simple - when all is said and done, the exchange can go up and down (and it sure can go up and down a hell of a lot), but it must return to its trend line - GDP growth.

Well, that's probably enough for now. I haven't talked about bonds (appalling, even risky companies can get away with ~4% and a lot of the juicy stuff is not available to the retail investor - you need ~100,000 SGD to even get started), inflation linked treasuries (miserly, inflation +2-3%) hedge funds (not always available to the retail investor, and anyway fund of hedge funds only get the same as the market over the long term).

Rant over.

Wednesday, May 27, 2009


Analysis of ChIP-seq data.

From the preamble:
This is GLbase, a set of tools to deal with heterogeneous genomic data. It's particularly useful for intersecting any data that can be expressed as a CSV file. Examples are microarray data, gene lists, Chip-seq location lists. GLbase excels at integrating these data and then outputting graphical representations of the resulting data:

You can get GLbase here:

Some screenshots of the output it can generate (via R):

Monday, May 4, 2009

Google Earth

Google Earth is Fun

2004-2009 - Singapore

2000-2004 - Norwich, UK.

Sunday, April 26, 2009

Renvy 0.1

Renvy 0.1, in its most basic form is usable. It will load and save R scripts, and you can run them. Plenty of things to do, it only deals with single tabs, no cut copy paste, no undo redo, no syntax highlighting or other nice bells and whistles.

Renvy requires rpy, python, and R. Click to run Renvy. Or type:

$ python

to run Renvy. You can get Renvy here. Or clone the mercurial repository with:

$ hg clone

Sunday, April 19, 2009


My general disappointment with the available R GUI's has finally led me to develop my own, Renvy, a simple GUI front-end to R without much of the bells and whistles. Think of Geany for coding, Renvy is to R. [Actually Geany can integrate R, it just does it poorly].

R is a statistical programming language that has gained a lot of traction amongst biologists due to the excellent Bioconductor package which allows researchers to do amazing amounts of analysis with the minimum of fuss.

You can follow the progress of Renvy here. Suffice to say it is not usable currently!

Wednesday, April 8, 2009

Economics - China and the reserve currency.

Hmm... Probably not the best entry to start with, 200 lines of Python code. It's just I'd only seen this code as fragments on the web and had never seen it pieced together and integrated into a GUI.

I commented on a blog entry here talking about China's push for a reserve currency.

I've edited it a little for clarity.

I’m not really sure the Chinese could really see this financial crisis coming. If they could then they certainly would not have parked massive reserves in the dollar nor their disastrous investment in Morgan Stanley and Blackstone.

As for the crisis not affecting China’s economy - I think it is to early to declare that. There is a large lag between import/export declines and direct effects on the economy. World-wide logistic chains take a while to unravel.

6.5% growth forecast in China next year sounds impressive, but is actually considered a catastrophe in China (re: protect 8, ie preserve 8% growth), this forecast is likely to be revised downwards as well, unlikely to go negative, but in a country of 1.2bn people with a dubious social contract with the people (don’t do anything political and we’ll provide the growth) it is a recipe for combustion. If China really does escape this crisis unscathed, then it is likely just saving up problems in their banking system for the future.

As for the new reserve currency - this is just China grandstanding to get a place at the table. The chances of it getting off the ground are zero. And commodity linked currencies would be a disaster, plus whom would guarantee the currency? The USD is the reserve currency because it is the largest economy with a massive and liquid trade in dollars. If China was serious about a new reserve currency then it should concentrate on opening up its own currency - as the third largest economy in the world it could form a bipolar reserve currency with the US. But it would not do that because the China government (rightly) fears massive currency movements overseas and is still chastened by 1997.

Friday, March 27, 2009

Integrating Cairo into wxWidgets...

Some python code to integrate Cairo into wxWidgets:

This goes into the top of your code:

# The Cairo interface.
import wx.lib.wxcairo

import ctypes
import cairo
from ctypes.util import find_library

cairo_dll = ctypes.CDLL(find_library("cairo"))

# Pycairo's API representation (from pycairo.h)
class Pycairo_CAPI(ctypes.Structure):
_fields_ = [
('Context_Type', ctypes.py_object),
('Context_FromContext', ctypes.PYFUNCTYPE(ctypes.py_object,
('FontFace_Type', ctypes.py_object),
('FontFace_FromFontFace', ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_void_p)),
('FontOptions_Type', ctypes.py_object),
('FontOptions_FromFontOptions', ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_void_p)),
('Matrix_Type', ctypes.py_object),
('Matrix_FromMatrix', ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_void_p)),
('Path_Type', ctypes.py_object),
('Path_FromPath', ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_void_p)),
('Pattern_Type', ctypes.py_object),
('SolidPattern_Type', ctypes.py_object),
('SurfacePattern_Type', ctypes.py_object),
('Gradient_Type', ctypes.py_object),
('LinearGradient_Type', ctypes.py_object),
('RadialGradient_Type', ctypes.py_object),
('Pattern_FromPattern', ctypes.c_void_p),
('ScaledFont_Type', ctypes.py_object),
('ScaledFont_FromScaledFont', ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_void_p)),
('Surface_Type', ctypes.py_object),
('ImageSurface_Type', ctypes.py_object),
('PDFSurface_Type', ctypes.py_object),
('PSSurface_Type', ctypes.py_object),
('SVGSurface_Type', ctypes.py_object),
('Win32Surface_Type', ctypes.py_object),
('XlibSurface_Type', ctypes.py_object),
('Surface_FromSurface', ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_void_p)),
('Check_Status', ctypes.PYFUNCTYPE(ctypes.c_int, ctypes.c_int))]

# look up the API
ctypes.pythonapi.PyCObject_Import.restype = ctypes.POINTER(Pycairo_CAPI)
pycairo_api = ctypes.pythonapi.PyCObject_Import("cairo", "CAPI").contents;

ContextType = pycairo_api.Context_Type

def Context_FromSWIGObject(swigObj):
get the Cairo object for drawing.
ptr = ctypes.c_void_p(int(swigObj))
#increment the native context's ref count, since the Pycairo_Context decrements it
#when it is finalised.
return pycairo_api.Context_FromContext(ptr, ContextType, None)

Then inside your drawing class you will need to add an OnPaint event:

def OnPaint(self, event):
Call to get Cairo to paint, this is done automatically if bound
to a Panel.
dc = wx.PaintDC(self.panel) # make each time OnPaint is called.
#dc = wx.AutoBufferedPaintDC(self) # not clear why this doesn't work ...
self.size = dc.GetSizeTuple()
self.setViewPortSize(self.size[0], self.size[1])
gc = wx.GraphicsContext.Create(dc)
nc = gc.GetNativeContext()
ctx = Context_FromSWIGObject(nc)
raise ErrorCairoAcquireDevice

self._paint(ctx) # actual paint calls go here.

I found it useful to bind all of this into a panel on my wxWidgets GUI. I have a panel in the GUI already, then I bind another panel on top of that panel.
My panel needs a few special options (see below), so I can't just bind it into that panel.

def bindPanel(self, panel):
bind a wx.Panel into gDraw.
self.panel = drawPanel(panel, self.OnPaint)


And this is my drawPanel class, which I used to bind the events into and exists somewhere were I need it in the GUI.

class drawPanel(wx.Panel):
An empty Panel class that sets things up suitably for Cairo.
def __init__(self, parent, paint_Procedure):
# This has to be set to full repaint to work,
# otherwise it will try to repaint only small parts.
wx.Panel.__init__(self, parent, -1, size=(-1,-1), style=wx.FULL_REPAINT_ON_RESIZE)
self.Bind(wx.EVT_PAINT, paint_Procedure, self)

Welcome to oAxiom

An occasional spot for me to write stuff I find interesting, and my faltering efforts to find funding for a biotech venture.

I sit at the interface of biology and bioinformatics - I'm in the unique position to be both a fully trained biologist (cell culture, Western blots, all that stuff). And I am also an experienced programmer (Python, C, R).

My project sits at the interface between these two people. As such this blog will contain snippets of code, snippets of biology and a dose of entrepreneurship, as wells as other miscellaneous nonsense.

Welcome to oAxiom, its only employee (if I could call myself that): Andrew Hutchins. I'm in Singapore (currently), and you can contact me at