[Biojava-l] SortedFeatureHolder (by location)

Keith James kdj@sanger.ac.uk
02 Jul 2002 18:01:51 +0100


>>>>> "pootle" == pootle monster <pootle_monster@hotmail.com> writes:

[...]

    pootle> I have made my own OrderedSequence Object constructed thus

Cool.

    pootle> that is all fine but I now can not see how to add features
    pootle> to it I would like to do somthing like this:

    pootle> Iterator featureIterator = sequenceLoaded.features();
    pootle> while(featureIterator.hasNext()){
    pootle> orderedSequence.add(featureIterator.next()); }

    pootle> but there is no add in the Sequence interface so I am
    pootle> going to have to use

    pootle> orderedSequence.createFeature(Feature.Template ft);

Yep. That's the intended route, so you're on track there.

    pootle> the problem with this is that I would have to create the
    pootle> Templates and there are several different types (eg
    pootle> StrandedFeature and RNAFeature) so I would have to check
    pootle> which it is then construct that type - seems nasty?

You don't have to check. See the method makeTemplate() in the Feature
interface. Call this on any Feature (which is immutable) and you will
get back a mutable Template corresponding for the Feature
implementation which it came from. You can change any of its fields if
you need to and then call createFeature(Feature.Template template) as
you describe above. This will add a new Feature to your FeatureHolder
(your OrderedSequence in this case).

Sounds like you're almost there. Let us know if you need anything
more.

Keith

-- 

-= Keith James - kdj@sanger.ac.uk - http://www.sanger.ac.uk/Users/kdj =-
Pathogen Sequencing Unit, Wellcome Trust Sanger Institute, Cambridge, UK