This page will contain a collection of short how-to's for BioCocoa.
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.
BCToolComplement *complementTool = [BCToolComplement complementToolWithSequence: mySequence]; BCSequence *complementSequence = [complementTool sequenceComplement];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 sequenceComplement];
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.
The current version of BioCocoa does not yet support mutable sequences.