|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef BAM2BCF_H |
|
#define BAM2BCF_H |
|
|
|
#include <stdint.h> |
|
#include <htslib/hts.h> |
|
#include <htslib/vcf.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef CDF_MWU_TESTS |
|
#define CDF_MWU_TESTS 0 |
|
#endif |
|
|
|
#define B2B_INDEL_NULL 10000 |
|
|
|
#define B2B_FMT_DP (1<<0) |
|
#define B2B_FMT_SP (1<<1) |
|
#define B2B_FMT_DV (1<<2) |
|
#define B2B_FMT_DP4 (1<<3) |
|
#define B2B_FMT_DPR (1<<4) |
|
#define B2B_INFO_DPR (1<<5) |
|
#define B2B_FMT_AD (1<<6) |
|
#define B2B_FMT_ADF (1<<7) |
|
#define B2B_FMT_ADR (1<<8) |
|
#define B2B_INFO_AD (1<<9) |
|
#define B2B_INFO_ADF (1<<10) |
|
#define B2B_INFO_ADR (1<<11) |
|
#define B2B_INFO_SCR (1<<12) |
|
#define B2B_FMT_SCR (1<<13) |
|
#define B2B_INFO_VDB (1<<14) |
|
#define B2B_FMT_QS (1<<15) |
|
#define B2B_FMT_NMBZ (1<<16) |
|
#define B2B_INFO_NMBZ (1<<17) |
|
#define B2B_INFO_BQBZ (1<<18) |
|
#define B2B_INFO_MQBZ (1<<19) |
|
#define B2B_INFO_MQSBZ (1<<20) |
|
#define B2B_INFO_RPBZ (1<<21) |
|
#define B2B_INFO_SCBZ (1<<22) |
|
#define B2B_INFO_SGB (1<<23) |
|
#define B2B_INFO_MIN_PL_SUM (1<<24) |
|
#define B2B_INFO_NM (1<<25) |
|
#define B2B_INFO_MQ0F (1<<26) |
|
#define B2B_INFO_IDV (1<<27) |
|
#define B2B_INFO_IMF (1<<28) |
|
#define B2B_INFO_FS (1<<29) |
|
|
|
#define B2B_MAX_ALLELES 5 |
|
#define B2B_N_NM 32 |
|
|
|
|
|
#define B2B_DROP 0 |
|
#define B2B_INC_AD 1 |
|
#define B2B_INC_AD0 2 |
|
|
|
|
|
|
|
#define PLP_CD(x) ((plp_cd_t*)((x)->p)) |
|
#define PLP_HAS_SOFT_CLIP(cd) (PLP_CD(cd)->i & 1) |
|
#define PLP_HAS_INDEL(cd) (PLP_CD(cd)->i & 2) |
|
#define PLP_IS_REALN(cd) (PLP_CD(cd)->i & 4) |
|
#define PLP_SAMPLE_ID(cd) (PLP_CD(cd)->i >> 3) |
|
#define PLP_QLEN(cd) (PLP_CD(cd)->qlen) |
|
#define PLP_NM(cd) (PLP_CD(cd)->nm) |
|
#define PLP_NM_UNSET -2 |
|
|
|
#define PLP_SET_SOFT_CLIP(cd) (PLP_CD(cd)->i |= 1) |
|
#define PLP_SET_INDEL(cd) (PLP_CD(cd)->i |= 2) |
|
#define PLP_SET_REALN(cd) (PLP_CD(cd)->i |= 4) |
|
#define PLP_SET_SAMPLE_ID(cd,n) (PLP_CD(cd)->i |= (n)<<3) |
|
|
|
typedef struct |
|
{ |
|
int64_t i; |
|
uint32_t qlen; |
|
int nm; |
|
} |
|
plp_cd_t; |
|
|
|
|
|
typedef struct __bcf_callaux_t { |
|
int fmt_flag, ambig_reads; |
|
int capQ, min_baseQ, max_baseQ, delta_baseQ; |
|
int openQ, extQ, tandemQ; |
|
uint32_t min_support, max_support; |
|
double min_frac; |
|
float max_frac; |
|
int per_sample_flt; |
|
int *ref_pos, *alt_pos, npos, *ref_mq, *alt_mq, *ref_bq, *alt_bq, *fwd_mqs, *rev_mqs, nqual; |
|
int *iref_pos, *ialt_pos, *iref_mq, *ialt_mq; |
|
int ref_scl[100], alt_scl[100]; |
|
int iref_scl[100], ialt_scl[100]; |
|
|
|
int max_bases; |
|
int indel_types[4]; |
|
int indel_win_size, indels_v20; |
|
int maxins, indelreg; |
|
int read_len; |
|
char *inscns; |
|
uint16_t *bases; |
|
errmod_t *e; |
|
void *rghash; |
|
float indel_bias; |
|
int32_t *ref_nm, *alt_nm; |
|
unsigned int nnm[2]; |
|
float nm[2]; |
|
void *iaux; |
|
char *chr; |
|
} bcf_callaux_t; |
|
|
|
|
|
typedef struct { |
|
uint32_t ori_depth; |
|
unsigned int mq0; |
|
int32_t *ADF, *ADR, SCR, *QS; |
|
int32_t *ref_nm, *alt_nm; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double anno[16]; |
|
float p[25]; |
|
} bcf_callret1_t; |
|
|
|
|
|
typedef struct { |
|
int tid, pos; |
|
bcf_hdr_t *bcf_hdr; |
|
int a[5]; |
|
float qsum[B2B_MAX_ALLELES]; |
|
int n, n_alleles, ori_ref, unseen; |
|
int32_t shift; |
|
int n_supp; |
|
double anno[16]; |
|
unsigned int depth, ori_depth, mq0; |
|
int32_t *PL, *DP4, *ADR, *ADF, *SCR, *QS, *ref_nm, *alt_nm; |
|
uint8_t *fmt_arr; |
|
float vdb; |
|
float mwu_pos, mwu_mq, mwu_bq, mwu_mqs, mwu_sc, *mwu_nm, nm[2]; |
|
float seg_bias; |
|
float strand_bias; |
|
kstring_t tmp; |
|
} bcf_call_t; |
|
|
|
|
|
#ifdef __cplusplus |
|
extern "C" { |
|
#endif |
|
|
|
bcf_callaux_t *bcf_call_init(double theta, int min_baseQ, int max_baseQ, |
|
int delta_baseQ); |
|
void bcf_call_destroy(bcf_callaux_t *bca); |
|
int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t *bca, bcf_callret1_t *r); |
|
int bcf_call_combine(int n, const bcf_callret1_t *calls, bcf_callaux_t *bca, int ref_base , bcf_call_t *call); |
|
int bcf_call2bcf(bcf_call_t *bc, bcf1_t *b, bcf_callret1_t *bcr, int fmt_flag, |
|
const bcf_callaux_t *bca, const char *ref); |
|
int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_callaux_t *bca, const char *ref); |
|
int bcf_iaux_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_callaux_t *bca, const char *ref); |
|
void bcf_callaux_clean(bcf_callaux_t *bca, bcf_call_t *call); |
|
|
|
int bcf_cgp_l_run(const char *ref, int pos); |
|
int est_indelreg(int pos, const char *ref, int l, char *ins4); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
|
|
#endif |
|
|