[Biococoa-dev] BCSymbolSet problem
Koen van der Drift
kvddrift at earthlink.net
Sat Nov 20 19:56:36 EST 2004
On Nov 16, 2004, at 8:24 PM, Koen van der Drift wrote:
> I am having some trouble getting to populate a BCSymbolSet. I am using
> the code that was originally committed by Alex, and changed it so that
> BCSymbolSet now is a subclass of NSMutableSet. To populate a set, I
> put some code into the dnaStrictSymbolSet and initwithString methods.
> I also added two lines in the translation demo. You need to uncomment
> them to debug the symbolset code. Everytime I reach the line
> addSymbol, the program raises an exception.
> I have no idea why this is happening, so if you see what I am doing
> wrong, let me know!
> There is another problem with the current approach. initWithString is
> now hardcoded to create a BCNucleotideDNA, but what if the method is
> called for RNA or a protein? Not sure yet how to solve this. We might
> need to take a different approach after all.
The following solves the second problem:
+ (BCSymbolSet *)dnaStrictSymbolSet
BCSymbolSet *symbolSet = [[BCSymbolSet alloc] init];
NSMutableArray *symbolArray = [NSMutableArray array];
[symbolArray addObject: [BCNucleotideDNA baseForSymbol: 'A']];
[symbolArray addObject: [BCNucleotideDNA baseForSymbol: 'C']];
[symbolArray addObject: [BCNucleotideDNA baseForSymbol: 'G']];
[symbolArray addObject: [BCNucleotideDNA baseForSymbol: 'T']];
[symbolSet addObjectsFromArray: symbolArray];
return [symbolSet autorelease];
But I still crash when I hit the line [symbolSet addObjectsFromArray:
From the debugger I see this:
(gdb) po symbolSet
<object raised exception generating description>
So even if I initialized the object, it causes an error. But it did do
something during the initialization:
(gdb) po [symbolSet class]
(gdb) po [symbolSet superclass]
A possible solution could be to not subclass NSMutableSet, but let
BCSymbolSet have a member NSMutableSet.
More information about the Biococoa-dev