dosorio / Peptides

An R package to calculate indices and theoretical physicochemical properties of peptides and protein sequences.
80 stars 21 forks source link

Issue with mz #45

Closed Arthfael closed 3 years ago

Arthfael commented 3 years ago

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.

dosorio commented 3 years ago

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

dosorio commented 3 years ago

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

Arthfael commented 3 years ago

Dear Daniel, Thanks! I will update. kind regards,

Armel

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, May 17, 2021 at 1:59 PM Daniel Osorio @.***> wrote:

Closed #45 https://github.com/dosorio/Peptides/issues/45.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dosorio/Peptides/issues/45#event-4754145127, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSHV4LGLBZGZ7J7D75RXG3TOEAKVANCNFSM444B4MOQ .