[Biojava-l] implementing writeSequence for EMBL/Genbank

Simon Brocklehurst simon.brocklehurst@CambridgeAntibody.com
Wed, 21 Feb 2001 18:13:00 +0000


Hi Keith,

Keith James wrote:

> As EmblLikeFormat is generic how is writeSequence to know whether (and
> how) to write EMBL or SwissProt etc? The writeSequence method is not
> parameterized to accept a formatting object. If this were done at the
> constructor it would impinge on sequence reading, which does just fine
> without help from other classes. Anyway, a formatting object for a
> format object doesn't seem very elegant.

Hi Keith,

Passing in an arbritray formatting object certainly doesn't seem the right
thing to do - in principle, I think you know in advance the precise details
of the information you want to dispatch? I'm not convinced, however, that
parameterising the writeSequence method in a different way is a bad thing to
do though i.e. by a discriminator String or integer constant.

I'm sure you know it well, but in case you don't you might want to have a
look at the Factory Method design pattern.  This is well suited to your
problem - which seems to be one of essentially creating a multiple, fixed
number of types of object - EMBL, SwissProt etc.

Without thinking about it too hard, it seems to me that adding a method such
as:

void writeSequence(Sequence seq, String discriminator, java.io.PrintStream
os)

or

void writeSequence(Sequence seq, int discriminator, java.io.PrintStream os)

to the SequenceFormat interface won't break any existing code?

If I've misunderstood what you were asking, my apologies...

Simon
--
Simon M. Brocklehurst, Ph.D.
Head of Bioinformatics & Advanced IS
Cambridge Antibody Technology
The Science Park, Melbourn, Cambridgeshire, UK
http://www.CambridgeAntibody.com/
mailto:simon.brocklehurst@CambridgeAntibody.com