|
a |
|
b/a_PreprocessPipeline/utils.R |
|
|
1 |
|
|
|
2 |
setCMD <- function(cmd, dir = ".", sepN = 1, conf = cmdConf) { |
|
|
3 |
|
|
|
4 |
idx <- seq_along(cmd) %% sepN |
|
|
5 |
idx[idx == 0] <- sepN |
|
|
6 |
|
|
|
7 |
cmdList <- tapply(cmd, idx, c) |
|
|
8 |
|
|
|
9 |
cmdHead <- glue(cmdConf$head, .trim = F) |
|
|
10 |
cmdList <- map2(cmdHead, cmdList, ~ c(.x, .y)) |
|
|
11 |
names(cmdList) <- 1:length(cmdList) |
|
|
12 |
|
|
|
13 |
iwalk(cmdList, ~ write.table( |
|
|
14 |
.x, |
|
|
15 |
glue("{dir}/batch{.y}.sh"), |
|
|
16 |
sep = "\n", quote = F, row.names = F, col.names = F, |
|
|
17 |
eol = "\n" |
|
|
18 |
)) |
|
|
19 |
|
|
|
20 |
submit <- glue( |
|
|
21 |
"{cmdConf$prefix} {dir}/batch{names(cmdList)}.sh {cmdConf$suffix}" |
|
|
22 |
) |
|
|
23 |
write.table( |
|
|
24 |
c("#!/bin/bash", submit), |
|
|
25 |
glue("{dir}/submit.sh"), |
|
|
26 |
sep = "\n", quote = F, row.names = F, col.names = F, |
|
|
27 |
eol = "\n" |
|
|
28 |
) |
|
|
29 |
|
|
|
30 |
system(glue("ls -lh {dir}")) |
|
|
31 |
} |