[Biojava-dev] DNASequence not being a bean

Richard Holland holland at eaglegenomics.com
Tue May 11 15:58:37 UTC 2010


To construct a delayed-instantiation form of DNASequence you could use the Proxy pattern:

1. Create a class that subclasses DNASequence AND implements SequenceProxyLoader, has an internal instance of DNASequence itself (set to null initially), and make all the DNASequence methods just delegate to the equivalents on the internal instance.
2. Add a null constructor (DNASequence already has one that does nothing so this is OK).
3. Add required additional setter methods from SequenceProxyLoader and make them remember/track when they are called and with what values.
4. Once all the SequenceProxyLoader setters have been called use the data to instantiate and construct a DNASequence instance and set it as the internal instance.

Alternatively just have Ibatis create SequenceProxyLoader instances directly and just convert them to DNASequence in your code whenever you need to, using the DNASequence(SequenceProxyLoader) constructor.

cheers,
Richard

On 11 May 2010, at 15:45, PATERSON Trevor wrote:

> Hi
> 
> as you may be aware I am working with Andy Law at Roslin  to kick off development of a Java version of the ensembl-api.
> 
> It makes good sense for us to integrate with the new Bio-Java code, however we have a few fundamental issues with the immutability of Sequence objects.
> 
> Because the BioJava Sequence objects require initialization at construction time with the actual sequence we will have problems using Ibatis mapping to create Sequences from SQL queries, and we will not easily be able to use LazyLoad to fetch the sequence only when we need it.
> 
> Ibatis uses bean setters to set properties on beans, which must have an empty constructor 
> 
> - so  setSequence(String seqString, CompoundSet<C> compoundSet) 
> and setSequence(SequenceProxyLoader<C> proxyLoader, CompoundSet<C> compoundSet) would be very useful
> 
> alternatively we could hack round this if we could access the backing store in our own subclasses of DNASequence - i.e give the Sequence properties 'protected' rather than 'private' visibility.
> 
> 
> In essence what we are wanting to do is implement DatasourceAware subclasses of BioJava DNASequence, which we can retrieve partially filled in from Ensembl, but only retrieve and set the actual DNASequence by LazyLoad when we want the DNA Sequence. 
> 
> It may be that we can implement this lazy loading using extensions of the SequenceProxyLoader interface (I am guessing that this is what it is for) but again we'd still benefit from accessing the backing store directly.
> 
> Obviously I am not up-to-speed with the design ideas behind the DNASequence Object and maybe I am barking  up the wrong tree in trying to subclass it to my own ends, so any hints and tips would be most welcome.
> 
> cheers for now
> 
> Trevor Paterson PhD
> new email trevor.paterson at roslin.ed.ac.uk
> 
> Bioinformatics 
> The Roslin Institute
> The Royal (Dick) School of Veterinary Studies
> University of Edinburgh
> Scotland EH25 9PS
> phone +44 (0)131 5274197
> http://www.roslin.ed.ac.uk
> http://www.resspecies.org
> http://www.thearkdb.org
> 
> 
> 
> 
> -- 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
> 
> 
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-dev

--
Richard Holland, BSc MBCS
Operations and Delivery Director, Eagle Genomics Ltd
T: +44 (0)1223 654481 ext 3 | E: holland at eaglegenomics.com
http://www.eaglegenomics.com/





More information about the biojava-dev mailing list