BioCocoa : Main / Tutorials

This page will contain a collection of short how-to's for BioCocoa.

Obtaining information about a sequence
To obtain some information about a sequence, BioCocoa provides a special class: BCSequenceTool. This class does nothing by itself, but has many subclasses, each for a particular task. For instance, to calculate the average molecular weight of a sequence, use the following code:
    BCToolMassCalculator *mwCalculator = [BCToolMassCalculator
             massCalculatorWithSequence: mySequence];

    [mwCalculator setMassType: BCAverage];

    NSArray *mwArray = [mwCalculator calculateMass];

    float lowerMass = [mwArray objectAtIndex: 0];
    float upperMass = [mwArray objectAtIndex: 1];

Because a sequence can have ambiguous symbols, this tool actually calculates a lower and upper MW limit, both of which are stored in the array that BCToolMassCalculator returns. In the case the sequence does not contain any ambiguous symbols, both values in the array will be the same. Note that in this case 'average' masstype means the MW is calculated using the average mass of each atom. In general, for large molecules such as proteins and DNA MW's are calculated using the average masstype. You can also calculate the MW using the monoisotopic mass, usually for smaller molecules, such as peptides. See this link for some more background on molecular mass calculations.

Manipulating a sequence
To manipulate a sequence, for instance to get a complement, you should also use a subclass of BCSequenceTool. The complement is obtained as follows:
    BCToolComplement *complementTool = [BCToolComplement 
           complementToolWithSequence: mySequence];

    BCSequence *complementSequence = [complementTool  

To obtain the reverse complement, simply use the code above with a slight modification:
    BCToolComplement *complementTool = [BCToolComplement 
           complementToolWithSequence: mySequence];

    [complementTool setReverse: YES];

    BCSequence *reverseComplementSequence = [complementTool 

If the sequence that is passed to BCToolComplement is not a DNA or RNA sequence, the tool returns a copy of the input sequence. This prevents a complement operation being carried out on for instance a protein sequence.

Changing a sequence

The current version of BioCocoa does not yet support mutable sequences.

(Printable View of