Skip to content

Commit

Permalink
Merge pull request #10 from mrc-ide/develop
Browse files Browse the repository at this point in the history
fixed matching function
  • Loading branch information
bobverity authored Jan 16, 2025
2 parents a00e521 + 5e33559 commit 3e0f83f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: variantstring
Type: Package
Title: Functions for working with variant string format
Version: 1.6.0
Version: 1.7.0
Authors@R: c(
person("Bob", "Verity", email = "r.verity@imperial.ac.uk", role = c("aut", "cre"))
)
Expand Down
22 changes: 13 additions & 9 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -924,17 +924,21 @@ compare_variant_string <- function(target_string, comparison_strings) {
}, 1:nrow(df_target), SIMPLIFY = FALSE) |>
dplyr::bind_rows()

# get if a match over all loci, and if match is ambiguous
# get if a match over all loci, if ambiguous, and the proportion
ret$match[i] <- all(df_match$match == 1)
ret$ambiguous[i] <- (sum(df_match$het) > 1) & ret$match[i]

if (sum(df_match$het) == 0) {
ret$prop[i] <- ret$match[i]
} else if (sum(df_match$het) == 1) {
w <- which(df_match$het == 1)
ret$prop[i] <- df_match$read_num[w] / df_match$read_denom[w]
if (ret$match[i]) {
ret$ambiguous[i] <- (sum(df_match$het) > 1)
if (sum(df_match$het) == 0) {
ret$prop[i] <- 1
} else if (sum(df_match$het) == 1) {
w <- which(df_match$het == 1)
ret$prop[i] <- df_match$read_num[w] / df_match$read_denom[w]
} else {
ret$prop[i] <- NA
}
} else {
ret$prop[i] <- NA
ret$ambiguous[i] <- FALSE
ret$prop[i] <- 0.0
}
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ There are also a few more utility functions not listed here - see the package he

## Release history

The current version is 1.6.0, released 16 Jan 2025.
The current version is 1.7.0, released 16 Jan 2025.

0 comments on commit 3e0f83f

Please sign in to comment.