BWT any suggestions to improve this?

279 views
Skip to first unread message

Dan Kortschak

unread,
Oct 9, 2013, 2:37:32 AM10/9/13
to golan...@googlegroups.com
I was just having a play implementing a simple BWT code.

Here's what I came up with: http://play.golang.org/p/coOUXB_g07

Any suggestions to improve this?

Dan

Dan Kortschak

unread,
Oct 9, 2013, 8:50:26 AM10/9/13
to Dan Kortschak, golan...@googlegroups.com

Ingo Oeser

unread,
Oct 13, 2013, 7:04:46 PM10/13/13
to golan...@googlegroups.com, Dan Kortschak
Hi Dan,

On Wednesday, October 9, 2013 2:50:26 PM UTC+2, kortschak wrote:
A little more polish: http://play.golang.org/p/HV2DFUyHkY

You can fold the equality into the else path, because you already return true, after the if triggers 
and the compare won't change the result anymore.


Best Regards

Ingo

Ingo Oeser

unread,
Oct 13, 2013, 7:13:03 PM10/13/13
to golan...@googlegroups.com, Dan Kortschak
It get's even more simple:

Dan Kortschak

unread,
Oct 13, 2013, 7:25:52 PM10/13/13
to Ingo Oeser, golan...@googlegroups.com
Yeah, I've been working on it, but not sending here. It gets even
simpler - something I have from last week:

http://play.golang.org/p/kEi1PyS-Wh

Dan

Dan Kortschak

unread,
Oct 13, 2013, 7:29:36 PM10/13/13
to Ingo Oeser, golan...@googlegroups.com
And merging in some of the things you had:

http://play.golang.org/p/eLzHRXJosP

Dan Kortschak

unread,
Oct 13, 2013, 7:33:58 PM10/13/13
to Ingo Oeser, golan...@googlegroups.com
Now with added concision:

http://play.golang.org/p/yHn_4fDGPS

Robert Syme

unread,
Dec 16, 2013, 2:31:59 AM12/16/13
to golan...@googlegroups.com, Ingo Oeser
If you are happy to borrow from stdlib, the index/suffixarray package contains code that will generate a suffix array very quickly (n log n). The important functions are not exported, so they are copied in the example below.

Once you have the suffix array, it's not difficult to generate the bwt:
Reply all
Reply to author
Forward
0 new messages