R/cai.R

Defines functions cai

Documented in cai

cai <- function(seq, w, numcode = 1, zero.threshold = 0.0001, zero.to = 0.01){
  stops <- which("Stp" == aaa(translate(s2c(c2s(words())), numcode = numcode)))
  singulets <- which(sapply(syncodons(words(), numcode = numcode), length) == 1)
  exclude <- c(stops, singulets)
  w <- w[-exclude]
  w[w < zero.threshold] <- zero.to # if value is effectively zero make it 0.01
  nncod <- uco(seq)
  nncod <- nncod[-exclude]
  sigma <- nncod %*% log(w)
  exp(sigma/sum(nncod))
}

Try the seqinr package in your browser

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

seqinr documentation built on April 6, 2023, 1:10 a.m.