[Biojava-l] SortedFeatureHolder (by location)

Kalle Näslund Kalle.Naslund@genpat.uu.se
Thu, 27 Jun 2002 19:30:23 +0200


pootle monster wrote:

> I am doing many tasks that look at features in sequential order along 
> a sequence.(over varying sizes of location)
>
> I felt sure that there would be a way to do this, but I just can not 
> find it.
>
> So I made a SortedFeatureHolder that took a Comparator in the 
> constructor (I used an implementation of Comparator for location)
>
> I now have two problems:
> 1: I cant see how to add a FeatureHolder to another FeatureHolder(eg 
> the Sequence) 

The FeatureHolder interface doesnt allow you to add objects of type 
FeatureHolder. What it does allow
you to do is to add objects of type Feature. A Feature on the other 
hand, implements the interface FeatureHolder.

Its not 100% clear to me what you are trying to do, but, from what i 
have heard so far, i would think that what you
should do, is to write your own class that implements the Sequence 
interface.

Basicly, you would start with the SimpleSequence class. it uses a 
SimpleFeatureHolder object to hold its features,
you would just change some small parts of the code so it uses your 
SortedFeatureHolder instead, and you would be
ready to go.

If you need a GappedSequence then things will be a bit messy, as it 
doesnt just delegate to a FeatureHolder, but does
the FeatureHolder stuff aswell. So lets hope you dont need 
GappedSequences =P

>
> 2: Once added I can not see how to speed up the filter method for a 
> location(which was the point of creating this class).
> But I may well be well off track and missing the obvious? 

if you want to filter the features so you only have features inside a 
certain range, then i would just use the intervall halving
method ( dunno if that makes sense in english, its a direct translation 
of the swedish name ) to locate the first and the last
feature in the range you want. And then you just return the part of the 
list, between these points. As i dont know how
this is done at current time, i dont know if this will yield any speed 
improvement.

>
>
you could try to join #biojava on irc.openprojects.net i usualy have my 
irc client parked there, and if i am available, i can
try to give you some quick help, if you get stuck. Sadly VERY FEW people 
seems to traffic the channel but if people are there, most seems very 
happy to help you out, when they have the time ( <hint> there is no 
parking fee to park your client there, and it wont do any harm so DO 
that =) </hint> )

Kalle