... | ... |
@@ -36,6 +36,7 @@ importFrom(basilisk,basiliskStop) |
36 | 36 |
importFrom(basilisk,obtainEnvironmentPath) |
37 | 37 |
importFrom(basilisk,setBasiliskFork) |
38 | 38 |
importFrom(basilisk.utils,activateEnvironment) |
39 |
+importFrom(basilisk.utils,deactivateEnvironment) |
|
39 | 40 |
importFrom(methods,is) |
40 | 41 |
importFrom(randomForest,randomForest) |
41 | 42 |
importFrom(reticulate,import_from_path) |
... | ... |
@@ -67,22 +67,24 @@ getAzimuthScores <- function(sequences, fork=FALSE){ |
67 | 67 |
|
68 | 68 |
# Ready to get the scores |
69 | 69 |
env <- basilisk::obtainEnvironmentPath(env_azimuth) |
70 |
- basilisk.utils::activateEnvironment(env) |
|
70 |
+ envls <- basilisk.utils::activateEnvironment(env) |
|
71 |
+ on.exit(basilisk.utils::deactivateEnvironment(envls)) |
|
71 | 72 |
programFile <- system.file("python", |
72 | 73 |
"azimuth/getAzimuth.py", |
73 | 74 |
package="crisprScore", |
74 | 75 |
mustWork=TRUE) |
75 |
- cmd <- paste0("python ", |
|
76 |
- programFile, " ", |
|
77 |
- inputfile, " ", |
|
78 |
- outputfile) |
|
76 |
+ #cmd <- paste0("python ", |
|
77 |
+ # programFile, " ", |
|
78 |
+ # inputfile, " ", |
|
79 |
+ # outputfile) |
|
79 | 80 |
|
80 | 81 |
if (sum(good)>0){ |
81 | 82 |
if (sum(good)==1){ |
82 | 83 |
sequences.valid <- rep(sequences.valid, 2) |
83 | 84 |
} |
84 | 85 |
.dumpToFile(sequences.valid, inputfile) |
85 |
- system(cmd) |
|
86 |
+ system2("python", |
|
87 |
+ c(programFile, inputfile, outputfile)) |
|
86 | 88 |
scores <- read.table(outputfile)[,1] |
87 | 89 |
if (sum(good)==1){ |
88 | 90 |
scores <- scores[1] |
... | ... |
@@ -39,9 +39,13 @@ |
39 | 39 |
#' @inheritParams getAzimuthScores |
40 | 40 |
#' @export |
41 | 41 |
#' @importFrom basilisk basiliskStart basiliskStop basiliskRun |
42 |
+#' @importFrom basilisk.utils activateEnvironment |
|
43 |
+#' @importFrom basilisk.utils deactivateEnvironment |
|
42 | 44 |
getDeepCpf1Scores <- function(sequences, |
43 | 45 |
convertPAM=TRUE, |
44 |
- fork=FALSE){ |
|
46 |
+ fork=FALSE |
|
47 |
+){ |
|
48 |
+ |
|
45 | 49 |
if (.Platform$OS.type=="windows"){ |
46 | 50 |
stop("DeepCpf1 is not available for Windows at the moment.") |
47 | 51 |
} |
... | ... |
@@ -74,18 +78,21 @@ getDeepCpf1Scores <- function(sequences, |
74 | 78 |
|
75 | 79 |
# Ready to get the scores |
76 | 80 |
env <- basilisk::obtainEnvironmentPath(env_deepcpf1) |
77 |
- basilisk.utils::activateEnvironment(env) |
|
81 |
+ envls <- basilisk.utils::activateEnvironment(env) |
|
82 |
+ on.exit(basilisk.utils::deactivateEnvironment(envls)) |
|
78 | 83 |
programFile <- system.file("python", |
79 | 84 |
"deepcpf1/getDeepCpf1.py", |
80 | 85 |
package="crisprScore", |
81 | 86 |
mustWork=TRUE) |
82 |
- cmd <- paste0("python ", |
|
83 |
- programFile, " ", |
|
84 |
- inputfile, " ", |
|
85 |
- outputfile) |
|
87 |
+ #cmd <- paste0("python ", |
|
88 |
+ # programFile, " ", |
|
89 |
+ # inputfile, " ", |
|
90 |
+ # outputfile) |
|
86 | 91 |
if (sum(good)>0){ |
87 | 92 |
.dumpToFile(sequences.valid, inputfile) |
88 |
- system(cmd) |
|
93 |
+ #system(cmd) |
|
94 |
+ system2("python", |
|
95 |
+ c(programFile, inputfile, outputfile)) |
|
89 | 96 |
scores <- read.table(outputfile)[,1] |
90 | 97 |
scores <- scores/100 |
91 | 98 |
df$score[good] <- scores |
... | ... |
@@ -72,7 +72,8 @@ getDeepSpCas9Scores <- function(sequences, |
72 | 72 |
|
73 | 73 |
# Ready to get the scores |
74 | 74 |
env <- basilisk::obtainEnvironmentPath(env_deepspcas9) |
75 |
- basilisk.utils::activateEnvironment(env) |
|
75 |
+ envls <- basilisk.utils::activateEnvironment(env) |
|
76 |
+ on.exit(basilisk.utils::deactivateEnvironment(envls)) |
|
76 | 77 |
programFile <- system.file("python", |
77 | 78 |
"deepspcas9/getDeepSpCas9Scores.py", |
78 | 79 |
package="crisprScore", |
... | ... |
@@ -81,14 +82,15 @@ getDeepSpCas9Scores <- function(sequences, |
81 | 82 |
"deepspcas9/DeepCas9_Final", |
82 | 83 |
package="crisprScore") |
83 | 84 |
modelDir <- paste0(modelDir, "/") |
84 |
- cmd <- paste0("python ", |
|
85 |
- programFile, " ", |
|
86 |
- inputfile, " ", |
|
87 |
- modelDir, " ", |
|
88 |
- outputfile) |
|
85 |
+ #cmd <- paste0("python ", |
|
86 |
+ # programFile, " ", |
|
87 |
+ # inputfile, " ", |
|
88 |
+ # modelDir, " ", |
|
89 |
+ # outputfile) |
|
89 | 90 |
if (sum(good)>0){ |
90 | 91 |
.dumpToFile(sequences.valid, inputfile) |
91 |
- system(cmd) |
|
92 |
+ system2("python", |
|
93 |
+ c(programFile, inputfile, modelDir, outputfile)) |
|
92 | 94 |
scores <- read.table(outputfile)[,1] |
93 | 95 |
#scores <- read.table(outputfile) |
94 | 96 |
scores <- scores/100 |
... | ... |
@@ -81,7 +81,9 @@ getLindelScores <- function(sequences, fork=FALSE){ |
81 | 81 |
seq, " ", |
82 | 82 |
weights_file, " ", |
83 | 83 |
file.full) |
84 |
- system(cmd, ignore.stdout=TRUE, ignore.stderr=FALSE) |
|
84 |
+ system(cmd, |
|
85 |
+ ignore.stdout=TRUE, |
|
86 |
+ ignore.stderr=FALSE) |
|
85 | 87 |
outputs <- list.files(dir) |
86 | 88 |
outputs <- outputs[grepl(file, outputs)] |
87 | 89 |
file.remove(file.path(dir,outputs)) |
... | ... |
@@ -86,7 +86,8 @@ getRuleSet3Scores <- function(sequences, |
86 | 86 |
|
87 | 87 |
# Ready to get the scores |
88 | 88 |
env <- basilisk::obtainEnvironmentPath(env_rs3) |
89 |
- basilisk.utils::activateEnvironment(env) |
|
89 |
+ envls <- basilisk.utils::activateEnvironment(env) |
|
90 |
+ on.exit(basilisk.utils::deactivateEnvironment(envls)) |
|
90 | 91 |
programFile <- system.file("python", |
91 | 92 |
"rs3/getRuleSet3ScoresSequence.py", |
92 | 93 |
package="crisprScore", |
... | ... |
@@ -94,16 +95,18 @@ getRuleSet3Scores <- function(sequences, |
94 | 95 |
modelFile <- system.file("rs3", |
95 | 96 |
"RuleSet3.pkl", |
96 | 97 |
package="crisprScoreData") |
97 |
- cmd <- paste0("python ", |
|
98 |
- programFile, " ", |
|
99 |
- inputfile, " ", |
|
100 |
- modelFile, " ", |
|
101 |
- outputfile, " ", |
|
102 |
- shQuote(tracrRNA)) |
|
98 |
+ #cmd <- paste0("python ", |
|
99 |
+ # programFile, " ", |
|
100 |
+ # inputfile, " ", |
|
101 |
+ # modelFile, " ", |
|
102 |
+ # outputfile, " ", |
|
103 |
+ # shQuote(tracrRNA)) |
|
103 | 104 |
if (sum(good)>0){ |
104 | 105 |
.dumpToFile(sequences.valid, |
105 | 106 |
inputfile) |
106 |
- system(cmd) |
|
107 |
+ system2("python", |
|
108 |
+ c(programFile, inputfile, modelFile, |
|
109 |
+ outputfile,shQuote(tracrRNA))) |
|
107 | 110 |
#scores <- readLines(outputfile, sep="\t")[,4] |
108 | 111 |
scores <- readLines(outputfile) |
109 | 112 |
df$score[good] <- scores |