Design pattern question
Markus von Ehr
markus.vonehr at ipm.fhg.de
Wed Aug 21 03:48:27 EDT 2002
Hi Karl,
I don't understand what you wanna do exactly, but do you know the
BioPython project? Maybe there's already something inside matching
your problem.
http://biopython.org
Markus
Karl Schmid schrieb:
>
> Hi,
>
> I would like to separate an abstraction from its implementation. I think
> this is called the Bridge pattern by Gamma et al. (or at least it is a part
> of a bridge pattern).
>
> In particular, I would like to assemble a set of DNA sequences and have the
> option to chose among different assembly algorithms. I am not sure what the
> best way to do this would be:
>
> class SequenceAssembler:
>
> def __init__(self,assembler_type):
>
> if assembler_type == 'cap3':
> # What should I do here?
> elif assembler_type == 'phrap':
> # What should I do here?
>
> def save_sequences():
> pass
>
> class Cap3Assembler(SequenceAssembler):
>
> def run_assembler():
> # Cap3 specific instructions
> pass
>
> class PhrapAssembler(SequenceAssembler):
>
> def run_assembler():
> # Phrap specific instructions
> pass
>
> Now I would like to instantiate the abstract class, but to obtain an
> instance of either the Cap3Assembler or PhrapAssembler class depending on
> the assembler_type variable.
>
> >>> assembler = SequenceAssembler(assembler_type)
>
> Is this possible?
>
> Thank you in advance.
>
> -- Karl Schmid
More information about the Python-list
mailing list