| 10 | 1 #Setup R error handling to go to stderr | 
|  | 2 options( show.error.messages = FALSE, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) | 
|  | 3 | 
|  | 4 # we need that to not crash galaxy with an UTF8 error on German LC settings. | 
|  | 5 Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") | 
|  | 6 | 
|  | 7 suppressMessages(library('getopt')) | 
|  | 8 | 
|  | 9 #get options, using the spec as defined by the enclosed list. | 
|  | 10 #we read the options from the default: commandArgs(TRUE). | 
|  | 11 spec = matrix(c( | 
|  | 12     'help' , 'h', 0, "logical", | 
|  | 13     'input', 'i', 1, "character", | 
|  | 14     'transcript', 't', 1, "character", | 
|  | 15     'method', 'm', 2, "character", | 
|  | 16     'cutoff', 'c', 2, "double", | 
|  | 17     'type', 'p', 2, "character", | 
|  | 18     'output', 'o', 1, "character" | 
|  | 19 ), byrow=TRUE, ncol=4); | 
|  | 20 | 
|  | 21 opt = getopt(spec); | 
|  | 22 | 
|  | 23 suppressMessages(require(RNAprobR)) | 
|  | 24 | 
|  | 25 #Read and convert input to GRanges object | 
|  | 26 data <- read.table(opt$input, header = TRUE) | 
|  | 27 dataGR <- norm_df2GR(data) | 
|  | 28 | 
|  | 29 #Check if given transcript exists in input file | 
|  | 30 if ( ! opt$transcript %in% data$RNAid ) { stop("Transript not found. Check input file.") } | 
|  | 31 | 
|  | 32 pdf(opt$output) | 
|  | 33 for (method in strsplit(opt$method, ",")[[1]] ) { | 
|  | 34 | 
|  | 35     #Check if columns exists in data file | 
|  | 36     if (! method %in% colnames(data)) { next } | 
|  | 37 | 
|  | 38     plotRNA(dataGR, opt$transcript, method, stat_cutoff = opt$cutoff, type = opt$type, | 
|  | 39         main=paste(opt$transcript,": ", method, sep="")) | 
|  | 40 } | 
|  | 41 dev.off() |