[Biococoa-dev] mass calculator bug

Koen van der Drift kvddrift at earthlink.net
Mon Aug 30 20:20:24 EDT 2004

On Aug 30, 2004, at 2:25 AM, Alexander Griekspoor wrote:

>> What I am trying to get at is to see if it is possible to have a 
>> separate method to test the entrySymbol and selfSymbol that goes in 
>> BCNucleotideDNA and BCAminoAcid  (or BCSequenceDNA and 
>> BCSequenceProtein). Then we can keep all the rangeOfSubsequence in 
>> BCSequence.
> Perhaps it's indeed a good plan to let BCSymbol have the 
> isRepresentedBySymbol method that BCNucleotideDNA overrides to check 
> for ambiguous bases as well, that way BCSequence could have the 
> general methods.

Here is my suggestion, but I don't know if this will work. Make the 
following method in BCSymbol:

-(BOOL) isEqualToSymbol : (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 isEqualToSymbol: 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 

There is no need for having the same code in a super and derived class.

John or Alex, if you think this will work, can you post the code that 
should be in isEqualToSymbol for BCNucleotideDNA?


- Koen.

More information about the Biococoa-dev mailing list