[Biojava-l] Proposal for some changes in the Sequence class.

Kalle Näslund Kalle.Naslund@genpat.uu.se
Tue, 14 May 2002 10:26:30 +0200


Cox, Greg wrote:

> Hello Kalle,
>
> This would create some problems for us.  Since alignments aren't 
> sequences,
> I'd rather see a seperate class, AlignmentPanel, than overload
> SequencePanel.  Off the cuff, I'd suggest pulling the common functions 
> up to
> a new class, AbstractPanel, and have both inherit from that.  Is there a
> reason this won't work that I'm missing?
>

While alignments arent sequences, they are SymbolLists, and Sequences 
are also
SymbolLists. So by changing the SequencePanel to accept SymbolLists instead
of sequences, you can render SymbolLists, Sequences, and Alignments made 
upp
of SymbolLists or Sequences, or of course anything else that is a 
SymbolList.

And its not uncommon with Alignments made up of Sequences.For example a 
protein
sequence alignment where features represent certain motifs in the sequence.

You could make a class called AbstractPanel, and from that derive an 
AlignmentPanel
and a SequencePanel. Those classes would differ in about 3 methods ( i 
might be wrong
about the exact numbers, as i dont have access to the biojava 
sources/docs while writing
this ). The methods they differ in would be get/set Sequence that would be
get/set SymbolList in the AlignmentPanel, and then getFeatures method, 
that in the
SequencePanel would return the sequence, whereas in the AlignmentPanel 
it would
return the symbollist if it is an instance of FeatureHolder otherwise it 
would
return an FeatureHolder.EmptyFeatureHolder.
In reality this is a very small number of lines of code that differs 
between the classes.
and the result is two VERY similar classes

>
>
> I understand points 2 and 3, but I don't understand the use case driving
> point 1.  Could you recap the irc discussion for those who weren't there?
>
The irc discussions have actualy taken place over a period of time, 
where i have
got some VERY good help from Matthew Pocock and David Huen about biojava
in general, and the Sequence/gui parts in particular. Happily Matthew 
Pocock have
already answeared the question about  point 1 in a much better way then 
i possibly
could so will just redirect you to his mail ( its already posted on the 
ml ).

>
>
> Regarding point 3, I'll observe that that EmblViewer doesn't call
> getSequence() anywhere.  I'm scanning our code to see if this would 
> make our
> stuff blow up, but I'd rather not see it happen regardless.
>
if your code uses the Sequence getSequence() method, then assuming that 
you only feed
Sequences to your SequencePanels ( should be a valid assumption ) you 
can just blindly
cast all SymbolLists that getSymbolList() would return into Sequences, 
and you would be
fine.

mvh Kalle Näslund

>
> Greg
>
>> -----Original Message-----
>> From: Kalle Näslund [ mailto:Kalle.Naslund@genpat.uu.se]
>> Sent: Monday, May 13, 2002 1:27 PM
>> To: biojava-l@biojava.org
>> Subject: [Biojava-l] Proposal for some changes in the SequencePanel
>> class.
>>
>>
>> HI!
>>
>> I have a proposal for a change to the 
>> org.biojava.bio.gui.sequence.SequencePanel class. Currently the 
>> SequencePanel class only accepts  objects of type Sequence. In some 
>> situations the need to visualize SymboLists arise, for example when 
>> you want to display alignments that are in the form of Alignment 
>> objects ( that is what i want to do ).
>> I have informaly spoken to some of the people on the biojava IRC ( 
>> Internet Relay Chat ) channel and the response i got was that 
>> changing the SequencePanel class to accept SymbolLists would most 
>> likely be the prefered way to allow rendering of Alignment objects. I 
>> was also suggested that the current situation where the SequencePanel 
>> implements SequenceRenderContext should be changed, to a solution 
>> where the SequenceRenderContext is implemented by an inner class 
>> inside the SequencePanel class.
>>
>> To be a bit more precise, the changes would be the following:
>>
>> 1. Move all methods from SequenceRenderContext to an inner class
>> 2. Make SequencePanel accept SymbolLists by chaning void setSequence( 
>> Sequence s );
>> 3. Change of the method Sequence getSequence(); to return SymbolList 
>> instead, as one
>>   no longer can be sure that we are rendering a Sequence. ( i assume 
>> this can break things )
>>
>> I have a working SequencePanel class that have been changed according 
>> to the description. And the EmblViewer demo already included in 
>> Biojava works without any changes. This hopefully means that change 
>> no 3 isnt a severe change, but comments on this is very welcome.
>>
>> So, what do you think about these changes, are they acceptable, or 
>> will they break some major thing for people ?
>>
>> mvh Kalle Näslund
>>
>>
>>    
>>
>> _______________________________________________
>> Biojava-l mailing list  -  Biojava-l@biojava.org
>> http://biojava.org/mailman/listinfo/biojava-l
>>
>