Hi again, I updated CVS and got the new SimpleGappedSymbolList class, but there seems to be no changes to the SimpleGappedSequence class, which is the one I need to extend...have I missed something?
Ditlev -- Ditlev E. Brodersen, Ph.D. Lektor, Associate Professor Department of Molecular Biology Office: +45 89425259 University of Aarhus Lab: +45 89425022 Gustav Wieds Vej 10c Fax: +45 86123178 DK-8000 Aarhus C Email: [EMAIL PROTECTED] Denmark Lab WWW: www.bioxray.dk/~deb > -----Original Message----- > From: Richard Holland [mailto:[EMAIL PROTECTED] > Sent: 16 November 2007 11:47 > To: Ditlev Egeskov Brodersen > Cc: [EMAIL PROTECTED] > Subject: Re: Wrapping SimpleGappedSequence > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > The easiest way is simply for me to alter the constructor to > SimpleGappedSequence (and equivalently to SimpleGappedSymbolList) to > copy all gaps if passed another instance of GappedSymbolList as the > parameter. I've just done this in CVS so you should be able to update > your copy and observe the new behaviour. > > cheers, > Richard > > Ditlev Egeskov Brodersen wrote: > > Hi again, > > > > thanks for the info - will do the check just to be proper. I have > another > > question: In my application, I would like to wrap the retrieved > > SimpleGappedSequence objects inside another object that extends the > > functionality with application-specific stuff. Ideally, I would do > this by > > extending the SimpleGappedSequence object and create it by passing > the > > SimpleGappedSequence from the alignment import to the constructor of > the > > parent, like so: > > > > class AlignedSequence extends SimpleGappedSequence { > > public AlignedSequence(SimpleGappedSequence aGapped) { > > super(aGapped); > > } > > > > ..custom stuff.. > > } > > > > However, the problem is that there is only one constructor for the > > SimpleGappedSequence, one which takes a simple Sequence object. I can > pass > > the derived class alright, but all gap information is lost again, > presumably > > because the SimpleGappedSequence constructor just takes out the > seqString() > > and puts it into its own sequence object. > > > > Shouldn't the constructor of the SimpleGappedSequence class recognise > when a > > derived (and gapped) sequence object is passed, and process it > accordingly? > > > > As it stands, I am forced to include the SimpleGappedSequence as a > private > > member of the AlignedSequence class, which is not near as nice since > all > > statement using the class will have to do something like > > > > class AlignedSequence extends SimpleGappedSequence { > > private SimpleGappedSequence gapped_sequence; > > > > public AlignedSequence(SimpleGappedSequence aGapped) { > > gapped_sequence = aGapped; > > } > > > > public SimpleGappedSequence getGappedSequence() { > > return(gapped_sequence); > > } > > > > ..custom stuff.. > > } > > > > ... > > > > AlignedSequence aAligned = new AlignedSequence(aGapped); > > aAligned.getGappedSequence().seqString(); > > > > rather than simply: > > > > AlignedSequence aAligned = new AlignedSequence(aGapped); > > aAligned.seqString(); > > > > In other words, is there any solution with the current setup that > would > > allow me to extend SimpleGappedSequence and not loose the gap > information? > > > > -- Ditlev > > > > -- > > > > Ditlev E. Brodersen, Ph.D. > > Lektor, Associate Professor > > > > Department of Molecular Biology Office: +45 89425259 > > University of Aarhus Lab: +45 89425022 > > Gustav Wieds Vej 10c Fax: +45 86123178 > > DK-8000 Aarhus C Email: [EMAIL PROTECTED] > > Denmark Lab WWW: www.bioxray.dk/~deb > > > > > >> -----Original Message----- > >> From: Richard Holland [mailto:[EMAIL PROTECTED] > >> Sent: 16 November 2007 10:50 > >> To: Ditlev Egeskov Brodersen > >> Cc: [EMAIL PROTECTED] > >> Subject: Re: [Biojava-l] Parsing exising gaps > >> > >>>> The returned gapped sequences are all properly set up with gaps, > > name etc. > >>>> But as for other users, I think there may be some problems, since > the > >>>> SimpleAlignment object only has a general symbol list iterator, > the > > user > >>>> will have to cast each statement extracting a sequence object, and > >>>> > >>>> SimpleSequence aSimple = (SimpleSequence)aSequences.next(); > >>>> > >>>> returns an ClassCastException at run time. So old code might not > run > > with > >>>> the update as far as I can see. > > This is true. However, such code would be unsupported by us as the > API > > clearly states that SimpleAlignment returns SymbolList instances, and > > does not make any guarantees about the exact implementation details > of > > the objects it returns. To attempt to cast it to anything other than > > SymbolList would be a mistake! (Although actually it is now returning > a > > guarantee of GappedSymbolList, which is what your code can now take > > advantage of). To assume it will return SimpleSequence is outside the > > behaviour defined by the API and therefore should not be relied upon. > > > > A more correct behaviour would be to test each item returned: > > > > SymbolList symlist = aSequences.next(); > > if (symlist instanceof SimpleSequence) { > > SimpleSequence seq = (SimpleSequence)symlist; > > // Do simple-sequence stuff > > } else { > > // Do something else! > > } > > > > In future, I will modify the API to change the SymbolList guarantee > to > > a > > GappedSymbolList guarantee, but I can't do this right now as this > > really > > would break everyone's code! > > > > We are currently planning a redesign as you may be aware, so issues > > like > > this will hopefully be resolved as part of that process. For a start, > > if > > we use Java 5 generics in future as we plan, we can strictly specify > > what kinds of objects will be returned by things such as the > alignment > > API, making it easier for us to enforce API-compliant behaviour in > > user's code. > > > > cheers, > > Richard > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2.2 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFHPXUh4C5LeMEKA/QRAsbqAKCnpCRnIiztjZ69fE2/UaJuI9QjiACfYa0m > 8EJTzWZYOyjp9VhmvsgvmNA= > =1uaB > -----END PGP SIGNATURE----- _______________________________________________ Biojava-l mailing list - [email protected] http://lists.open-bio.org/mailman/listinfo/biojava-l
