[BioCocoa-dev] Peptides...

Koen van der Drift kvddrift at earthlink.net
Sat Mar 19 16:57:56 EST 2005

On Mar 19, 2005, at 7:22 AM, Alexander Griekspoor wrote:

> Often using the framework is the best way to discover problems or come 
> up with new ideas (so I guess I better start working on the demo app 
> we plan to make), so here are a few suggestions/changes I'd like to 
> feed back in the repository but not before you have agreed to do so...
> 1) In this case I have one sequence of which I want to calculate the 
> mass of many peptides. So I wanted to cache the BCToolMassCalculator 
> and ask it for the mass of a certain range. To avoid the overhead of 
> having to create a subsequence first, instantiate a new 
> BCToolMassCalculator from it and calculate the mass, I've added a 
> simple method:
> -(NSArray *)calculateMassForRange: (NSRange)aRange;
> and changed the original calculateMass method to a convenience method:
> --(NSArray *)calculateMass{
> 	return [self calculateMassForRange: NSMakeRange(0, [[self sequence] 
> length])];
> }

Sounds good.

Some comments on the mass calculation. In mass spectrometry a molecule 
can only be detected if it has a charge. With most modern MS equipment 
the charge of peptides and proteins is obtained by addition of one or 
more protons from the solvent. Usually this is denoted as [M+H]+ or 
[M+2H]2+. Especially for peptides, the charge in general is 2+; a 
peptide of MW 2000, will therefore be observed as [2000 + 2* 
protonmass]/2 = 1001. This if referred to as the mass-over-charge ratio 
(m/z). So when a mass spectrum shows a peptide of 1001, the peptide can 
actually have an uncharged mass of 1000 or 2000. Looking at the 
spectrum will reveal if a species is 'singly-charged' or 
'doubly-charged'. So for our search program, we need to take into 
account what the charge of the peptide is that we are looking at. The 
mass of a proton is defined in BCFoundationDefines.h: H_mono and H_ave. 
This code probably needs to be added to BCMassCalculator tool - I will 
look into that and will start with just protons, but we need to keep in 
mind that there are more possibilities, eg sodium.

> As BCToolMassCalculator uses BCToolSymbolCounter (very elegant Koen!) 
> I've added the same method there as well:
> - (NSCountedSet *)countSymbols;
> - (NSCountedSet *)countSymbolsForRange: (NSRange)aRange;

Sounds good, too.

> 2) I noticed that the BCSequenceView still needs a lot of works. For 
> one, it can display line numbers (not so useful), but it wrongly 
> displays symbol numbers. Also many things are not configurable yet 
> (like the indent of the spacing). Also, none of the selection, marking 
> etc methods take the spaces into account, so for a start I added an 
> override of the setSelectedRange:  method:
> - (void)setSelectedRange:(NSRange)charRange{
> 	int start = charRange.location;
> 	int end = charRange.location + charRange.length;
> 	start += start/10;
> 	end += end/10;
> 	[super setSelectedRange: NSMakeRange(start, end-start)];
> }
> Again, the 10 here should become configurable later.. I'd like to 
> spend some time on this one further, and see what we can do... (it's 
> also required for the demo app).

As discussed a while ago, for our BCSequenceView, it might eventually 
be better to roll our own view, including a NSLayoutManager, etc. The 
code that is currently used is sufficient for displaying a simple 
sequence in an NSTextView.

- Koen.

More information about the Biococoa-dev mailing list