lgatto/synapter — pull request #49 by sgibb (2014-02-28 23:51:19+00:00)
Title: Modification of findMSeEMRTs to speed up searchGrid

Dear Laurent,

today in the afternoon I wanted to experiment with the Mobility as third dimension for the peak matching process. I was a little bit disappointed because of the slow `searchGrid` that makes testing really boring.
That's why I tried to modify the code of the workhorse function `findMSeEMRT` to reduce the running time.

This pull request introduces two main modifications:

1. `findMSeEMRTs` calculates the mass error only for the RT window that matches the boundaries generated by the RT model (0153ec2). That is roughly 3x times faster.
2. The `for` loop that fills the `pep3d2` matrix is replaced by a vectorized fill up (1f4b420). That is roughly 20x times faster.

All in all `findMSeEMRTs` is now ca. 40-70x faster!

(on my laptop `searchGrid` is even more faster)

## master branch
library("synapter")
load("s.RData")
system.time(searchGrid(s))
# user system elapsed
# 6038.128 51.471 6145.132

## findMSeEMRTs branch
library("synapter")
load("s.RData")
system.time(searchGrid(s))
# user system elapsed
# 15.357 0.200 15.785

Please find a minimal working example at: https://gist.github.com/sgibb/9281811

`findMSeEMRTs` could still improved, e.g. the calculation of `hdmseData <- doHDMSePredictions(identpep, model, nsd)` and `idxs` is the same for all `ppms` and `nsds[i]`. That's why we should remove it from `findMSeEMRTs` and calculate it only once for all `ppms` in the outer `for` loop of `gridSearch2`. `findMSeEMRTs` could get these values as an argument. (I have not done these change because `findMSeEMRTs` is called in `findEMRTs`. I did not want to change the internal API without asking you about it (BTW the effect would be small)).

Best wishes,

Sebastian