R/aaCheck.R

Defines functions aaCheck

aaCheck <- function(seq){
  if(!any(lengths(seq) > 1)){
    seq <- toupper(seq)
    seq <- gsub(pattern = "[[:space:]]+",replacement = "",x = seq)
    seq <- strsplit(x = seq,split = "")
  } else {
    seq <- lapply(seq,toupper)
  }
  check <- unlist(lapply(seq,function(sequence){
    !all(sequence%in%c("A" ,"C" ,"D" ,"E" ,"F" ,"G" ,"H" ,"I" ,"K" ,"L" ,"M" ,"N" ,"P" ,"Q" ,"R" ,"S" ,"T" ,"V" ,"W" ,"Y", "-"))
  }))
  if(sum(check) > 0){
    sapply(which(check == TRUE),function(sequence){warning(paste0("Sequence ",sequence," has unrecognized amino acid types. Output value might be wrong calculated"),call. = FALSE)})
  }
  return(seq)
}

Try the Peptides package in your browser

Any scripts or data that you put into this service are public.

Peptides documentation built on May 31, 2023, 9:47 p.m.