lgatto/synapter — pull request #47 by sgibb (2014-02-25 16:20:19+00:00)
Title: Use Biostrings::readAAStringSet and cleaver::cleave instead of readFasta and digest

Dear Laurent,

this PR is a little bit complicated because the results of `dbUniquePeptideSet` will vary slightly.
Please be careful!

This PR replaces `readFasta` by `Biostrings::readAAStringSet` and `digest` by `cleaver::cleave`. That's why it also introduces two new dependencies to `synapter` namely `Biostrings` and `cleaver`.

The results of `dbUniquePeptideSet` will vary because the output of `digest` and `cleave` is different. Here are a few examples:
```s
library("synapter")
library("cleaver")

# subsets/substrings of:
# sp|B1XDP2|AAS_ECODH Bifunctional protein aas OS=Escherichia coli (strain K12 / DH10B) GN=aas PE=3 SV=1
# sp|B1XFV2|ANMK_ECODH Anhydro-N-acetylmuramic acid kinase OS=Escherichia coli (strain K12 / DH10B) GN=anmK PE=3 SV=1
p <- c(B1XDP2="IGLMLPNAGISAAVIFGAIARRRMPAMMNYTAGVK",
B1XFV2="QAGKPYDKDAEWAR")

cleave(p)
#$B1XDP2
#[1] "IGLMLPNAGISAAVIFGAIAR" "RR" "MPAMMNYTAGVK"
#
#$B1XFV2
#[1] "QAGKPYDKDAEWAR"

synapter:::digest(p[1])
# [1] "IGLMLPNAGISAAVIFGAIAR" "R" "R" "MPAMMNYTAGVK"
synapter:::digest(p[2])
# [1] "QAGKPYDK" "DAEWAR"
```
According to http://web.expasy.org/peptide_cutter/peptidecutter_enzymes.html#exceptions there should be no cleavage (split) at *RRR* and no one at *DKD*.

To give you an idea about the amount of changes please see the following example:
```s
library("cleaver")
library("synapterdata")

fastafile <- getFasta()
s <- sapply(synapter:::readFasta(fastafile), "[[", 2)

length(cl) # 83520
length(sy) # 83523

sum(cl %in% sy) # 82996
sum(sy %in% cl) # 82996
```
There are around 600 different cleavage results.

I do not know `synapter` good enough to appreciate the influence of this change to the subsequent analysis.

Best wishes,

Sebastian

BTW: I know this code is not time critical but it is also 5-6 times faster :wink:
```s
system.time(dbUniquePeptideSet(fastafile))
#Fasta file: 4041 proteins
# 79548 out of 83520 tryptic peptides are proteotypic.
# user system elapsed
# 0.468 0.012 0.490
system.time(synapter:::dbUniquePeptideSet(fastafile))
#Fasta file: 4041 proteins
# 79542 out of 83523 tryptic peptides are proteotypic.
# user system elapsed
# 2.928 0.000 2.901
```