It worked! So this is how handlers work. I remember somewhere I read that you always have to close the handler too, so I know why u use the last statement too. You wrap it and then you unwrap it.
Thanks Gurado :D
Question: Simple Fasta Parsing Is Not Simple. |
||
2
|
When trying out the examples from chapter 2.3 of the biopython 1.54b tutorial I keep running into this very annoying problem: When I use:
The Python interpreter tells me I should use a handle in stead of filenames. I use biopython 1.53 and not 1.54b for which this tutorial was meant. I can't find an older archived version of the tutorial I could use to help me learn how to use a handle in stead of the simple filename method (ls_orchid.fasta in this case.). I know that in older versions of biopython you have to do everything in handlers but not in the newer versions. The new tutorial now on-line has an obscure last chapter on how to use handlers but that's hardly helpfull. I think the tutorial is great, I just havent got the right version installed. I use Ubuntu and downloaded biopython via ubuntu software center. Can anyone help me use a handler and get the above parsing example working in 1.53? Thank you, |
|
|
| ||
2
|
Others have already shown some explicit examples of how to use a handle - and the tutorial has been updated to try and make this clearer for Biopython 1.54. You also asked where to find older copies of the tutorial, they are included in the .zip or .tar.gz archives of Biopython on our downloads page. For Biopython 1.53 try: http://biopython.org/DIST/biopython-1.53.zip http://biopython.org/DIST/biopython-1.53.tar.gz Hope that helps. |
|
|
| ||
4
|
The tutorial you are reading describes a feature that has been introduced in biopython 1.54. With all the earlier versions, SeqIO required a file-like handler as the first argument, so you had to do something like SeqIO.parse(open("seq.fasta", "r"), "fasta") as explained in the other answers. Starting from biopython 1.54, SeqIO.parse can accept either a file handler or a filename as argument, so SeqIO.parse("ls_orchid.fasta", "fasta") works correctly. I'll notify the biopython's devs to add a note to this in the current tutorial, it may be useful to somebody else. |
|