0

Similar problem as here How to redirect output from file to stdout? However, the solution given there is not universal.

My problem: I have a command that produces output to STDOUT. At the same time, I can specify via arguments to produce another output that goes straight to a file.

tcsh$ hmmscan --domtblout FILEOUTPUT Pfam-A.hmm query.fasta

Pfam-A.hmm is a database file (input); query.fasta is also an input file

How can I redirect FILEOUTPUT to STDOUT ?

Background: I plan to use the command on thousands of inputs and I need to run it for each of them separately. The command is called within a Python script, and I would like to read its FILEOUTPUT directly into the memory/a variable using the subprocess module. I know how to get the STDOUT with the subprocess module; so if I could redirect FILEOUTPUT to STDOUT...

I tried already stuff like this (ended up with errors or created files):

tcsh$ hmmscan --domtblout >/dev/tty Pfam-A.hmm query.fasta
tcsh$ hmmscan --domtblout >(mypipe) Pfam-A.hmm query.fasta
tcsh$ hmmscan --domtblout >$ Pfam-A.hmm query.fasta
tcsh$ hmmscan --domtblout >($1) Pfam-A.hmm query.fasta
tcsh$ hmmscan --domtblout >cat Pfam-A.hmm query.fasta
tcsh$ hmmscan --domtblout test.tab Pfam-A.hmm query.fasta >/dev/tty
  • 1
    there's a tcsh in your prompt string; does the solution need to work in tcsh, or were those just sample runs, while your code would be called from python (to /bin/sh, presumably)? – Jeff Schaller Oct 23 '18 at 0:12
0

To make the hmmscan program write to stdout instead of a regular file, specify /dev/stdout instead of the regular filename. e.g.

$ hmmscan --domtblout /dev/stdout Pfam-A.hmm query.fasta

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.