grunwaldlab / effectR

An R package to call oomycete effectors
10 stars 7 forks source link

fixed potential bug when mafft path is specified as the path to the binary on windows #9

Closed zachary-foster closed 7 years ago

zachary-foster commented 7 years ago

I noticed that the following code will probably fail on windows when mafft.path is given a path that ends in "mafft.bat". It will probably enter the third "if" statement and add on another "mafft.bat".

https://github.com/grunwaldlab/effectR/blob/d72fae3e6a37a93a6ed42d4dceff3d47b616f12a/R/internal.R#L13-L25

I dont know why it looks like I replaced the whole file. Maybe windows line endings? Anyway all I added was:

  # Get name of mafft executable
  if (Sys.info()[['sysname']] == "Windows") {
    mafft_file <- "mafft.bat"
  } else {
    mafft_file <- "mafft"
  }

  # Set defualt path
  if (is.null(mafft.path)) {
    path <- unname(Sys.which("mafft"))
  } else if (endsWith(mafft.path, mafft_file)) { # if mafft executable is in the path...
    path <- mafft.path
  } else {
    # add on executable to path if not already present
    path <- file.path(mafft.path, mafft_file)
  }