[Biojava-dev] SimpleFeature simple question

Paul.Seed@geneprot.com Paul.Seed@geneprot.com
Mon, 11 Nov 2002 11:55:50 +0100


Hi Matthew -

I haven't found anything in the docs about the template annotation being
copied to a SimpleAnnotation, so I'd agree that it looks like a bug or at
least an undocumented feature.  Keeping the copy behaviour for
EMPTY_ANNOTATION sounds like a good idea as it may help compatiblility with
existing code, although it could be argued that even this is not what you'd
expect from the docs (Annotation.EmptyAnnotation is described as "the empty
and *immutable* annotation", but a feature created with an EmptyAnnotation
template will be given a very mutable SimpleAnnotation).

Perhaps we should update the code as you suggest and document the
EmptyAnnotation->SimpleAnnotation behaviour, thus turning it into a feature
:-)

Any feedback welcome, cheers


- Paul.



                                                                                                                                                 
                    Matthew Pocock                                                                                                               
                    <matthew_pocock@yah       To:     Paul.Seed@geneprot.com, biojava-dev@biojava.org                                            
                    oo.co.uk>                 cc:                                                                                                
                    Sent by:                  Subject:     Re: [Biojava-dev] SimpleFeature simple question                                       
                    biojava-dev-admin@b                                                                                                          
                    iojava.org                                                                                                                   
                                                                                                                                                 
                                                                                                                                                 
                    08.11.2002 12:14                                                                                                             
                                                                                                                                                 
                                                                                                                                                 




Hi Paul,

This is a bug not a feature I think. I'm not sure. Do
we state anywhere in the docs that the annotation is
or is not coppied? There are cases (e.g. if you pass
in Annotation.EMPTY_ANNOTATION) where you /may/ want
to replace this with a SimpleAnnotation instance.

I would sudgest changing the line

this.annotation = new
SimpleAnnotation(template.annotation);

to:

this.annotation = (template.annotation ==
Annotation.EMPTY_ANNOTATION) ?
  new SimpleAnnotation() :
  template.annotation;

This will break code where people assume that
annotations are coppied. People, comments?

Matthew

 --- Paul.Seed@geneprot.com wrote: > Hello -
>
> I have a small question about the behaviour of
> SimpleFeature - I'm sure
> there's a good reason for it, but it's not
> immediately obvious to me why
> the constructor creates a new SimpleAnnotation based
> on the Template
> annotation:
>
>         this.loc = template.location;
>         this.type = template.type;
>         this.source = template.source;
>         this.annotation = new
> SimpleAnnotation(template.annotation);
>
> ... rather than simply using the annotation from the
> template directly:
>
>         this.annotation = template.annotation;
>
> This behaviour caught me out when I created a
> feature (using the default
> feature realizer) based on a template containing my
> own Annotation
> implementation.  When I later accessed the feature's
> annotation, I was
> surprised to find that it was a SimpleAnnotation
> rather than my own
> implementation class.  I can avoid the problem by
> using a custom
> "MySimpleFeature" that takes its Annotation directly
> from the Template, but
> I'd like to increase my knowledge of BioJava by
> understanding what this
> workaround might break!
>
> Thanks, best regards
>
>
> - Paul Seed.
>
> Bioinformatician
> GeneProt Inc. (Geneva Branch)
> Tel. +41 (0)22 719 88 36
> Fax. +41 (0)22 719 88 69
>
>
> _______________________________________________
> biojava-dev mailing list
> biojava-dev@biojava.org
> http://biojava.org/mailman/listinfo/biojava-dev

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
_______________________________________________
biojava-dev mailing list
biojava-dev@biojava.org
http://biojava.org/mailman/listinfo/biojava-dev