File: BwtToSuffixArray.cpp

package info (click to toggle)
blasr 5.3.5%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,196 kB
  • sloc: cpp: 8,412; ansic: 806; python: 331; sh: 178; java: 158; makefile: 36
file content (30 lines) | stat: -rw-r--r-- 811 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <cstring>
#include <iostream>
#include <string>

#include <alignment/bwt/BWT.hpp>
#include <alignment/suffixarray/SuffixArray.hpp>
#include <alignment/suffixarray/SuffixArrayTypes.hpp>

int main(int argc, char* argv[])
{

    std::string bwtFileName, saFileName;
    if (argc < 3) {
        std::cout << "usage: bwt2sa bwtfile safile " << std::endl;
        std::exit(EXIT_FAILURE);
    }
    bwtFileName = argv[1];
    saFileName = argv[2];

    Bwt<PackedDNASequence, FASTASequence> bwt;
    DNASuffixArray suffixArray;

    bwt.Read(bwtFileName);
    suffixArray.AllocateSuffixArray(bwt.bwtSequence.length - 1);
    SAIndex index;
    for (index = 1; index < bwt.bwtSequence.length + 1; index++) {
        suffixArray.index[index - 1] = bwt.Locate(index);
    }
    suffixArray.Write(saFileName);
}