]> git.donarmstrong.com Git - ape.git/blobdiff - R/clustal.R
fix bug in prop.clades
[ape.git] / R / clustal.R
index 3cfd1c0373667aa4abf1ae66414975c069c825e8..c777945c0963e5761fcabba066ab08fa347221b1 100644 (file)
@@ -1,21 +1,21 @@
-## clustal.R (2011-03-16)
+## clustal.R (2012-11-28)
 
 ##   Multiple Sequence Alignment with External Applications
 
-## Copyright 2011 Emmanuel Paradis
+## Copyright 2011-2012 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
 
 clustal <- function(x, pw.gapopen = 10, pw.gapext = 0.1,
                     gapopen = 10, gapext = 0.2, exec = NULL,
-                    MoreArgs = "", quiet = TRUE)
+                    MoreArgs = "", quiet = TRUE, original.ordering = TRUE)
 {
     os <- Sys.info()[1]
     if (is.null(exec)) {
         if (os == "Linux") exec <- "clustalw"
         if (os == "Darwin") exec <- "clustalw2"
-        if (os == "Windows") exec <- "C:/Program Files/ClustalW2/clustalw2"
+        if (os == "Windows") shortPathName("C:/Program Files/ClustalW2/clustalw2.exe")
     }
 
     if (missing(x)) {
@@ -32,10 +32,12 @@ clustal <- function(x, pw.gapopen = 10, pw.gapext = 0.1,
     opts <- paste(prefix, suffix, sep = "=", collapse = " ")
     opts <- paste(opts, MoreArgs)
     system(paste(exec, opts), ignore.stdout = quiet)
-    read.dna(outf, "clustal")
+    res <- read.dna(outf, "clustal")
+    if (original.ordering) res <- res[labels(x), ]
+    res
 }
 
-muscle <- function(x, exec = "muscle", MoreArgs = "", quiet = TRUE)
+muscle <- function(x, exec = "muscle", MoreArgs = "", quiet = TRUE, original.ordering = TRUE)
 {
     if (missing(x)) {
         system(exec)
@@ -50,10 +52,12 @@ muscle <- function(x, exec = "muscle", MoreArgs = "", quiet = TRUE)
     if (quiet) opts <- paste(opts, "-quiet")
     opts <- paste(opts, MoreArgs)
     system(paste(exec, opts))
-    read.dna(outf, "fasta")
+    res <- read.dna(outf, "fasta")
+    if (original.ordering) res <- res[labels(x), ]
+    res
 }
 
-tcoffee <- function(x, exec = "t_coffee", MoreArgs = "", quiet = TRUE)
+tcoffee <- function(x, exec = "t_coffee", MoreArgs = "", quiet = TRUE, original.ordering = TRUE)
 {
     if (missing(x)) {
         system(exec)
@@ -68,5 +72,7 @@ tcoffee <- function(x, exec = "t_coffee", MoreArgs = "", quiet = TRUE)
     opts <- paste(inf, MoreArgs)
     if (quiet) opts <- paste(opts, "-quiet=nothing")
     system(paste(exec, opts))
-    read.dna("input_tcoffee.aln", "clustal")
+    res <- read.dna("input_tcoffee.aln", "clustal")
+    if (original.ordering) res <- res[labels(x), ]
+    res
 }