Debian Codegraph @

SeqLib/RefGenome.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #ifndef SEQLIB_REF_GENOME_H
2 #define SEQLIB_REF_GENOME_H
3
4 #include <string>
5 #include <cstdlib>
6 #include <iostream>
7
•8 #include <htslib/faidx.h>
9
10 namespace SeqLib {
11
12 /** Stores an indexed reference genome
13 *
14 * RefGenome is currently used as an interface to obtain
15 * sequences from the reference given an interval.
16 */
17 class RefGenome {
18
19 public:
20
21 /** Create an empty RefGenome object */
22 RefGenome() { index = NULL; }
23
24 /** Destroy the malloc'ed faidx_t index inside object */
25 ~RefGenome() { if (index) fai_destroy(index); }
26
27 /** Query a region to get the sequence
28 * @param chr_name name of the chr to query
29 * @param p1 position 1. Zero-based
30 * @param p2 position 2. Zero-based
31 *
32 * @exception Throws an invalid_argument if p1 > p2, p1 < 0, p2 < 0, chr not found, or seq not found
33 * @note This is currently NOT thread safe
34 */
35 std::string QueryRegion(const std::string& chr_name, int32_t p1, int32_t p2) const;
36
37 /** Load an indexed reference sequence
38 * @param file Path to an indexed reference genome. See samtools faidx to create
39 * @return True if succesfully loaded
40 */
41 bool LoadIndex(const std::string& file);
42
43 /** Check if reference has been loaded */
44 bool IsEmpty() const {
45 return (index == NULL);
46 }
47
48 private:
49
50 faidx_t * index;
51
52 };
53
54
55 }
56
57 #endif