[Seqinr-commits] r2090 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Feb 24 12:11:37 CET 2018


Author: jeanlobry
Date: 2018-02-24 12:11:36 +0100 (Sat, 24 Feb 2018)
New Revision: 2090

Modified:
   pkg/R/read.alignment.R
   pkg/R/read.fasta.R
Log:
 

Modified: pkg/R/read.alignment.R
===================================================================
--- pkg/R/read.alignment.R	2018-02-24 11:10:38 UTC (rev 2089)
+++ pkg/R/read.alignment.R	2018-02-24 11:11:36 UTC (rev 2090)
@@ -1,7 +1,7 @@
 #
 # Read files of aligned sequences in various formats
 #
-read.alignment <- function(file, format, forceToLower = TRUE)
+read.alignment <- function(file, format, forceToLower = TRUE, ...)
 {
   #
   # Check that we have read permission on the file:
@@ -9,12 +9,12 @@
   file <- path.expand(file) 
   if(file.access(file, mode = 4) != 0) stop(paste("File", file, "is not readable"))
   
-  fasta2ali <- function(file){
-  	tmp <- read.fasta(file, as.string = TRUE)
+  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), 
+	fasta = fasta2ali(file, ...), 
 	mase = .Call("read_mase", file, PACKAGE = "seqinr"),
 	phylip = .Call("read_phylip_align", file, PACKAGE = "seqinr"),
 	msf = .Call("read_msf_align", file, PACKAGE = "seqinr"),

Modified: pkg/R/read.fasta.R
===================================================================
--- pkg/R/read.fasta.R	2018-02-24 11:10:38 UTC (rev 2089)
+++ pkg/R/read.fasta.R	2018-02-24 11:11:36 UTC (rev 2090)
@@ -1,6 +1,7 @@
 read.fasta <- function(file = system.file("sequences/ct.fasta.gz", package = "seqinr"), 
   seqtype = c("DNA", "AA"), as.string = FALSE, forceDNAtolower = TRUE,
   set.attributes = TRUE, legacy.mode = TRUE, seqonly = FALSE, strip.desc = FALSE,
+  whole.header = FALSE,
   bfa = FALSE, sizeof.longlong = .Machine$sizeof.longlong,
   endian = .Platform$endian, apply.mask = TRUE)
 {
@@ -49,10 +50,16 @@
   #
   # Read sequence names:
   #
-  nomseq <- lapply(seq_len(nseq), function(i){
-    firstword <- strsplit(lines[ind[i]], " ")[[1]][1]
-    substr(firstword, 2, nchar(firstword))
-  })
+  if(!whole.header){
+    nomseq <- lapply(seq_len(nseq), function(i){
+      firstword <- strsplit(lines[ind[i]], " ")[[1]][1]
+      substr(firstword, 2, nchar(firstword))
+      })
+  } else {
+    nomseq <- lapply(seq_len(nseq), function(i){
+      substr(lines[ind[i]], 2, nchar(lines[ind[i]]))
+      })  
+  }
   #
   # Turn DNA sequences in lower case letters if required:
   #



More information about the Seqinr-commits mailing list