Skip to content

Commit

Permalink
Changed system to system2
Browse files Browse the repository at this point in the history
  • Loading branch information
fortinj2 committed Jul 24, 2022
1 parent 1de382d commit 4af68d2
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 29 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ importFrom(basilisk,basiliskStop)
importFrom(basilisk,obtainEnvironmentPath)
importFrom(basilisk,setBasiliskFork)
importFrom(basilisk.utils,activateEnvironment)
importFrom(basilisk.utils,deactivateEnvironment)
importFrom(methods,is)
importFrom(randomForest,randomForest)
importFrom(reticulate,import_from_path)
Expand Down
14 changes: 8 additions & 6 deletions R/getAzimuthScores.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,24 @@ getAzimuthScores <- function(sequences, fork=FALSE){

# Ready to get the scores
env <- basilisk::obtainEnvironmentPath(env_azimuth)
basilisk.utils::activateEnvironment(env)
envls <- basilisk.utils::activateEnvironment(env)
on.exit(basilisk.utils::deactivateEnvironment(envls))
programFile <- system.file("python",
"azimuth/getAzimuth.py",
package="crisprScore",
mustWork=TRUE)
cmd <- paste0("python ",
programFile, " ",
inputfile, " ",
outputfile)
#cmd <- paste0("python ",
# programFile, " ",
# inputfile, " ",
# outputfile)

if (sum(good)>0){
if (sum(good)==1){
sequences.valid <- rep(sequences.valid, 2)
}
.dumpToFile(sequences.valid, inputfile)
system(cmd)
system2("python",
c(programFile, inputfile, outputfile))
scores <- read.table(outputfile)[,1]
if (sum(good)==1){
scores <- scores[1]
Expand Down
21 changes: 14 additions & 7 deletions R/getDeepCpf1Scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@
#' @inheritParams getAzimuthScores
#' @export
#' @importFrom basilisk basiliskStart basiliskStop basiliskRun
#' @importFrom basilisk.utils activateEnvironment
#' @importFrom basilisk.utils deactivateEnvironment
getDeepCpf1Scores <- function(sequences,
convertPAM=TRUE,
fork=FALSE){
fork=FALSE
){

if (.Platform$OS.type=="windows"){
stop("DeepCpf1 is not available for Windows at the moment.")
}
Expand Down Expand Up @@ -74,18 +78,21 @@ getDeepCpf1Scores <- function(sequences,

# Ready to get the scores
env <- basilisk::obtainEnvironmentPath(env_deepcpf1)
basilisk.utils::activateEnvironment(env)
envls <- basilisk.utils::activateEnvironment(env)
on.exit(basilisk.utils::deactivateEnvironment(envls))
programFile <- system.file("python",
"deepcpf1/getDeepCpf1.py",
package="crisprScore",
mustWork=TRUE)
cmd <- paste0("python ",
programFile, " ",
inputfile, " ",
outputfile)
#cmd <- paste0("python ",
# programFile, " ",
# inputfile, " ",
# outputfile)
if (sum(good)>0){
.dumpToFile(sequences.valid, inputfile)
system(cmd)
#system(cmd)
system2("python",
c(programFile, inputfile, outputfile))
scores <- read.table(outputfile)[,1]
scores <- scores/100
df$score[good] <- scores
Expand Down
16 changes: 9 additions & 7 deletions R/getDeepSpCas9Scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ getDeepSpCas9Scores <- function(sequences,

# Ready to get the scores
env <- basilisk::obtainEnvironmentPath(env_deepspcas9)
basilisk.utils::activateEnvironment(env)
envls <- basilisk.utils::activateEnvironment(env)
on.exit(basilisk.utils::deactivateEnvironment(envls))
programFile <- system.file("python",
"deepspcas9/getDeepSpCas9Scores.py",
package="crisprScore",
Expand All @@ -81,14 +82,15 @@ getDeepSpCas9Scores <- function(sequences,
"deepspcas9/DeepCas9_Final",
package="crisprScore")
modelDir <- paste0(modelDir, "/")
cmd <- paste0("python ",
programFile, " ",
inputfile, " ",
modelDir, " ",
outputfile)
#cmd <- paste0("python ",
# programFile, " ",
# inputfile, " ",
# modelDir, " ",
# outputfile)
if (sum(good)>0){
.dumpToFile(sequences.valid, inputfile)
system(cmd)
system2("python",
c(programFile, inputfile, modelDir, outputfile))
scores <- read.table(outputfile)[,1]
#scores <- read.table(outputfile)
scores <- scores/100
Expand Down
4 changes: 3 additions & 1 deletion R/getLindelScores.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ getLindelScores <- function(sequences, fork=FALSE){
seq, " ",
weights_file, " ",
file.full)
system(cmd, ignore.stdout=TRUE, ignore.stderr=FALSE)
system(cmd,
ignore.stdout=TRUE,
ignore.stderr=FALSE)
outputs <- list.files(dir)
outputs <- outputs[grepl(file, outputs)]
file.remove(file.path(dir,outputs))
Expand Down
19 changes: 11 additions & 8 deletions R/getRuleSet3Scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,27 @@ getRuleSet3Scores <- function(sequences,

# Ready to get the scores
env <- basilisk::obtainEnvironmentPath(env_rs3)
basilisk.utils::activateEnvironment(env)
envls <- basilisk.utils::activateEnvironment(env)
on.exit(basilisk.utils::deactivateEnvironment(envls))
programFile <- system.file("python",
"rs3/getRuleSet3ScoresSequence.py",
package="crisprScore",
mustWork=TRUE)
modelFile <- system.file("rs3",
"RuleSet3.pkl",
package="crisprScoreData")
cmd <- paste0("python ",
programFile, " ",
inputfile, " ",
modelFile, " ",
outputfile, " ",
shQuote(tracrRNA))
#cmd <- paste0("python ",
# programFile, " ",
# inputfile, " ",
# modelFile, " ",
# outputfile, " ",
# shQuote(tracrRNA))
if (sum(good)>0){
.dumpToFile(sequences.valid,
inputfile)
system(cmd)
system2("python",
c(programFile, inputfile, modelFile,
outputfile,shQuote(tracrRNA)))
#scores <- readLines(outputfile, sep="\t")[,4]
scores <- readLines(outputfile)
df$score[good] <- scores
Expand Down

0 comments on commit 4af68d2

Please sign in to comment.