[Biococoa-dev] BCSymbolSet done

Charles PARNOT charles.parnot at stanford.edu
Fri Mar 11 02:18:16 EST 2005

I commited an updated version of BCSymbolSet, 
which is now immutable, can return an array of 
symbols, etc and other goodies.
Here is the header below, so you don't have to 
necessarily update your project right now.

Comments and questions welcome!


NB: next on my agenda is BCAbstractSequence et 
al... Also, my full agenda is in the TODO file in 
the project, if you are curious :-)

//  BCSymbolSet.h
//  BioCocoa
//  Created by Alexander Griekspoor on Fri Sep 10 2004.
//  Copyright (c) 2004 The BioCocoa Project. All rights reserved.

#import <Foundation/Foundation.h>
#import "BCFoundationDefines.h"

@class BCSymbol;

@class      BCSymbolSet
@abstract   A collection of BCSymbols of the same type
@discussion BCSymbolSet objects provide a lot of flexibility for the user
* of the framework when creating and manipulating sequence objects.
* They can be thought of as filters, by restricting a sequence object
* to a certain set of symbols. For instance, a dna sequence could be
* created that will only accept the non-ambiguous bases A, T, G, C
* but not the compound symbols like P and Y.
* BCSymbolSet objects are immutable. The class object provides a number
* of factory methods for prebuilt symbol sets such as
* '+ (BCSymbolSet *)dnaSymbolSet' and '+ (BCSymbolSet *)dnaStrictSymbolSet'.
* It is recommanded to use these methods when creating a symbol set
* supported by the class. For other cases, a new BCSymbolSet can easily
* be created from an array of symbols, or by combining existing symbol sets.
* Because BCSymbolSet are immutable, new objects have to be created to
* modify existing symbol sets.

@interface BCSymbolSet : NSObject <NSCopying>
	NSSet	*symbolSet;
	BCSequenceType	sequenceType;

#pragma mark ’

//designated initializer
- (id)initWithArray:(NSArray *)symbols sequenceType:(BCSequenceType)type;

//decide the sequence type based on the first symbol in the passed array
- (id)initWithArray:(NSArray *)symbols;

//initializes the symbol sets using a string, by scanning the characters
//and generating symbols of the right sequence type
// e.g. A --> Adenosine if sequence type is DNA, Alanine if protein
- (id)initWithString:(NSString 

//factory methods - return an autoreleased object
+ (BCSymbolSet *)symbolSetWithArray:(NSArray *)symbols;
+ (BCSymbolSet *)symbolSetWithArray:(NSArray 
*)symbols sequenceType:(BCSequenceType)type;
+ (BCSymbolSet *)symbolSetWithString:(NSString 
*)aString sequenceType:(BCSequenceType)type;

//pre-built symbol sets
+ (BCSymbolSet *)dnaSymbolSet;
+ (BCSymbolSet *)dnaStrictSymbolSet;
+ (BCSymbolSet *)rnaSymbolSet;
+ (BCSymbolSet *)rnaStrictSymbolSet;
+ (BCSymbolSet *)proteinSymbolSet;
+ (BCSymbolSet *)proteinStrictSymbolSet;
+ (BCSymbolSet *)unknownSymbolSet;
+ (BCSymbolSet *)unknownAndGapSymbolSet;

#pragma mark ’
#pragma mark ’GENERAL METHODS

- (NSSet *)symbolSet;
- (NSArray *)allSymbols;
- (NSCharacterSet *)characterSetRepresentation;
- (BCSequenceType)sequenceType;

- (BOOL)containsSymbol:(BCSymbol *)aSymbol; 
	// aSymbol=W and contains A --> no
- (BOOL)containsSymbolRepresentedBy:(BCSymbol 
*)aSymbol; // aSymbol=W and contains A --> yes
- (BOOL)containsAllSymbolsRepresentedBy:(BCSymbol 
*)aSymbol; // aSymbol=W and contains A,T --> yes
- (BOOL)containsSymbolRepresenting:(BCSymbol 
*)aSymbol; // aSymbol=A and contains W --> yes

//creating new symbol sets from existing ones
- (BCSymbolSet *)symbolSetByFormingUnionWithSymbolSet:(BCSymbolSet *)otherSet;
- (BCSymbolSet 
/* TO DO (or not to do?)
- (BCSymbolSet *)complementSet;
- (BCSymbolSet *)expandedSet; // ambigous symbols expanded

- (BOOL)isSupersetOfSet:(BCSymbolSet *)theOtherSet;

//NSCopying formal protocol
- (id)copyWithZone:(NSZone *)zone;

//BCSymbolSet is immutable
//Keep this for a future BCMutableSymbolSet, if ever needed
#pragma mark ’

- (void)addSymbol:(BCSymbol *)symbol;
- (void)addSymbols:(NSArray *)symbols;
- (void)addSymbolsInString:(NSString *)aString;
- (void)removeSymbol:(BCSymbol *)symbol;
- (void)removeSymbols:(NSArray *)symbols;
- (void)removeSymbolsInString:(NSString *)aString;

- (void)formUnionWithSymbolSet:(BCSymbolSet *)otherSet;
- (void)formIntersectionWithSymbolSet:(BCSymbolSet *)otherSet;
- (void)makeComplementary;


Help science go fast forward:

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.bioinformatics.org/pipermail/biococoa-dev/attachments/20050310/32f5ac43/attachment.html>

More information about the Biococoa-dev mailing list