[Biococoa-dev] BCSequence init methods
Charles PARNOT
charles.parnot at stanford.edu
Thu Feb 3 20:03:18 EST 2005
Hi all!
I commited last night (Pacific time...) the code with the new class
'BCAbstractSequence', the superclass, and changed the subclass header
accordingly, and all the methods names etc.. in the framework (like I
said before).
In the process of writing the implementation for the BCSequence
one-for-all placeholder class, I spent some time looking at the init
and factory methods of the whole BCAbstractSequence class tree. I had
a few questions, comments and/or suggestions:
* I believe some of the factory methods in the subclasses are
redundant; I am talking about the '+dnaSequenceWithString:' and
equivalents; normally, defining a '+sequenceWithString' in the
superclass is enough, because the type of the returned object is
defined by the class used for the call, e.g.
BCSequenceDNA *dna=[BCSequenceDna sequenceWithString:@"ATCGGGT"];
BCSequenceProtein *prot=[BCSequenceProtein
sequenceWithString:@"AOCOCOIB"];
It would make the interface cleaner and more consistent, and
reduce the amount of code by factoring it out to the superclass.
* There is this concept of 'skippingNonBases' in the BCSequenceDNA,
which could indeed be useful; but this could actually be useful for
all the subclasses, proteins as well as DNA (the rationale is to
handle pasting from output where there are numbers, spaces and other
non-relevant characters); so I thought we could maybe put the code in
the superclass and use something more generic like
'skippingUndefinedSymbols' (if you have a better shorter name, I'll
take it); again, more consistent interface and more shared code in
the superclass
* I still don't know what to do with '-initWithSequence:' if the
target and the argument are different sequence types; should we
return an empty sequence unless they are the same type?; should we
translate?; the latter might seem logical, but this innocent method
name would then be hiding quite an important feature... I propose we
drop that method (and +sequenceWithSequence), and let the user with
'copy', and then come up with a better name for a method that would
do the tranformation of one sequence type into another.
I put at the end of the email what I would propose as init and
factory methods for the different subclasses. There are not many
changes from the current status, in fact. I put some comments to
indicate which methods will really need to be implemented in the
subclass (well, the code is already done, anyway). This little
'cleaning' would be nice before we add the annotations stuff, what do
you think?
One more random thought: We probably don't need annotations in the
init methods (or at least we can live without for a while). We would
just need to set the ivar to nil at init and then alloc it at the
first '-addAnnotation:'.
Let me know what you think!
Charles
NB: I think Alex is still away, so I will wait also for his input...
// ------------------
// BCAbstractSequence
// ------------------
//designated initializer
//override in subclasses
- (id)initWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag;
//another initializer
//(that does not call the designated initializer)
//(or should this one be the designated initializer?)
//override in subclasses
- (id)initWithSymbolArray:(NSArray *)anArray;
//Call the designated initializer
//do not override in the subclasses
- (id)initWithString:(NSString *)aString;
- (id)initWithString:(NSString *)aString
range:(NSRange)aRange
skippingUnknownSymbols:(BOOL)skipFlag;
//Factory methods that call the init methods
//do not override in the subclasses
+ (BCAbstractSequence *) sequenceWithString:(NSString *)aString;
+ (BCAbstractSequence *) sequenceWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag;
+ (BCAbstractSequence *) sequenceWithString:(NSString *)aString
range:(NSRange)aRange
skippingUnknownSymbols:(BOOL)skipFlag;
+ (BCAbstractSequence *) sequenceWithSymbolArray: (NSArray *)entry;
//Call the designated initializer
//do not override in subclasses
//(these methods are a bit dangerous when using 2 different subclasses
// probably better to forget that for now
// and come up with a better name that clearly implies translation
// may have to occur for the method to make sense)
- (id)initWithSequence:(BCAbstractSequence *)entry;
+ (BCAbstractSequence
*)sequenceWithSequence:(BCAbstractSequence *)entry;
// ----------
// BCSequence
// ----------
// placeholder subclass
//methods to override
- (id)initWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag;
- (id)initWithSymbolArray:(NSArray *)anArray;
//new methods
- (id)initWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag;
usingType:(BCSequenceType) type;
+ (BCSequence *)sequenceWithString:(NSString *)string
skippingUnknownSymbols:(BOOL)skipFlag;
usingType:(BCSequenceType) type;
- (BCSequenceType)sequenceTypeForUntypedString:(NSString *)string;
//automatically inherited methods
- (id)initWithString:(NSString *)aString;
- (id)initWithString:(NSString *)aString
range:(NSRange)aRange
skippingUnknownSymbols:(BOOL)skipFlag;
+(BCAbstractSequence *)sequenceWithString:(NSString *)string;
+(BCAbstractSequence *)sequenceWithString:(NSString *)string
skippingUnknownSymbols:(BOOL)skipFlag;
+(BCAbstractSequence *)sequenceWithString:(NSString *)string
range:(NSRange)aRange
skippingUnknownSymbols:(BOOL)skipFlag;
+(BCAbstractSequence *)sequenceWithSymbolArray: (NSArray *)entry;
- (id)initWithSequence:(BCAbstractSequence *)entry;
+ (BCAbstractSequence
*)sequenceWithSequence:(BCAbstractSequence *)entry;
// ------------
// BCSequenceDNA
/ ------------
//methods to override
- (id)initWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag;
- (id)initWithSymbolArray:(NSArray *)anArray;
//automatically inherited methods
//...same as above...
// ------------
// BCSequenceRNA
// ------------
//methods to override
- (id)initWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag;
- (id)initWithSymbolArray:(NSArray *)anArray;
//new methods
- (id)initWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag
convertingThymidines:(BOOL)convertFlag;
+ (BCSequenceRNA *)rnaSequenceWithString:(NSString *)string
skippingUnknownSymbols:(BOOL)skipFlag;
convertingThymidines:(BOOL)convertFlag;
//automatically inherited methods
//...same as above...
// ---------------
// BCSequenceCodon
// ---------------
//methods to override
- (id)initWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag;
- (id)initWithSymbolArray:(NSArray *)anArray;
//new methods
- (id)initWithCodonArray:(NSArray *)anArray
geneticCode:(BCGeneticCodeName)codeType
frame:(NSString *)theFrame;
- (BCSequenceCodon *)codonSequenceWithCodonArray:(NSArray *)anArray
geneticCode:(BCGeneticCodeName)codeType
frame:(NSString *)theFrame;
//automatically inherited methods
//...same as above...
// ------------
// BCSequenceProtein
// ------------
//methods to override
- (id)initWithString:(NSString *)aString
skippingUnknownSymbols:(BOOL)skipFlag;
- (id)initWithSymbolArray:(NSArray *)anArray;
//automatically inherited methods
//...same as above...
--
Help science go fast forward:
http://cmgm.stanford.edu/~cparnot/xgrid-stanford/
Charles Parnot
charles.parnot at stanford.edu
Room B157 in Beckman Center
279, Campus Drive
Stanford University
Stanford, CA 94305 (USA)
Tel +1 650 725 7754
Fax +1 650 725 8021
More information about the Biococoa-dev
mailing list