[Biopython] Unix pipes and APIs like NcbiblastxCommandline()

Peter Cock p.j.a.cock at googlemail.com
Tue Oct 21 21:17:47 UTC 2014


Hi Ivan,

The BLAST+ tools default to using stdout for output
if you do not give a filename.

There are some examples in the Biopython tutorial
using MUSCLE with stdout - the same would apply.
i.e. Try using the command line wrapper to run the
command which returns stdout and stderr as strings
(all in memory - not suitable for large data), or use
the Python subprocess module directly for a handle
(more memory efficient but more complicated).

Peter

On Tue, Oct 21, 2014 at 9:56 PM, Ivan Gregoretti <ivangreg at gmail.com> wrote:
> Hello everybody
>
> Can somebody suggest a way to run an API like NcbiblastxCommandline()
> but directing the output to standard output?
>
> For instance, this is the conventional execution with output directed
> to a file, in this case opuntia.csv:
>
> from Bio.Blast.Applications import NcbiblastxCommandline
> blastx_cline = NcbiblastxCommandline("/mnt/shared/ncbi-blast-2.2.29+/blastx",
> query="opuntia.fasta", db="nr", evalue=0.001, outfmt=10,
> out="opuntia.csv")
>
> Now, what I would like to know is how to run this API with something like
>
> out="/dev/stdout" instead of out="opuntia.csv".
>
> In other words, I seek to avoid the creation of opuntia.csv.
>
> Optional context:
>
> I can currently execute local blast from within Python and direct its
> output to a pipe (i.e. subprocess.Popen...). I am now interested in
> trying the API way as it is likely to be more robust than my
> implementation and already tested by a very large number of users.
>
> Thank you,
>
> Ivan
>
>
>
> Ivan Gregoretti, PhD
> Bioinformatics
> _______________________________________________
> Biopython mailing list  -  Biopython at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython


More information about the Biopython mailing list