[Biojava-l] Am I misunderstanding?

mark.schreiber at novartis.com mark.schreiber at novartis.com
Thu Jul 27 00:58:36 UTC 2006


Hi -

You are correct that when a method says it returns a Sequence it returns 
an instance of Sequence. It can infact return any instance of Sequence so 
it is not entirely safe to cast it to SimpleSequence although in this case 
you are ok.

In previous versions of BioJava SimpleSequence was not in an impl package. 
I think the whole thing came up as a debate surrounding how modifiable 
sequences should be. As a preference we prefer people build sequences 
through one of the Tools methods you used or through a SequenceBuilder.

There are good reasons why you may want to modify a SimpleSequence and you 
should regardless of it being in an impl package if you need to. 
Retrospectively this is probably not the best design.

Also when RichSequences become available (in biojava 1.5 or now if you 
download from CVS) we have deprecated the URN for 3 reasons.

1. Its not clear what should go in there. Possibly an LSID but no-one can 
agree.
2. BioSQL doesn't store it (not directly anyway).
3. The presence of the BioEntry interface somewhat removes the need for 
it.

Hope this helps,

- Mark

Mark Schreiber
Research Investigator (Bioinformatics)

Novartis Institute for Tropical Diseases (NITD)
10 Biopolis Road
#05-01 Chromos
Singapore 138670
www.nitd.novartis.com

phone +65 6722 2973
fax  +65 6722 2910





czaleski <czaleski at albany.edu>
Sent by: biojava-l-bounces at lists.open-bio.org
07/27/2006 12:59 AM

 
        To:     biojava-l at lists.open-bio.org
        cc:     (bcc: Mark Schreiber/GP/Novartis)
        Subject:        [Biojava-l] Am I misunderstanding?



I'm worried I may be misunderstanding the intended usage of BioJava. What
made me question this was a simple example...

I followed the tutorial, and examples in the cookbook. I make a Sequence 
via
the DNATools.createDNASequence(str, str) method. This returns a Sequence
object. Sequence is an Interface, so there must be an implementation I 
don't
see... however by following the examples, it shouldn't be necessary to 
worry
about it.
According to the tutorial there are 2 global pieces of annotation that 
have
their own accessors - name and URN. The name gets set when I called
createDNASequence, but how do I set the URN? There is no method declared 
on
Sequence, or anything it inherits to be able to set the URN. This seems
weird.
So I start to dig through the source code. I find that
createDNASequence(str, str) eventually ends up returning a SimpleSequence
impl object, and sure enough, SimpleSequence implements setURN(str);

So... in my code... if I want to set the URN, I need to create
SimpleSequence objects explicitly instead of referencing them as Sequence
objects. Like this:
SimpleSequence simpSeq = (SimpleSequence)DNATools.createDNASequence(seq,
name);

This seems like an unintentional use of the package, and I only even came 
to
this possibility by having to search through the source sode.

If this is true and you are you not supposed to use the .impl classes
directly, then how would I perform the simple task of setting the URN?

Am I misunderstanding?

Thanks much.
-- 
View this message in context: http://www.nabble.com/Am-I-misunderstanding--tf2004940.html#a5507066
Sent from the BioJava forum at Nabble.com.

_______________________________________________
Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biojava-l






More information about the Biojava-l mailing list