/usr/lib/R/site-library/Gviz/scripts/testBiomartGenomeMappings.R is in r-bioc-gviz 1.22.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | library(Gviz)
library(biomaRt)
library(Biobase)
library(rtracklayer)
testBiomartVersion <- function(){
allGenomes <- union(read.delim(system.file(package="Gviz", "extdata/biomartVersionsLatest.txt"))$ucscId,
read.delim(system.file(package="Gviz", "extdata/biomartVersionsNow.txt"))$ucscId)
res <- mclapply(allGenomes, function(genome){
return(try({
map <- Gviz:::.ucsc2Ensembl(genome)
res <- list()
if(map$date == "head"){
bm <- useMart("ensembl", dataset=map$dataset)
ds <- listDatasets(bm)
mt <- ds[match(map$dataset, ds$dataset), "version"]
if(is.na(mt)){
res <- list(current=genome, set=map$dataset, type="head", cause="error")
}
if(mt != map$value){
res <- list(current=genome, set=map$value, setCurrent=mt, type="head", cause="mismatch")
}
}else{
bm <- useMart(host=sprintf("%s.archive.ensembl.org", tolower(sub(".", "", map$date, fixed=TRUE))),
biomart="ENSEMBL_MART_ENSEMBL", dataset=map$dataset)
ds <- listDatasets(bm)
mt <- ds[match(map$dataset, ds$dataset), "version"]
if(is.na(mt)){
res <- list(current=genome, set=map$dataset, type="archive", cause="error")
}
if(mt != map$value){
res <- list(current=genome, set=map$value, setArchive=sub(".", " ", map$date, fixed=TRUE),
setVersion=map$version, setCurrent=mt, type="archive", cause="mismatch")
}
}
res
}, silent=TRUE))
})
res <- res[listLen(res)>0]
res[sapply(res, is, "try-error")] <- list(type="error")
allFields <- unique(unlist(lapply(res, names)))
dt <- as.data.frame(do.call(rbind, lapply(res, function(x) t(as.data.frame(unlist(x)[allFields])))),
stringsAsFactors=FALSE)
rownames(dt) <- NULL
gens <- ucscGenomes()
gens$version <- as.numeric(gsub("[a-zA-Z]*", "", gens$db))
gensS <- split(gens, gsub("[0-9]*$", "", gens$db))
highestVersion <- as.data.frame(t(sapply(gensS, function(x) unlist(x[which.max(x$version),]))),
stringsAsFactors=FALSE)
rownames(gens) <- gens$db
mt <- match(gsub("[0-9]*$", "", dt$current), rownames(highestVersion))
tmp <- highestVersion[mt, c("db", "date", "name", "version")]
colnames(tmp) <- paste("UCSCLatest", colnames(tmp), sep="_")
dt2 <- cbind(dt, tmp)
tmp2 <- gens[dt2$current,c("db", "date", "name", "version")]
colnames(tmp2) <- paste("UCSC", colnames(tmp2), sep="_")
dt3 <- cbind(dt2, tmp2)
if(require(xlsx)){
write.xlsx2(dt3, file="ensMappings.xlsx", sheetName="Sheet1")
}else{
write.table(dt3, file="ensMappings.xls", sep="\t", quote=FALSE)
}
return(dt3)
}
|