| 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 |
#ifndef BAM2BCF_H |
| 27 |
#define BAM2BCF_H |
| 28 |
|
| 29 |
#include <stdint.h> |
| 30 |
#include <htslib/hts.h> |
| 31 |
#include <htslib/vcf.h> |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
#ifndef CDF_MWU_TESTS |
| 41 |
#define CDF_MWU_TESTS 0 |
| 42 |
#endif |
| 43 |
|
| 44 |
#define B2B_INDEL_NULL 10000 |
| 45 |
|
| 46 |
#define B2B_FMT_DP (1<<0) |
| 47 |
#define B2B_FMT_SP (1<<1) |
| 48 |
#define B2B_FMT_DV (1<<2) |
| 49 |
#define B2B_FMT_DP4 (1<<3) |
| 50 |
#define B2B_FMT_DPR (1<<4) |
| 51 |
#define B2B_INFO_DPR (1<<5) |
| 52 |
#define B2B_FMT_AD (1<<6) |
| 53 |
#define B2B_FMT_ADF (1<<7) |
| 54 |
#define B2B_FMT_ADR (1<<8) |
| 55 |
#define B2B_INFO_AD (1<<9) |
| 56 |
#define B2B_INFO_ADF (1<<10) |
| 57 |
#define B2B_INFO_ADR (1<<11) |
| 58 |
#define B2B_INFO_SCR (1<<12) |
| 59 |
#define B2B_FMT_SCR (1<<13) |
| 60 |
#define B2B_INFO_VDB (1<<14) |
| 61 |
#define B2B_FMT_QS (1<<15) |
| 62 |
#define B2B_FMT_NMBZ (1<<16) // per-sample NMBZ |
| 63 |
#define B2B_INFO_NMBZ (1<<17) |
| 64 |
#define B2B_INFO_BQBZ (1<<18) |
| 65 |
#define B2B_INFO_MQBZ (1<<19) |
| 66 |
#define B2B_INFO_MQSBZ (1<<20) |
| 67 |
#define B2B_INFO_RPBZ (1<<21) |
| 68 |
#define B2B_INFO_SCBZ (1<<22) |
| 69 |
#define B2B_INFO_SGB (1<<23) |
| 70 |
#define B2B_INFO_MIN_PL_SUM (1<<24) |
| 71 |
#define B2B_INFO_NM (1<<25) |
| 72 |
#define B2B_INFO_MQ0F (1<<26) |
| 73 |
#define B2B_INFO_IDV (1<<27) |
| 74 |
#define B2B_INFO_IMF (1<<28) |
| 75 |
#define B2B_INFO_FS (1<<29) |
| 76 |
|
| 77 |
#define B2B_MAX_ALLELES 5 |
| 78 |
#define B2B_N_NM 32 // number of NMBZ bins, i.e. max number of mismatches |
| 79 |
|
| 80 |
|
| 81 |
#define B2B_DROP 0 |
| 82 |
#define B2B_INC_AD 1 |
| 83 |
#define B2B_INC_AD0 2 |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
#define PLP_CD(x) ((plp_cd_t*)((x)->p)) |
| 88 |
#define PLP_HAS_SOFT_CLIP(cd) (PLP_CD(cd)->i & 1) |
| 89 |
#define PLP_HAS_INDEL(cd) (PLP_CD(cd)->i & 2) |
| 90 |
#define PLP_IS_REALN(cd) (PLP_CD(cd)->i & 4) |
| 91 |
#define PLP_SAMPLE_ID(cd) (PLP_CD(cd)->i >> 3) |
| 92 |
#define PLP_QLEN(cd) (PLP_CD(cd)->qlen) |
| 93 |
#define PLP_NM(cd) (PLP_CD(cd)->nm) |
| 94 |
#define PLP_NM_UNSET -2 |
| 95 |
|
| 96 |
#define PLP_SET_SOFT_CLIP(cd) (PLP_CD(cd)->i |= 1) |
| 97 |
#define PLP_SET_INDEL(cd) (PLP_CD(cd)->i |= 2) |
| 98 |
#define PLP_SET_REALN(cd) (PLP_CD(cd)->i |= 4) |
| 99 |
#define PLP_SET_SAMPLE_ID(cd,n) (PLP_CD(cd)->i |= (n)<<3) |
| 100 |
|
| 101 |
typedef struct |
| 102 |
{ |
| 103 |
int64_t i; |
| 104 |
uint32_t qlen; |
| 105 |
int nm; |
| 106 |
} |
| 107 |
plp_cd_t; |
| 108 |
|
| 109 |
|
| 110 |
typedef struct __bcf_callaux_t { |
| 111 |
int fmt_flag, ambig_reads; |
| 112 |
int capQ, min_baseQ, max_baseQ, delta_baseQ; |
| 113 |
int openQ, extQ, tandemQ; |
| 114 |
uint32_t min_support, max_support; |
| 115 |
double min_frac; |
| 116 |
float max_frac; |
| 117 |
int per_sample_flt; |
| 118 |
int *ref_pos, *alt_pos, npos, *ref_mq, *alt_mq, *ref_bq, *alt_bq, *fwd_mqs, *rev_mqs, nqual; |
| 119 |
int *iref_pos, *ialt_pos, *iref_mq, *ialt_mq; |
| 120 |
int ref_scl[100], alt_scl[100]; |
| 121 |
int iref_scl[100], ialt_scl[100]; |
| 122 |
|
| 123 |
int max_bases; |
| 124 |
int indel_types[4]; |
| 125 |
int indel_win_size, indels_v20, edlib; |
| 126 |
int seqQ_offset; |
| 127 |
int maxins, indelreg, poly_mqual; |
| 128 |
int read_len; |
| 129 |
char *inscns; |
| 130 |
uint16_t *bases; |
| 131 |
errmod_t *e; |
| 132 |
void *rghash; |
| 133 |
float indel_bias; |
| 134 |
float del_bias; |
| 135 |
float vs_ref; |
| 136 |
int32_t *ref_nm, *alt_nm; |
| 137 |
unsigned int nnm[2]; |
| 138 |
float nm[2]; |
| 139 |
void *iaux; |
| 140 |
char *chr; |
| 141 |
} bcf_callaux_t; |
| 142 |
|
| 143 |
|
| 144 |
typedef struct { |
| 145 |
uint32_t ori_depth; |
| 146 |
unsigned int mq0; |
| 147 |
int32_t *ADF, *ADR, SCR, *QS; |
| 148 |
int32_t *ref_nm, *alt_nm; |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
double anno[16]; |
| 162 |
float p[25]; |
| 163 |
} bcf_callret1_t; |
| 164 |
|
| 165 |
|
| 166 |
typedef struct { |
| 167 |
int tid, pos; |
| 168 |
bcf_hdr_t *bcf_hdr; |
| 169 |
int a[5]; |
| 170 |
float qsum[B2B_MAX_ALLELES]; |
| 171 |
int n, n_alleles, ori_ref, unseen; |
| 172 |
int32_t shift; |
| 173 |
int n_supp; |
| 174 |
double anno[16]; |
| 175 |
unsigned int depth, ori_depth, mq0; |
| 176 |
int32_t *PL, *DP4, *ADR, *ADF, *SCR, *QS, *ref_nm, *alt_nm; |
| 177 |
uint8_t *fmt_arr; |
| 178 |
float vdb; |
| 179 |
float mwu_pos, mwu_mq, mwu_bq, mwu_mqs, mwu_sc, *mwu_nm, nm[2]; |
| 180 |
float seg_bias; |
| 181 |
float strand_bias; |
| 182 |
kstring_t tmp; |
| 183 |
} bcf_call_t; |
| 184 |
|
| 185 |
|
| 186 |
#ifdef __cplusplus |
| 187 |
extern "C" { |
| 188 |
#endif |
| 189 |
|
| 190 |
bcf_callaux_t *bcf_call_init(double theta, int min_baseQ, int max_baseQ, |
| 191 |
int delta_baseQ); |
| 192 |
void bcf_call_destroy(bcf_callaux_t *bca); |
| 193 |
int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t *bca, bcf_callret1_t *r); |
| 194 |
int bcf_call_combine(int n, const bcf_callret1_t *calls, bcf_callaux_t *bca, int ref_base , bcf_call_t *call); |
| 195 |
int bcf_call2bcf(bcf_call_t *bc, bcf1_t *b, bcf_callret1_t *bcr, int fmt_flag, |
| 196 |
const bcf_callaux_t *bca, const char *ref); |
| 197 |
int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_callaux_t *bca, const char *ref); |
| 198 |
int bcf_iaux_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_callaux_t *bca, const char *ref); |
| 199 |
int bcf_edlib_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, |
| 200 |
bcf_callaux_t *bca, const char *ref, int ref_len); |
| 201 |
|
| 202 |
void bcf_callaux_clean(bcf_callaux_t *bca, bcf_call_t *call); |
| 203 |
|
| 204 |
int bcf_cgp_l_run(const char *ref, int pos); |
| 205 |
int est_indelreg(int pos, const char *ref, int l, char *ins4); |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
int tpos2qpos(const bam1_core_t *c, const uint32_t *cigar, int32_t tpos, int is_left, int32_t *_tpos); |
| 217 |
|
| 218 |
|
| 219 |
void get_pos(const bcf_callaux_t *bca, bam_pileup1_t *p, |
| 220 |
int *sc_len_r, int *slen_r, int *epos_r, int *end); |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
char *bcf_cgp_calc_cons(int n, int *n_plp, bam_pileup1_t **plp, |
| 225 |
int pos, int *types, int n_types, |
| 226 |
int max_ins, int s); |
| 227 |
|
| 228 |
#ifdef __cplusplus |
| 229 |
} |
| 230 |
#endif |
| 231 |
|
| 232 |
#endif |