[Biopython] Alternatives to Bio.Application for invoking command line tools?
Peter Cock
p.j.a.cock at googlemail.com
Tue May 12 13:17:45 UTC 2020
Thanks Stephane,
If you mean you'd prefer to rely on the standard library (e.g. subprocess)
over a third party dependency (like sh or plumbum or anything else), I
understand that. We've been cautious about adding extra dependencies to
Biopython, so it would have to be a compelling use case.
The Biopython Tutorial already uses subprocess heavily for all our examples
piping stdin/stdout. Working out how to do this can be tricky, so the
examples help. Piping this way generally works fine, but when something
fails (e.g. a malformed input), it becomes harder to debug than using
temporary intermediate files. I don't yet see any reason to change those
examples using subprocess.
My point was subprocess does not help build up the command line - you must
give it the command line string, or a list of arguments. Doing this "by
hand" is fine for simple cases, and string templates or carefully
constructed f-strings would cover most things elegantly.
Peter
P.S. I've opened an issue on GitHub as an easier long term way to track
this discussion and any conclusions from it:
https://github.com/biopython/biopython/issues/2877
On Mon, May 11, 2020 at 8:50 PM Stéphane Téletchéa <
stephane.teletchea at univ-nantes.fr> wrote:
> Dear all,
>
> I was about to say the same, my preference for my own projects is always
> to try to rely on upstream development as much as possible, so
> subprocess it the recommandation.
>
> Concerning the pipes, isn't subprocess meant for that already?
>
> According to the doc (https://docs.python.org/3/library/subprocess.html)
> and some answers in stack overflow
> (
> https://stackoverflow.com/questions/13332268/how-to-use-subprocess-command-with-pipes),
>
> it should.
>
> Would you have some examples so we can try what is problematic (one/two
> basic cases)?
>
> And yes, thanks for asking for comments :-)
>
> Stéphane
>
> Le 10/05/2020 à 19:09, Peter Cock a écrit :
> > Yes, subprocess is very powerful but tricky.
> >
> > Sadly it doesn't help with giving a nice syntax for building command
> > lines, which for me was the main thing our Bio.Application framework
> > added. Perhaps someone else on the list will have a good suggestion.
> >
> > Peter
>
> --
> Assistant Professor, UFIP, UMR 6286 CNRS, Team Protein Design In Silico
> UFR Sciences et Techniques, 2, rue de la Houssinière, Bât. 25, 44322
> Nantes cedex 03, France
> Tél : +33 251 125 636 / Fax : +33 251 125 632
> http://www.ufip.univ-nantes.fr/ - http://www.steletch.org
>
> _______________________________________________
> Biopython mailing list - Biopython at mailman.open-bio.org
> https://mailman.open-bio.org/mailman/listinfo/biopython
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20200512/0cf42fbf/attachment.htm>
More information about the Biopython
mailing list