-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdemo_run.R
78 lines (72 loc) · 2.25 KB
/
demo_run.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Example: Rscript demos/demo_run.R /workspaces/blast/bin/
# LIBS
#library(phylotaR)
devtools::load_all()
# VARS ----
demos <- c(
"anisoptera" = "6962", "acipenseridae" = "7900",
"tinamiformes" = "8802", "aotus" = "9504",
"bromeliaceae" = "4613", "cycadidae" = "1445963",
"eutardigrada" = "42242", "kazachstania" = "71245",
"platyrrhini" = "9479", "primates" = "9443"
)
demos <- demos[1:9]
# set these paths for your own system
args <- commandArgs(trailingOnly = TRUE)
if (length(args) < 1) {
print("Please provide a NCBI blast path")
quit(status = -1)
} else {
message("Only the first path will be used.")
ncbi_dr <- args[1]
}
# FOR LOOP ----
for (i in seq_along(demos)) {
txid <- demos[[i]]
wd <- file.path(getwd(), "demos", names(demos)[[i]])
# create folder, delete if already exists
if (file.exists(wd)) {
unlink(wd, recursive = TRUE)
}
dir.create(wd)
# run
phylotaR::setup(wd = wd, txid = txid, ncbi_dr = ncbi_dr, v = TRUE)
run(wd = wd)
}
# TIMINGS ----
timings <- vector(mode = "list", length = length(demos))
names(timings) <- names(demos)
for (i in seq_along(demos)) {
wd <- file.path(getwd(), "demos", names(demos)[[i]])
timings[[i]] <- get_stage_times(wd)
}
# CLSQ STATS ----
clsq <- vector(mode = "list", length = length(demos))
names(clsq) <- names(demos)
for (i in seq_along(demos)) {
wd <- file.path(getwd(), "demos", names(demos)[[i]])
phylota <- read_phylota(wd)
clsq[[i]] <- c(
"Taxa" = length(phylota@txids),
"Sequences" = length(phylota@sids),
"Clusters" = length(phylota@cids)
)
}
# MARKDOWN ----
mrkdwn <- "Taxon|N. taxa|N. sequences|N. clusters|Taxise (mins.)|"
mrkdwn <- paste0(mrkdwn, "Download (mins.)|Cluster (mins.)|Cluster2 (mins.)|")
mrkdwn <- paste0(mrkdwn, "Total (mins.)|\n")
mrkdwn <- paste0(mrkdwn, "|:--|--:|--:|--:|--:|--:|--:|--:|--:|\n")
for (i in seq_along(timings)) {
mrkdwn <- paste0(
mrkdwn, Hmisc::capitalize(names(timings)[[i]]), "|",
clsq[[i]][["Taxa"]], "|", clsq[[i]][["Sequences"]], "|",
clsq[[i]][["Clusters"]], "|",
signif(timings[[i]][["taxise"]], 2), "|",
signif(timings[[i]][["download"]], 2), "|",
signif(timings[[i]][["cluster"]], 2), "|",
signif(timings[[i]][["cluster\\^2"]], 2), "|",
signif(sum(timings[[i]]), 2), "|\n"
)
}
cat(mrkdwn)