[Biopython] [Biopython-dev] Saving a Trie
Peter Cock
p.j.a.cock at googlemail.com
Wed Jul 31 21:59:21 UTC 2013
On Wednesday, July 31, 2013, Rishi Sharma wrote:
> Hello,
>
> I was was wondering how i might write a Trie to file. It doesn't seem to
> have a write() method so pickling won't work. I'm not sure how the
> biopython save is intended to work, so I guess that is what I'm asking.
>
>
Hi Rishi,
You need to do something like this (untested - I'm not at a computer):
from Bio import trie
f = open("my-data.dat", "w")
tr = trie.trie()
#fill in the trie
trie.save(f, trie)
f.close()
And to read it back,
from Bio import trie
f = open('my-data.dat', 'r')
tr = trie.load(f)
f.close()
Peter
More information about the Biopython
mailing list