File: SAModify.cpp

package info (click to toggle)
blasr 5.3%2B0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,064 kB
  • sloc: cpp: 13,753; ansic: 614; python: 314; makefile: 237; xml: 201; sh: 72
file content (77 lines) | stat: -rw-r--r-- 1,790 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <vector>
#include <string>
#include "NucConversion.hpp"
#include "FASTASequence.hpp"
#include "FASTAReader.hpp"
#include "suffixarray/SuffixArray.hpp"
#include "suffixarray/SuffixArrayTypes.hpp"
#include "suffixarray/ssort.hpp"
#include "algorithms/sorting/qsufsort.hpp"


void PrintUsage() {
    cout << "samodify changes word size of input suffix array." << endl;
	cout << "Usage: samodify in.sa genome.fasta out.sa [-blt p]" << endl;
	cout << "       -blt p  Build a lookup table on prefixes of length 'p' " << endl;
}

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

    if (argc < 4) {
        PrintUsage();
        exit(1);
    }
    int argi = 1;
    string saInFile = argv[argi++];
    string genomeFileName = argv[argi++];
    string saOutFile = argv[argi++];
    vector<string> inFiles;

    int doBLT = 0;
    int doBLCP = 0;
    int bltPrefixLength = 0;
    int lcpLength = 0;
    int parsingOptions = 0;

    while (argi < argc) {
        if (strcmp(argv[argi], "-blt") == 0) {
            doBLT = 1;
            bltPrefixLength = atoi(argv[++argi]);
        }
        else if (strcmp(argv[argi], "-blcp") == 0) {
            doBLCP = 1;
            lcpLength = atoi(argv[++argi]);
        }
        else {
            PrintUsage();
            cout << "Bad option: " << argv[argi] << endl;
            exit(1);
        }
        ++argi;
    }

    //
    // Read the suffix array to modify.
    //

    DNASuffixArray  sa;
    sa.Read(saInFile);

    FASTAReader reader;
    reader.Initialize(genomeFileName);
    FASTASequence seq;
    reader.ReadAllSequencesIntoOne(seq);


    if (doBLT) {
        sa.BuildLookupTable(seq.seq, seq.length, bltPrefixLength);
    }

    if (doBLCP) {
        cout << "LCP Table not yet implemented." << endl;
    }

    sa.Write(saOutFile);

}