[Biopython-dev] Proposed addition to Standalone BLAST
Jeffrey Chang
jchang at SMI.Stanford.EDU
Tue Nov 7 17:47:51 EST 2000
> I use copy.deepcopy() to copy the handle
Are you sure you can copy file handles in this way? It's not working for
me using Python 2.0 on Solaris:
Python 2.0 (#1, Oct 17 2000, 12:05:31)
[GCC 2.8.1] on sunos5
Type "copyright", "credits" or "license" for more information.
>>> from Bio.Blast import NCBIStandalone
>>> parser = NCBIStandalone.BlastErrorParser()
>>> rec = parser.parse(open('bt001'))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/jchang/lib/jchang/pylib/Bio/Blast/NCBIStandalone.py", line
1578, in parse
copy_handle = copy.deepcopy(handle)
File "/home/jchang/lib/python2.0/copy.py", line 147, in deepcopy
raise error, \
copy.Error: un-deep-copyable object of type <type 'file'>
>>>
I'm trying to parse blast test bt001.
+ def __init__(self, bad_report_file = None):
+ """Initialize a parser that tries to catch BlastErrors.
+
+ Arguments:
+ o bad_report_file - An optional argument specifying a file to
+ write any reports that raise errors to. If not specified, these
+ reports will not be saved.
Can we make this function take a handle instead of the name of a file?
That would allow people to use sys.stderr, if they want the bad files to
go to STDERR. The tradeoff is that it would place the burden of creating
a handle on the client.
Another option is to allow people to pass in either a file name or a
handle. While I'm not crazy about this, there is at least one instance of
this in Python (see uu.py), and tabnanny.py has a function that takes the
name of either a file or directory. Perhaps this is a case of
practicality beating purity.
Jeff
More information about the Biopython-dev
mailing list