Skip to content

Commit

Permalink
aliscore, alicut
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoer Dong committed Dec 10, 2018
1 parent 9bc60a1 commit 39dd90d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
46 changes: 46 additions & 0 deletions R/phylo.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#' @title wrapper to run Aliscore
#'
#' @details aliscore will produce several files under the directory containg input files
#'
#' @param args character. options for `Aliscore.0x.y.pl`
#' @param ... other parameters passed on to [system2()]
#'
#' @return result of [system2()]
#' @export
#'
#' @examples
#' \donotrun {
#' aliscore('-i data-raw/aliscore/test.fasta')
#' }
aliscore <- function(args, ...) {
args %<>% c('-I', pkg_file('lib'), pkg_file('exec/Aliscore.02.2.pl'), .)
system2('perl', args, ...);
}


#' @title wrapper to run Alicut
#'
#' @param dir string. the directory your input files lie. working directory will
#' be temporarily set to it
#' @param ... other parameters passed on to [system2()], including `args` and so
#' on.
#'
#' @return result of [system2()]
#' @export
#'
#' @examples
#' \donotrun {
#' aliscore('-i data-raw/aliscore/test.fasta');
#' alicut('data-raw/aliscore', args = '-s')
#' }
alicut <- function(dir, ...) {
old_wd <- getwd();
on.exit(setwd(old_wd));

setwd(dir);
system2(pkg_file('exec/ALICUT_V2.31.pl'), ...);
}




4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(biozhuoer)

test_check("biozhuoer")
15 changes: 15 additions & 0 deletions tests/testthat/test-phylo.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
context("Testing phylo")

setwd('../..');

dir('data-raw/aliscore/', full.names = T) %>% file.remove()
file.copy('data-raw/aligned-multiline.fasta', 'data-raw/aliscore/test.fasta');

test_that("Testing aliscore", {
expect_identical(aliscore('-i data-raw/aliscore/test.fasta', F, F), 0L);
});

test_that("Testing alicut", {
expect_identical(alicut('data-raw/aliscore', '-s'), 0L);
});

0 comments on commit 39dd90d

Please sign in to comment.