Skip to content

Invert BWT

Felipe A. Louza edited this page Jun 26, 2020 · 1 revision

Invert BWT

Given the BWT computed for INPUT, stored as INPUT.bwt:

./gsufsort dataset/example.txt --sa --bwt
## gsufsort ##
## store_to_disk ##
example.txt.bwt	19 bytes (n = 19)

We can invert the BWT with option --ibwt:

./gsufsort dataset/example.txt.bwt --ibwt

The result is stored in INPUT.ibwt, which can be compared with the orignal file:

diff -s dataset/example.txt.ibwt dataset/example.txt
Files dataset/example.txt.ibwt and dataset/example.txt are identical

Fasta files:

For fasta files, one can compare INPUT.ibwt using the commands:

awk '!/^>/ { printf "%s", $0; n = "\n" } /^>/ { print n $0; n = "" } END { printf "%s", n }' INPUT | sed '/^>/d' - | diff INPUT.ibwt -

Fastq files:

For fastq files, one can compare INPUT.ibwt using the commands:

sed -n 2~4p INPUT | diff INPUT.ibwt -
Clone this wiki locally