[Biococoa-dev] Base test

Koen van der Drift kvddrift at earthlink.net
Sat Aug 14 19:35:15 EDT 2004

On Aug 14, 2004, at 5:40 PM, John Timmer wrote:

> Quick naming ideal - how about BCSequenceUnit as the root class of 
> bases and
> amino acids?   Then BCSequenceUnitDNABase, BCSequenceUnitAminoAcid, 
> etc.

Why not BCUnit, BCUnitDNABase, BCUnitAminoAcid, etc? Or even BCDNABase, 
BCAminoAcid? They can be used everywhere, not limited to a sequence 
(although they will be most of the time).

> Incidentally, I'm not going to implement the base class just yet (even 
> if we
> did know what we're calling it) - I'll get the DNA bases working first 
> and
> then figure out which methods would also apply to an amino acid and 
> move
> them up the inheritance chain.

Good luck :)

> I've also attached the preliminary .plist file I'll be using to 
> generate
> base definitions.  Let me know if I made any mistakes, and feel free 
> to add
> any other bases if you have time to kill.

I don't know much about bases, but this looks fine. You can also add 
stuff like elemental composition and other physical properties. The 
nice thing of a plist is that stuff can always be added later.

> My current thought on extensibility:
> The class will have singleton variables and methods for accessing all
> defined bases, and I'll go looking through the .plist file for them.  
> Any
> additional items will get held in a "custom base" dictionary, and will 
> be
> accessible through a "getCustomBase: (NSString *)baseName".  This will 
> allow
> for quick access for typical uses, but still provide flexibility.
> I'm diving into this now, so stop me if I'm making a stupid mistake...

Difficult to say without seeing the code. I'd say go ahead and share 
it, either on the list or the cvs website.  Make sure you make plist 
(as an NSDictionary) a shared member of all bases, so you only have to 
read it once from disk. This is what I use for amino acids in my app:

#import "IDAminoAcid.h"

static NSMutableDictionary	*aminoAcidPropertiesDict = nil;

@implementation IDAminoAcid

+ (NSDictionary *) aaPropertiesDict
	if ( aminoAcidPropertiesDict == nil )
		NSString *filePath = [[NSBundle mainBundle] pathForResource: 
@"aminoacids" ofType: @"plist"];
		aminoAcidPropertiesDict = [[NSMutableDictionary alloc] 
initWithContentsOfFile: filePath];
	return aminoAcidPropertiesDict;


The just call [self aaPropertiesDict] to access the dictionary. And 
yes, the naming difference between aaPropertiesDict and 
aminoAcidPropertiesDict is intentional :)

- Koen.

More information about the Biococoa-dev mailing list