[Biopython] Extracting data genpept files

Peter biopython at maubp.freeserve.co.uk
Tue Nov 23 09:09:57 EST 2010


On Tue, Nov 23, 2010 at 1:27 PM, Ara Kooser <akooser at unm.edu> wrote:
> Peter,
>
> I would like the whole taxonomy to go into one column but couldn't figure
> out how to do that.
>
> ...
>
> I wanted to use tabs but here again wasn't sure of how to code that. Commas
> have been my bane while trying to write this code.

I'd suggest writing the taxonomy in a single column, space separated.
You can do that with the python string join method. For example, if
taxonomy_list is a list of strings, use:

taxonomy_str = " ".join(taxonomy_list)

Regarding tabs, use slash t to get a tab in Python, e.g. "\t", or:

name = "Test"
x = 10
y = -5
handle = open("example.tsv", "w")
handle.write("%s\t%i\t%i\n" % (name, x, y))
handle.close()

Peter


More information about the Biopython mailing list