]> git.donarmstrong.com Git - ape.git/blobdiff - R/read.dna.R
various fixes in C files
[ape.git] / R / read.dna.R
index 88f3d61abd7a17757dae0a8d85e80cae07f08d48..3e2b980670d872529f78eae740215d5d1582c279 100644 (file)
@@ -1,8 +1,8 @@
-## read.dna.R (2011-02-01)
+## read.dna.R (2012-04-26)
 
 ##   Read DNA Sequences in a File
 
-## Copyright 2003-2011 Emmanuel Paradis
+## Copyright 2003-2012 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -28,9 +28,9 @@ read.dna <- function(file, format = "interleaved", skip = 0,
               skip = skip, nlines = nlines, comment.char = comment.char)
     pat.base <- "[-AaCcGgTtUuMmRrWwSsYyKkVvHhDdBbNn?]{10}"
     if (phylip) {
-        ## need to remove the possible leading spaces in the first line
-        fl <- gsub("^ +", "", X[1])
-        fl <- as.numeric(unlist(strsplit(fl, " +")))
+        ## need to remove the possible leading spaces and/or tabs in the first line
+        fl <- gsub("^[[:blank:]]+", "", X[1])
+        fl <- as.numeric(unlist(strsplit(fl, "[[:blank:]]+")))
         if (length(fl) != 2 || any(is.na(fl)))
             stop("the first line of the file must contain the dimensions of the data")
         n <- fl[1]