[Biopython-dev] [Bug 2454] Iterators can't use file-like objects

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Jun 13 12:24:29 EDT 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2454





------- Comment #12 from mdehoon at ims.u-tokyo.ac.jp  2008-06-13 12:24 EST -------
(In reply to comment #11)
> Maybe it's a good idea for any parsers/iterators to just use the iterator-like
> ability of file handles?

In principle, yes. In practice, it's not so easy because many parsers in
Biopython follow the framework in Bio.ParserSupport. These parsers are not
really written to deal with lines pulled one-by-one from a file handle. To
reconcile these two, I pull out data line-by-line from the file handle, store
it in a string, and then call the parser to parse it. This is not ideal, and it
may be a good idea for Biopython at some point to change its parser strategy.

> Writers would have to function slightly differently,
> but since file objects, StringIOs and any other file-like objects must provide
> an __iter__ method, it's probably a good idea to take that into consideration
> when developing a common interface. In addition, writers could output 
> iterators or generators, so that they can be chained together to operate
> on files.
> 
Writers should also be able to just print the record to the screeen. I don't
see how that is easily achievable with generators. 


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


More information about the Biopython-dev mailing list