[Biococoa-dev] rangeOfSubsequence fix
Alexander Griekspoor
mek at mekentosj.com
Thu Sep 2 01:59:07 EDT 2004
Hi Koen,
Indeed very busy ;-) But I think in this it's really between John and
you what to decide. Things are to specific for me, being not really
into the code, to say much. It sounds all very logical and it would be
nice if we could dramatically simply the code... I would say go ahead,
but John will have his words as well I guess...
Cheers,
Alex
> Here is my suggestion, but I don't know if this will work. Make the
> following method in BCSymbol:
>
>
> -(BOOL) isRepresentedBySymbol : (BCSymbol *)aSymbol
> {
> return (self == aSymbol);
> }
>
>
> Then override this for BCNucleotideDNA to do all the ambiguity
> testing. Now the method - (NSRange) rangeOfSubsequence: (BCSequence
> *)entry withinRange: (NSRange)theLimit can be much simplified and only
> needs to be in BCSequence:
>
> - (NSRange) rangeOfSubsequence: (BCSequence *)entry withinRange:
> (NSRange)theLimit {
> // do bounds checking
> if ( theLimit.location + theLimit.length >= [sequenceArray count] )
> return NSMakeRange( NSNotFound, 0);
>
> // get the region to check
> NSArray *subSequence = [sequenceArray subarrayWithRange: theLimit];
>
> int loopCounter;
> BCSymbol *entrySymbol, *selfSymbol;
> BOOL haveMatch = NO;
>
> for ( loopCounter = 0 ; loopCounter < [subSequence count] - [entry
> length] ; loopCounter++ ) {
> selfSymbol = [subSequence objectAtIndex: loopCounter];
> entrySymbol = [entry symbolAtIndex: 0];
>
> haveMatch = [selfSymbol isRepresentedBySymbol: entrySymbol];
>
> if ( haveMatch )
> return NSMakeRange( loopCounter, [entry length] );
>
> }
>
> }
> // went through the whole sequence without finding anything
> return NSMakeRange( NSNotFound, 0);
> }
>
> The same can be done for - (NSArray *) rangesOfSubsequence:
> (BCSequence *)entry
>
> There is no need for having the same code in a super and derived
> class, so it should all be removed from BCSequenceDNA.
>
> However, just copy-paste the following to BCNucleotideDNA won't work,
> because 'entry' and 'subSequence' are part of the
> rangesOfSubsequence method.
>
>
> if ( [selfBase isRepresentedByBase: entryBase] || [entryBase
> isRepresentedByBase: selfBase] ) {
> haveMatch = YES;
> innerCounter = 1;
> // go through and compare each base
> while ( innerCounter < [entry length] ) {
> selfBase = [subSequence objectAtIndex: loopCounter +
> innerCounter];
> entryBase = [entry symbolAtIndex: innerCounter];
>
> if ( ![selfBase isRepresentedByBase: entryBase] &&
> ![entryBase isRepresentedByBase: selfBase] ) {
> // exit without a match if we fail that comparison
> innerCounter = [entry length];
> haveMatch = NO;
> }
> innerCounter ++;
> }
>
>
> I don't want to break the algorithm, so if anyone has a suggestion how
> to approach this, could you commit it or post it here?
>
>
> thanks,
>
>
> - Koen.
>
> _______________________________________________
> Biococoa-dev mailing list
> Biococoa-dev at bioinformatics.org
> https://bioinformatics.org/mailman/listinfo/biococoa-dev
>
>
*********************************************************
** Alexander Griekspoor **
*********************************************************
The Netherlands Cancer Institute
Department of Tumorbiology (H4)
Plesmanlaan 121, 1066 CX, Amsterdam
Tel: + 31 20 - 512 2023
Fax: + 31 20 - 512 2029
AIM: mekentosj at mac.com
E-mail: a.griekspoor at nki.nl
Web: http://www.mekentosj.com
Mac vs Windows
65 million years ago, there were more
dinosaurs than humans.
Where are the dinosaurs now?
*********************************************************
**************************************************************
** Alexander Griekspoor **
**************************************************************
The Netherlands Cancer Institute
Department of Tumorbiology (H4)
Plesmanlaan 121, 1066 CX, Amsterdam
Tel: + 31 20 - 512 2023
Fax: + 31 20 - 512 2029
AIM: mekentosj at mac.com
E-mail: a.griekspoor at nki.nl
Web: http://www.mekentosj.com
MacOS X: The power of UNIX with the simplicity of the Mac
***************************************************************
More information about the Biococoa-dev
mailing list