[adegenet-commits] r904 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jun 13 13:15:07 CEST 2011


Author: jombart
Date: 2011-06-13 13:15:06 +0200 (Mon, 13 Jun 2011)
New Revision: 904

Modified:
   pkg/R/import.R
Log:
fasta2genlight works nicely. sanity checks OK. NAs OK.


Modified: pkg/R/import.R
===================================================================
--- pkg/R/import.R	2011-06-13 10:50:39 UTC (rev 903)
+++ pkg/R/import.R	2011-06-13 11:15:06 UTC (rev 904)
@@ -1117,6 +1117,13 @@
 
     txt <- scan(file,what="character",sep="\n",quiet=TRUE, skip=lines.to.skip, nmax=LINES.PER.IND*chunkSize)
 
+    ## returns a vector of nb of second alleles or NAs
+    f1 <- function(vec){
+        out <- as.integer(vec==sec.all)
+        out[!vec %in% letterOK] <- NA
+        return(out)
+    }
+
     ## read and process chunks
     while(length(txt)>0){
         COUNT <- COUNT + 1
@@ -1132,7 +1139,8 @@
 
 
         ## convert to genlight
-        res <- c(res, lapply(txt, function(e) new("SNPbin", as.integer(e==sec.all))))
+        ##res <- c(res, lapply(txt, function(e) new("SNPbin", as.integer(e==sec.all))))
+        res <- c(res, lapply(txt, function(e) new("SNPbin", f1(e))))
 
         lines.to.skip <- lines.to.skip + nb.ind*LINES.PER.IND
         txt <- scan(file,what="character",sep="\n",quiet=TRUE, skip=lines.to.skip, nmax=LINES.PER.IND*chunkSize)



More information about the adegenet-commits mailing list