-## DNA.R (2010-10-19)
+## DNA.R (2011-02-18)
## Manipulations and Comparisons of DNA Sequences
-## Copyright 2002-2010 Emmanuel Paradis
+## Copyright 2002-2011 Emmanuel Paradis
## This file is part of the R-package `ape'.
## See the file ../COPYING for licensing issues.
if (is.list(x)) lapply(x, f) else f(x)
}
-base.freq <- function(x, freq = FALSE)
+base.freq <- function(x, freq = FALSE, all = FALSE)
{
if (is.list(x)) x <- unlist(x)
n <- length(x)
- BF <- .C("BaseProportion", x, n, double(4), freq,
- DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")[[3]]
- names(BF) <- letters[c(1, 3, 7, 20)]
+ BF <-.C("BaseProportion", x, n, double(17),
+ DUP = FALSE, NAOK = TRUE, PACKAGE = "ape")[[3]]
+ names(BF) <- c("a", "c", "g", "t", "r", "m", "w", "s",
+ "k", "y", "v", "h", "d", "b", "n", "-", "?")
+ if (all) {
+ if (!freq) BF <- BF / n
+ } else {
+ BF <- BF[1:4]
+ if (!freq) BF <- BF / sum(BF)
+ }
BF
}