[Biojava-l] Creating my own classes
Richard Holland
richard.holland at ebi.ac.uk
Thu Apr 27 15:36:51 UTC 2006
On Thu, 2006-04-27 at 16:12 +0100, Nathan S. Haigh wrote:
> My application essentially defines sets of positions from an alignment - I
> call them CHARSETs as they are analogous to CHARSETs in the Nexus file
> format. I believe in Biojava the Locations object/interface (sorry, not
> familiar enough with correct terminology yet) is essentially the same sort
> of thing. In my app, the user can use several approaches to define a CHARSET
> e.g. a CHARSET containing just invariable sites, or a CHARSET containing
> sites above a given % identity.
You'd be right there. A Location in BioJava represents a range of
positions.
> My question is this, if I were to create a class called Charset, and I
> create several subclasses called e.g. Invariable etc is this reasonable? Or
> should the class Charset contain many methods for creating a different type
> of CHARSET?
My suggestion would be create an interface called Charset, which defines
behaviour which you expect all types of Charset to exhibit. Then,
implement a number of classes which implement this interface, one for
each type of Charset you have, which each add their own methods or
special behaviour. If a lot of the behaviour is common, you can define
an abstract class called something like AbstractCharset which defines
this common behaviour, and have the others extend it.
> In my app, a CHARSET needs to be associated with a particular alignment, and
> settings used to define the CHARSET, so my Charset class have variables such
> as an Alignment object, Locations objects etc. I’d like to write a method
> that returns a subalignment based on the CHARSETs associated alignment
> object and Locations object but I’m not sure how to do this.
BioJava Alignment objects implement the SymbolList interface, which
means you can use all the methods from SymbolList to work with the
Alignment, including the subList() method.
cheers,
Richard
--
Richard Holland (BioMart Team)
EMBL-EBI
Wellcome Trust Genome Campus
Hinxton
Cambridge CB10 1SD
UNITED KINGDOM
Tel: +44-(0)1223-494416
More information about the Biojava-l
mailing list