Skip to content

Commit 6cdac55

Browse files
committed
Added checks.
Added checks of valid domains/species for scoreWTSequences.
1 parent e607599 commit 6cdac55

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

R/Rmimp.R

+17-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ library(GenomicRanges)
66
library(data.table)
77
library(Biostrings)
88

9-
if(F){
9+
if(T){
1010
setwd('~/Desktop/Repos/rmimp/')
1111
BASE_DIR = '~/Desktop/Repos/rmimp/inst/extdata'
1212
source('R/display-functions.r')
@@ -485,6 +485,22 @@ pRewiringPosterior <- function(wt.scores, mt.scores, fg.params, bg.params, auc=1
485485
#' @import data.table
486486
#' @export
487487
scoreWTSequence <- function(wt_seqs, central = T, domain = "phos", species = "human", model.data = "hconf", cores = 2) {
488+
# Ensure valid domain
489+
if (central) {
490+
valid.domains <- .VALID_DOMAINS$central
491+
} else {
492+
valid.domains <- .VALID_DOMAINS$not_central
493+
}
494+
495+
if (!is.element(domain, valid.domains)) {
496+
stop("Domain must be valid. Please check MIMP documentation for a list of valid domains")
497+
}
498+
499+
# Ensure valid species
500+
if (!is.element(species, .VALID_SPECIES[[domain]])) {
501+
stop("Species must be valid. Please check MIMP documentation for a list of valid domains")
502+
}
503+
488504
# Load model
489505
cat('\r.... | loading specificity models')
490506
mpath <- .getModelDataPath(model.data, domain = domain, species = species)

R/display-functions.r

+2-8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
#'
1010
#' @param s Data frame resulting from mimp call.
1111
#' @param dist Distance of mutation.
12-
#'
13-
#' @keywords helper mimp
12+
#' @noRd
1413
.htmlSeq <- function(s, dist) {
1514
s = strsplit(s, '')[[1]]
1615
if (dist != 0)
@@ -26,8 +25,7 @@
2625
#'
2726
#' @param s Data frame resulting from mimp call.
2827
#' @param dist Distance of mutation.
29-
#'
30-
#' @keywords helper mimp
28+
#' @noRd
3129
.htmlSeqSh3 <- function(wt, mut) {
3230
wtSplit <- strsplit(wt, '')[[1]]
3331
mutSplit <- strsplit(mut, '')[[1]]
@@ -48,8 +46,6 @@
4846
#' @param HL_DIR Directory containing overlays
4947
#' @param logoExt Extension of logo files
5048
#' @param .webserver Request coming from webserver?
51-
#'
52-
#' @keywords display mimp
5349
dohtml <- function(x, LOGO_DIR, HL_DIR, logoExt = ".svg", .webserver = F) {
5450
x = unfactor(x)
5551
x$score_wt = signif(x$score_wt, 3)
@@ -151,8 +147,6 @@ dohtml <- function(x, LOGO_DIR, HL_DIR, logoExt = ".svg", .webserver = F) {
151147
#' @param HL_DIR Directory containing overlays
152148
#' @param logoExt Extension of logo files
153149
#' @param .webserver Request coming from webserver?
154-
#'
155-
#' @keywords display mimp
156150
dohtmlSh3 <- function(x, LOGO_DIR, HL_DIR, logoExt = ".svg", .webserver = F) {
157151
x = unfactor(x)
158152
x$score_wt = signif(x$score_wt, 3)

R/pwm-functions.r

+1-4
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ scoreArrayRolling <- function(seqs, pwm){
201201
#'
202202
#' @param seqs Sequences to be scored
203203
#' @param pwm Position weight matrix
204-
#'
205-
#' @keywords pwm mss match tfbs
206-
#' @examples
207-
#' # No Examples
204+
#' @noRd
208205
.mssNonCentral <- function(seqs, pwm){
209206
# Best/worst sequence match
210207
oa = scoreArrayFast(bestSequence(pwm), pwm, do_sum = F)[[1]]

man/dohtml.Rd

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dohtmlSh3.Rd

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)