[Biopython-dev] Bio.File

Peter Cock p.j.a.cock at googlemail.com
Wed Sep 7 10:36:43 EDT 2011


On Wed, Sep 7, 2011 at 2:53 PM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
> Hi all,
>
> Bio.File makes three classes available:
> Bio.File.UndoHandle
> Bio.File.StringHandle (which simply points to StringIO.StringIO)
> Bio.File.SGMLStripper (which has a pending deprecation warning)
>
> Bio.File.StringHandle is currently used only in
> Bio.Blast.NCBIStandalone and Bio.ParserSupport,
> both of which now have a pending deprecation warning.

We can just switch them to use StringIO directly, and immediately
deprecate Bio.File.StringHandle.

We can probably deprecate SGMLStripper now as well (which
means indirectly deprecating the bit of Bio.ParserSupport
which uses it).

> Bio.File.UndoHandle is used in three modules that now have a
> pending deprecation warning (Bio.Blast.NCBIStandalone,
> Bio.ParserSupport, Bio.UniGene.UniGene), as well as in
> Bio.SCOP.__init__. I don't know why the UndoHandle is
> used in that module; the relevant code looks like this:
>
> def _open(cgi, params={}, get=1):
>    ...
>    handle = urllib.urlopen(cgi, options)
>    uhandle = File.UndoHandle(handle)
>    return uhandle
>
> If there is no pressing reason for using File.UndoHandle here
> and we can remove it, then we could add a
> PendingDeprecationWarning to Bio.File.

Unless there is something similar in the standard library,
I think the UndoHandle is still useful.

UndoHandle used to be used in Bio.Entrez for spotting error
conditions, but now we trust the NCBI to set an HTTP return
code:

https://github.com/biopython/biopython/commit/2c4d8b99fc1b2dffa726e7d9956d766f7013164d

I'm using the same trick in my TogoWS wrapper (something
I'm hoping will be ready to include in the next Biopython,
once the TogoWS team have fixed a couple of server side
issues). If the server could be relied on to always give an
HTTP error code this wouldn't be needed:

https://github.com/peterjc/biopython/blob/togows/Bio/TogoWS/__init__.py

I imagine the use of an UndoHandle in SCOP search was
to allow the user to make similar sanity checks.

Peter



More information about the Biopython-dev mailing list