Commit 8072722f by Eric Coissac

First version of the introduction of the sumalib aligment routine in ROBITools2

parent 11fda8e5
......@@ -388,6 +388,7 @@ export(is_robitaxonomy)
export(is_robiuniqueid)
export(is_subcladeof)
export(kingdom)
export(lcs_score)
export(left_parse_sample_ids)
export(log_q)
export(lowest_common_ancestor)
......
......@@ -2,6 +2,7 @@
#' @importFrom vctrs vec_data vec_cast vec_default_ptype2 vec_default_cast new_factor
#' @importFrom glue glue
#' @import stringr
#' @import tibble
NULL
#' Vector of 4mers for multiplexing PCR.
......@@ -161,3 +162,49 @@ as_robi4mer <- function(object) {
vec_cast(object,robi4mer())
}
#' @export
lcs_score <- function(x,y,lx=nchar(x),ly=nchar(y),
threshold = -1,
normalize = FALSE,
reference = c("alignment","longest","shortest"),
similarity_mode = c("similarity","distance"),
lcs=FALSE,alilength=FALSE) {
data <- tibble(x=x,y=y,lx=lx,ly=ly)
theshold <- as.double(threshold[1])
normalize <- as.logical(normalize[1])
reference <- as.integer(match(as.character(reference[1]),c("alignment","longest","shortest"),nomatch = 0) - 1)
robiassert_arg(reference>=0,
"reference",
"must be one of the following values : \"alignment\",\"longest\",\"shortest\"")
similarity_mode <- match(as.character(similarity_mode[1]),c("similarity","distance"),0)
robiassert_arg(similarity_mode>0,
"similarity_mode",
"must be one of the following values : \"similarity\",\"distance\"")
similarity_mode <- similarity_mode == 1
lcs <- as.logical(lcs[1])
alilength <- as.logical(alilength[1])
results = .Call("ROBI_lcs",
data$x,data$y,data$lx,data$ly,
threshold,normalize,reference,similarity_mode,
lcs,alilength)
n <- "score"
if (lcs) n <- c(n,"lcs")
if (alilength) n <- c(n,"alignment_length")
names(results) <- n
do.call(tibble,results);
}
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment