forked from brentp/hileup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhile.h
104 lines (92 loc) · 2.32 KB
/
hile.h
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef HILE_H
#define HILE_H
#include "htslib/vcf.h"
#include "htslib/sam.h"
#include "htslib/hts.h"
#include "stdint.h"
#include "stdio.h"
#include "string.h"
#include "stdbool.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* config_t determines which reads and bases are added to the
* pileup. It should be created with `hile_init_config`
*/
typedef struct {
uint8_t min_mapping_quality;
uint8_t min_base_quality;
uint16_t exclude_flags;
uint16_t include_flags;
bool track_read_names;
bool track_reads;
bool track_base_qualities;
bool track_mapping_qualities;
// BAQ https://doi.org/10.1093/bioinformatics/btr076
// uses sam_prob_realn in htslib
//bool adjust_base_quality;
char tags[4]; // track up to 2 tags.
} hile_config_t;
/*
* hile_deletion_t holds the length of the event.
* the `index` allows lookup into the hile struct
* bases,read_names,etc that this event follows.
*/
typedef struct {
uint32_t index;
uint32_t length;
} hile_deletion_t;
/*
* hile_insertion_t holds the length of the event.
* the `index` allows lookup into the hile struct
* bases,read_names,etc that this event follows.
*/
typedef struct {
uint32_t index;
char *sequence;
uint32_t length;
} hile_insertion_t;
/*
* hile_basestrand_t holds the base (A/C/G/T) and
* the strand in a single uint8
*/
typedef struct {
uint8_t reverse_strand:1, base: 7;
} hile_basestrand_t;
/*
* hile tracks the "pileup at a single
* genomic location
*/
typedef struct {
uint32_t pos;
char reference_base;
hile_basestrand_t *bases;
uint32_t n;
uint32_t cap;
uint8_t *bqs;
uint8_t *mqs;
char **read_names;
bam1_t **reads;
char **tags;
hile_insertion_t *insertions;
uint32_t n_insertions;
hile_deletion_t *deletions;
uint32_t n_deletions;
} hile;
/*
* create a hile for the given genomic position and config
* the user is responsible for freeing the returned hile
* using `hile_destroy`
*/
hile *hileup(htsFile *htf, bam_hdr_t *hdr, hts_idx_t *idx, const char *chrom, int position, hile_config_t *cfg, char ignore_base);
/* free all memory from the given hile struct, including the insertion sequences */
void hile_destroy(hile *h);
/* initialize a config struct with sane defaults */
hile_config_t hile_init_config(void);
/* get the qpos (stored in the id field); */
int qpos(bam1_t *b);
#ifdef __cplusplus
}
#endif
#endif