[Biococoa-dev] singletons

John Timmer jtimmer at bellatlantic.net
Sun Aug 22 10:47:43 EDT 2004


> What I am actually looking for is the equivalent of the code that John
> put in BCNucleotideDNA where he has a class method for each possible
> base. Before I start doing that for all + 20 amino acids, I want to be
> sure that that is the most effective way to do it. Somehow I have the
> feeling this can be much more simplified, maybe by mainiaining an array
> of singletons  (is that what BioJava calls an alphabet?).  But maybe
> not, therefore I was looking for the way BioJava does this. My
> apologies if I was not clear when I asked my question :)
> 


Well, it's very easy to avoid the proliferation of methods.  Simply have a
static NSDictionary with all the bases/aa's, and have a single accessor
method that pulls the base/aa out of the dictionary based on a name/symbol.

What I was trying to avoid by not doing that was the cost in terms of
processing time of doing the lookup in the dictionary, which will get
substantial once you start iterating over thousands of Symbols.  I'd like
this to scale well to BAC sized items (800,000 Symbols or so).  Proteins
don't often go above about 2000 aa's, so this may not be much of a worry for
you.

One thing that does bug me is the need for an "if" statement in each method
- longer term, I was thinking that it might be nice to have a single
initialization method required before using Symbols.  That way, any delay
during initialization could be accompanied by a notification to the user -
"Loading Bases and Amino Acids..."


John

_______________________________________________
This mind intentionally left blank





More information about the Biococoa-dev mailing list