Emboss & Python : Suppress Printing Messages To Standard Output
3
0
Entering edit mode
12.7 years ago
Ncemami ▴ 10

I have a Python script running EMBOSS "needle" alignments using the os.system() command, and I find it unnecessary for it to print out:

(a) all error messages e.g.

Error: Sequence is not nucleic

(b) the standard "needle" message e.g.

Needleman-Wunsch global alignment of two sequences

Does anybody have a clean solution suppress these? Thanks in advance for your help.

python biopython output • 6.1k views
ADD COMMENT
5
Entering edit mode
12.7 years ago
Neilfws 49k

Have you read the documentation? There are some standard switches for all EMBOSS programs including:

General qualifiers:
-auto               boolean    Turn off prompts
-stdout             boolean    Write first file to standard output
-filter             boolean    Read first file from standard input, write
                              first file to standard output
-options            boolean    Prompt for standard and additional values
-debug              boolean    Write debug output to program.dbg
-verbose            boolean    Report some/full command line options
-help               boolean    Report command line options and exit. More
                              information on associated and general
                              qualifiers can be found with -help -verbose
-warning            boolean    Report warnings
-error              boolean    Report errors
-fatal              boolean    Report fatal errors
-die                boolean    Report dying program messages
-version            boolean    Report version number and exit

So in your case, -auto and -options will address issue (b) and some/all of -warning, -error, -fatal and -die will address issue (a).

ADD COMMENT
0
Entering edit mode

Hi newilfws,

Thank you for your suggesstions. I think the error problems were solved, but I am not having luck suppressing the standard output messages described in (b), as they are not exactly prompts. If you have any additional insight into this I would greatly appreciate it.

ADD REPLY
0
Entering edit mode

Hi newilfws, Thank you for your suggestions. I think the error problems were solved, but I am not having luck suppressing the standard output messages described in (b), as they are not exactly prompts. If you have any additional insight into this I would greatly appreciate it

ADD REPLY
0
Entering edit mode

Have you tried the -auto switch? I just ran needle from the command line using it and the "needle message" is not printed.

ADD REPLY
0
Entering edit mode

My bad, this totally works, I was confusing the invocation syntax with the NeedleCommandline biopython wrapper. Thanks!

ADD REPLY
1
Entering edit mode
12.7 years ago
Michael 55k

Maybe writing your system command like needle -params stuff > /dev/null? Dont't know if that python os.command handles it, but it works in shell.

ADD COMMENT
0
Entering edit mode

Hi Michael, thanks for the suggestion. I did try this initially, along with a couple other permutations ("&> /dev/null", "> nul", etc.) without any success. It seems that the "-auto" switch is successful in suppressing the standard output, though.

ADD REPLY
0
Entering edit mode
12.7 years ago
Peter 6.0k

You could use the NeedleCommandline object in Biopython for building the command line and executing it (It's in the Bio.Emboss.Applications module - see the tutorial http://biopython.org/DIST/docs/tutorial/Tutorial.html for an example).

ADD COMMENT

Login before adding your answer.

Traffic: 2005 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6