File: base.cpp

package info (click to toggle)
seqan2 2.3.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 222,320 kB
  • ctags: 40,872
  • sloc: cpp: 252,894; ansic: 86,805; python: 6,534; sh: 985; xml: 570; makefile: 236; awk: 51
file content (61 lines) | stat: -rw-r--r-- 1,746 bytes parent folder | download | duplicates (7)
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
//![build_index1]
//![open_index1]
#include <seqan/seq_io.h>
#include <seqan/sequence.h>

using namespace seqan;

int main()
{
    CharString pathToFile = getAbsolutePath("/demos/tutorial/indexed_fasta_io/example.fasta");
    FaiIndex faiIndex;

//![open_index1]
    if (!build(faiIndex, toCString(pathToFile)))
        std::cout << "ERROR: Could not build the index!\n";
//![build_index1]
    clear(faiIndex);
//![build_index2]
    CharString pathToFaiFile = pathToFile;
    append(pathToFaiFile, ".fai");
    if (!build(faiIndex, toCString(pathToFile), toCString(pathToFaiFile)))
        std::cout << "ERROR: Could not build the index!\n";
//![build_index2]

//![save_index]
    if (!save(faiIndex, toCString(pathToFaiFile)))
        std::cout << "ERROR: Could not save the index to file!\n";
//![save_index]

//![open_index1]
    if (!open(faiIndex, toCString(pathToFile)))
        std::cout << "ERROR: Could not load FAI index " << pathToFile << ".fai\n";
//![open_index1]

//![open_index2]
    if (!open(faiIndex, toCString(pathToFile), toCString(pathToFaiFile)))
        std::cout << "ERROR: Could not load FAI index " << pathToFaiFile << "\n";
//![open_index2]

//![idx]
    unsigned idx = 0;
    if (!getIdByName(idx, faiIndex, "chr1"))
        std::cout << "ERROR: FAI index has no entry for chr1.\n";
//![idx]

//![example_functions]
    unsigned seqLength = sequenceLength(faiIndex, idx);

    // Load first 10 characters of chr1.
    CharString seqChr1Prefix;
    readRegion(seqChr1Prefix, faiIndex, idx, 0, 10);

    // Load all of chr1.
    CharString seqChr1;
    readSequence(seqChr1, faiIndex, idx);
//![example_functions]
    ignoreUnusedVariableWarning(seqLength);
//![example_functions]
    return 0;
}
//![example_functions]