Skip to content

Commit 16aff86

Browse files
committed
Make Meta dbs
1 parent e2fac5e commit 16aff86

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

Diff for: 3.20/bioc/bbscentral2/postrun.sh

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if [ -n "$BBS_OUTGOING_MAP" ]; then
3232
find OUTGOING -type d -exec chmod 755 {} \;
3333
$BBS_PYTHON_CMD $BBS_HOME/BBS-make-PROPAGATION_STATUS_DB.py
3434
chmod -R +r .
35+
$BBS_PYTHON_CMD $BBS_HOME/BBS-make-meta.py
3536
fi
3637

3738
# Generate the HTML report

Diff for: 3.21/bioc/bbscentral1/postrun.sh

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if [ -n "$BBS_OUTGOING_MAP" ]; then
3232
find OUTGOING -type d -exec chmod 755 {} \;
3333
$BBS_PYTHON_CMD $BBS_HOME/BBS-make-PROPAGATION_STATUS_DB.py
3434
chmod -R +r .
35+
$BBS_PYTHON_CMD $BBS_HOME/BBS-make-meta.py
3536
fi
3637

3738
# Generate the HTML report

Diff for: BBS-make-meta-dbs.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
import os
5+
import time
6+
import subprocess
7+
8+
import BBSutils
9+
import BBSvars
10+
import BBSbase
11+
12+
def make_meta():
13+
## Prepare Rexpr (must be a single string with no spaces).
14+
Rscript_path = os.path.join(BBSvars.BBS_home,
15+
'utils',
16+
'generateMetaDbs.R')
17+
Rfun = 'generateMetaDbs'
18+
OUTGOING_dir = 'OUTGOING'
19+
db_filepath = 'PROPAGATION_STATUS_DB.txt'
20+
Rfuncall = f"{Rfun}('{OUTGOING_dir}','{db_filepath}')"
21+
Rexpr = f"source('{Rscript_path}');{Rfuncall}"
22+
23+
## Turn Rexpr into a system command.
24+
cmd = BBSbase.Rexpr2syscmd(Rexpr)
25+
26+
try:
27+
## Nasty things (that I don't really understand) can happen with
28+
## subprocess.run() if this code is runned by the Task Scheduler
29+
## on Windows (the child process tends to almost always return an
30+
## error). Apparently using 'stderr=subprocess.STDOUT' fixes this pb.
31+
subprocess.run(cmd, stdout=None, stderr=subprocess.STDOUT, shell=True,
32+
check=True)
33+
except subprocess.CalledProcessError as e:
34+
print(f'BBS> [generateMetaDbs] Failed at {time.asctime()} . . .')
35+
print(f'BBS> [generateMetaDbs] Error: {e} . . .')
36+
return
37+
38+
39+
##############################################################################
40+
### MAIN SECTION
41+
##############################################################################
42+
43+
if __name__ == "__main__":
44+
if not os.path.isfile('PROPAGATION_STATUS_DB.txt'):
45+
msg = (
46+
f'Make sure to be in {BBSvars.Central_rdir.path} and run '
47+
f'BBS-make-PROPAGATION_STATUS_DB.py before BBS-make-meta.py.'
48+
)
49+
sys.exit('=> EXIT.')
50+
print('BBS> ==============================================================')
51+
print(f'BBS> [generateMetaDbs] STARTING on {time.asctime()} ...')
52+
sys.stdout.flush()
53+
generate_meta_dbs()
54+
print(f'BBS> [generateMetaDbs] DONE on {time.asctime()} ...')
55+

Diff for: utils/makeMetaDbs.R

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
generateMetaDbs <- function(outgoing_path, db_filepath) {
2+
3+
meat_dir <- Sys.getenv("BBS_MEAT_PATH")
4+
bbs_central_rdir <- Sys.getenv("BBS_CENTRAL_RDIR")
5+
prop_status <- read.dcf(file.path(bbs_central_rdir, db_filepath))
6+
7+
pkgs <- c()
8+
for (i in 1:dim(prop_status)[2]) {
9+
pkg_type_stage <- strsplit(colnames(prop_status)[i], "#")[[1]]
10+
if ("source" %in% pkg_type_stage &&
11+
strsplit(prop_status[i], ",")[[1]][1] %in% c("YES", "UNNEEDED")) {
12+
pkgs <- c(pkgs, pkg_type_stage[1])
13+
}
14+
}
15+
16+
# Because the location is always recreated, we always create the Meta
17+
# directory and always create all the databases
18+
web_dir <- file.path(bbs_central_rdir, "web", "packages")
19+
meta_dir <- file.path(bbs_central_rdir, "OUTGOING", "Meta")
20+
dir.create(meta_dir, recursive = TRUE)
21+
22+
biocViews::build_db_from_source(file.path(meat_dir, pkgs), bbs_central_rdir)
23+
24+
aliases_db_file <- file.path(meta_dir, "aliases.rds")
25+
biocViews::build_meta_aliases_db(web_dir, aliases_db_file, TRUE)
26+
27+
rdxrefs_db_file <- file.path(meta_dir, "rdxrefs.rds")
28+
biocViews::build_meta_rdxrefs_db(web_dir, rdxrefs_db_file, TRUE)
29+
}

0 commit comments

Comments
 (0)