I am working on incorporating a program (samtools) into a pipeline. FYI samtools is a program used to manipulate DNA sequence alignments that are in a SAM format. It takes input and generates an output file via stdin and stdout, so it is quite easily controlled via pythons subprocess.Popen().
When it runs, it also outputs short messages to the console - not using stdout, obviously - and I wonder if it would be possible to catch these as well - potentially by getting a os generated handler list?
I guess my question in general is if it is possible to catch a programs console output if it is not coming from stdout? Thank you.
There is no other console output than stdout and stderr (assuming that samtools does not write to the terminal directly via a tty device). So, if the output is not captured with the subprocesses stdout, it must have been written to stderr, which can be captured as well using Popen()
with stderr=subprocess.PIPE
and inspecting the stderr
attribute of the resulting process object.