Displaying 1 result from an estimated 1 matches for "gcsgcs".
Did you mean:
csgfs
2012 Apr 26
2
Memoize and vectorize a custom function
...;C","CTC")
Some sequences are missing, so they're blank `""`.
I have a function for calculating GC content:
> GC <- function(s) {
if (!is.character(s)) return(NA)
n <- nchar(s)
if (n == 0) return(NA)
m <- gregexpr('[GCSgcs]', s)[[1]]
if (m[1] < 1) return(0)
return(100.0 * length(m) / n)
}
It works:
> GC('')
[1] NA
> GC('G')
[1] 100
> GC('GAG')
[1] 66.66667
> sapply(seqs, GC)
G C CCC...