view test-data/out_rscript.txt @ 9:44018dd6b447 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/annotatemyids commit b71c1516972f1a9f869428c474aca5a42d08bb36"
author iuc
date Mon, 23 Nov 2020 01:03:37 +0000
parents 442e2d79b05c
children 4f2967b27e67
line wrap: on
line source


options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )

# we need that to not crash galaxy with an UTF8 error on German LC settings.
loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")

id_type <- "ENSEMBL"
organism <- "Hs"
output_cols <- "ENSEMBL,ENTREZID,SYMBOL,GENENAME"
file_has_header <- FALSE

ids <- as.character(read.table("/tmp/tmpY5XREO/files/000/dataset_3.dat", header=file_has_header)[,1])

if(organism == "Hs"){
    suppressPackageStartupMessages(library(org.Hs.eg.db))
    db <- org.Hs.eg.db
} else if (organism == "Mm"){
    suppressPackageStartupMessages(library(org.Mm.eg.db))
    db <- org.Mm.eg.db
} else if (organism == "Dm"){
    suppressPackageStartupMessages(library(org.Dm.eg.db))
    db <- org.Dm.eg.db
} else if (organism == "Dr"){
    suppressPackageStartupMessages(library(org.Dr.eg.db))
    db <- org.Dr.eg.db
} else {
    cat(paste("Organism type not supported", organism))
}

cols <- unlist(strsplit(output_cols, ","))
result <- select(db, keys=ids, keytype=id_type, columns=cols)
write.table(result, file="/tmp/tmpY5XREO/files/000/dataset_4.dat", sep="\t", row.names=FALSE, quote=FALSE)