Selecting a different superclass

psaffrey at googlemail.com psaffrey at googlemail.com
Wed Dec 17 09:41:24 EST 2008


This might be a pure OO question, but I'm doing it in Python so I'll
ask here.

I'm writing a number crunching bioinformatics application. Read lots
of numbers from files; merge, median and munge; draw plots. I've found
that the most critical part of this work is validation and
traceability - "where does this final value come from? How has it been
combined with other values? Is that right?"

My current implementation stores all my values just as floats with a
class called PointSet for storing one set of such values, with various
mathematical and statistical methods. There are several subclasses of
PointSet (IDPointSet, MicroArrayPointSet) for obtaining values from
different file types and with different processing pipelines.

I'm planning to instead store each value in a TraceablePoint class
which has members that describe the processing stages this value has
undergone and a TraceablePointSet class to store groups of these -
this will contain all the same methods as PointSet, but will operate
on TraceablePoints instead of floats. Of course, this will be much
slower than just floats, so I'd like to be able to switch it on and
off.

The problem is that IDPointSet and MicroArrayPointSet will need to
inherit from PointSet or TraceablePointSet based on whether I'm
handling traceable points or not. Can I select a superclass
conditionally like this in Python? Am I trying to do something really
evil here?

Any other bright ideas on my application also welcome.

Peter



More information about the Python-list mailing list