# HG changeset patch # User sblanck # Date 1491983094 14400 # Node ID 2c9e44ff68dc3d49480a6f42ddbbf4cfb7be9554 # Parent b01c4f2600855aa5c5fffc803fa47bb4afc5814e use optparse diff -r b01c4f260085 -r 2c9e44ff68dc GEOQuery.R --- a/GEOQuery.R Wed Apr 12 03:44:02 2017 -0400 +++ b/GEOQuery.R Wed Apr 12 03:44:54 2017 -0400 @@ -1,17 +1,40 @@ +#!/usr/bin/env Rscript +# setup R error handling to go to stderr +options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) -library(GEOquery) +# we need that to not crash galaxy with an UTF8 error on German LC settings. +loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") + +library("optparse") - -cargs<-commandArgs() -cargs<-cargs[(which(cargs=="--args")+1):length(cargs)] +##### Read options +option_list=list( + make_option("--id",type="character",default=NULL,help="GSE ID from GEO databse (required)"), + make_option("--transformation",type="character",default=NULL,help="log2 transformation (required)"), + make_option("--data",type="character",default=NULL,help="A table containing the expression data"), + make_option("--rdata",type="character",default="NULL",help="rdata object containing eset object"), + make_option("--conditions",type="character",default=NULL,help="Text file summarizing conditions of the experiment") + +); -GEOQueryID<-cargs[[1]] -GEOQueryData<-cargs[[2]] -GEOQueryRData<-cargs[[3]] -conditionFile<-cargs[[4]] -transformation<-cargs[[5]] +opt_parser = OptionParser(option_list=option_list); +opt = parse_args(opt_parser); + +if(is.null(opt$id)){ + print_help(opt_parser) + stop("GEOdata id required.", call.=FALSE) +} -data1 = getGEO(GEOQueryID) +#loading libraries +suppressPackageStartupMessages(require(GEOquery)) + +GEOQueryID=opt$id +GEOQueryData=opt$data +GEOQueryRData=opt$rdata +conditionFile=opt$conditions +transformation=opt$transformation + +data1=getGEO(GEOQueryID) eset=data1[[1]] #check if datas are in log2 space