[Seqinr-commits] r2049 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 4 12:25:33 CEST 2017


Author: jeanlobry
Date: 2017-07-04 12:25:33 +0200 (Tue, 04 Jul 2017)
New Revision: 2049

Modified:
   pkg/R/read.alignment.R
Log:
read.alignment can now handle legacy fasta format

Modified: pkg/R/read.alignment.R
===================================================================
--- pkg/R/read.alignment.R	2017-07-03 17:38:49 UTC (rev 2048)
+++ pkg/R/read.alignment.R	2017-07-04 10:25:33 UTC (rev 2049)
@@ -9,18 +9,17 @@
   file <- path.expand(file) 
   if(file.access(file, mode = 4) != 0) stop(paste("File", file, "is not readable"))
   
-  ali <- switch( format,
-	fasta = .Call("read_fasta_align", file, PACKAGE = "seqinr"), 
-	FASTA = .Call("read_fasta_align", file, PACKAGE = "seqinr"), 
+  fasta2ali <- function(file){
+  	tmp <- read.fasta(file, as.string = TRUE)
+  	list(length(tmp), getName(tmp), unlist(getSequence(tmp, as.string = TRUE)))
+  }
+  ali <- switch( tolower(format),
+	fasta = fasta2ali(file), 
 	mase = .Call("read_mase", file, PACKAGE = "seqinr"),
-	MASE = .Call("read_mase", file, PACKAGE = "seqinr"),
 	phylip = .Call("read_phylip_align", file, PACKAGE = "seqinr"),
-	PHYLIP = .Call("read_phylip_align", file, PACKAGE = "seqinr"),
 	msf = .Call("read_msf_align", file, PACKAGE = "seqinr"),
-	MSF = .Call("read_msf_align", file, PACKAGE = "seqinr"),
-	CLUSTAL = .Call("read_clustal_align", file, PACKAGE = "seqinr"),
 	clustal = .Call("read_clustal_align", file, PACKAGE = "seqinr"),
-	stop("Wrong format name: Format available are fasta,mase,phylip,msf,clustal")
+	stop("Wrong format name: Format available are fasta, mase, phylip, msf, clustal")
   )
 
   ali <- lapply(ali, as.character)



More information about the Seqinr-commits mailing list