dosorio / Peptides

An R package to calculate indices and theoretical physicochemical properties of peptides and protein sequences.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with mz

Arthfael opened this issue · comments

I tried to run the mz function today and got an error for any peptide not including "C":

> mz("AGHTTKILC")
[1] 500.7658
> mz("AGHTTKIL")
Error in table(unlist(strsplit(X, "")))[["C"]] : subscript out of bounds

Assuming I have the latest version (I did exit R and re-installed from CRAN), I would suggest the following change to the function's code:

function (seq, charge = 2, label = "none", aaShift = NULL, cysteins = 57.021464) {
    if (!is.numeric(charge) | length(charge) != 1) {
        stop("Charge must be given as an integer (typically between 1-4).")
    }
    mass <- mw(seq = seq, label = label, aaShift = aaShift, monoisotopic = TRUE)
    mass <- mass + nchar(gsub("[^C]", "", seq)) * cysteins #This is my suggested edit
    if (charge >= 0) {
        mass <- mass + charge * 1.007276
        mass <- mass/charge
    }
    return(mass)
}

I have no idea whether this is the most optimal/fastest code, or whether it makes incorrect assumptions as to the type of input sequences acceptable (I assumed upper case, one letter amino acid code as character). At least it doesn't fail because it assumes there should be at least one C, which the current version appears to do.

Thank you very much for letting us know! I will check it out and submit a new version to CRAN.

Hi @Arthfael, we solved the problem in version 2.4.3 that is already available at CRAN. Please don't hesitate to contact us if you have other problems.

Best wishes,

Daniel