routputsuppresssuppressmessage

How to suppress RED progress messages that are not warning messages? SOLUTIONS NOT WORKING


I have a script and in that script I am running a command form a package: proteinToGenome() from the ensembldb package.

I run the command iteratively using a for () {} structure, and upon each iteration it will return RED output that is more of "progress" messages that output regardless of the success/failure of the command, not warning messages:

Checking CDS and protein sequence lengths ... 1/1 OK

Fetching CDS for 1 proteins ... 1 found

or:

Fetching CDS for 1 proteins ... 1 found

Checking CDS and protein sequence lengths ... 0/0 OK

How do I suppress these messages? Other questions I found do not seem to apply to these and their solutions do not seem to stop these. I have tried all the solutions presented in:

Suppress output of a function

I have tired:

capture.output(for (x in length(DF)) { 
        OutputDF <- function(DF[x])
})

and:

sink(for (x in length(DF)) { 
        OutputDF <- function(DF[x])
})

also tried:

hush=function(code){
  sink("NUL") # use /dev/null in UNIX
  tmp = code
  sink()
  return(tmp)
}
hush(for (x in length(DF)) { 
        OutputDF <- function(DF[x])
})

also, the reason I use for and not lapply() is because I check whether or not the OutputDF is empty, and take action accordingly using an if(){}else{} command within the for(){} loop


Solution

  • How about:

    suppressMessages(proteinToGenome(...))
    

    Where the arguments you are using in the model replace ...