[Biopython] [Biopython-dev] Saving a Trie
Rishi Sharma
sharma409 at gmail.com
Wed Jul 31 22:05:40 UTC 2013
Ah yes this worked. I was doing something stupid by importing trie from
Bio.trie and confusing myself between the module and the method.
Thank you!
On Wed, Jul 31, 2013 at 2:59 PM, Peter Cock <p.j.a.cock at googlemail.com>wrote:
>
> 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