[Biojava-l] Constructing features

Dr S.M. Huen smh1008@cus.cam.ac.uk
Tue, 29 May 2001 09:30:48 +0100 (BST)


I have been trying to figure out how to construct a hierarchical tree of
Features.  This is a consequence of trying to write a SeqIOListener
that takes a stream of events generated from an XML parse and
constructs an in-memory sequence with nested Features on it. Can you tell
me whether I understand this correctly?

A feature can only be added by calling createFeature with a
Feature.Template on a class that has a FeatureHolder.  Once done, you
cannot add to the annonation bundle.  If this is the case, then when I
receive startFeature events from the XML parser, I need to defer creation
of the feature until the corresponding endFeature event as I may receive
an addFeatureProperty I might want to add to the annotation field in the
interim.

If I cannot create the root feature, I cannot add child features to it
until it comes into existence so creation of those features need to be
deferred too. When I finally create the root Feature with createFeature
and add it to whatever parent Sequence/other parent Feature, do I then
have to call features() on the parent (there may be multiple features on
that FeatureHolder by then) and then go thru' the list there to
find the Feature I've just created before I can add further child features
to it?

Does all this apply to ComponentFeatures too?

Is this the right way of doing it or have I got the wrong end of the stick
here?

Thanks,
David