Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ vcfcnv.o: vcfcnv.c $(htslib_vcf_h) $(htslib_synced_bcf_reader_h) $(htslib_kstrin
vcfhead.o: vcfhead.c $(htslib_kstring_h) $(htslib_vcf_h) $(bcftools_h)
vcfsom.o: vcfsom.c $(htslib_vcf_h) $(htslib_synced_bcf_reader_h) $(htslib_vcfutils_h) $(htslib_hts_os_h) $(htslib_hts_defs_h) $(bcftools_h)
vcfsort.o: vcfsort.c $(htslib_vcf_h) $(htslib_kstring_h) $(htslib_hts_os_h) $(htslib_hts_defs_h) $(htslib_bgzf_h) kheap.h $(bcftools_h)
vcfstats.o: vcfstats.c $(htslib_vcf_h) $(htslib_synced_bcf_reader_h) $(htslib_vcfutils_h) $(htslib_faidx_h) $(bcftools_h) $(filter_h) bin.h dist.h
vcfstats.o: vcfstats.c $(htslib_vcf_h) $(htslib_synced_bcf_reader_h) $(htslib_vcfutils_h) $(htslib_faidx_h) $(htslib_hts_endian_h) $(bcftools_h) $(filter_h) bin.h dist.h
vcfview.o: vcfview.c $(htslib_vcf_h) $(htslib_synced_bcf_reader_h) $(htslib_vcfutils_h) $(bcftools_h) $(filter_h) $(htslib_khash_str2int_h) $(htslib_kbitset_h)
reheader.o: reheader.c $(htslib_vcf_h) $(htslib_bgzf_h) $(htslib_tbx_h) $(htslib_kseq_h) $(htslib_thread_pool_h) $(htslib_faidx_h) $(htslib_khash_str2int_h) $(bcftools_h) $(khash_str2str_h)
tabix.o: tabix.c $(htslib_bgzf_h) $(htslib_tbx_h)
Expand Down
65 changes: 34 additions & 31 deletions vcfstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ THE SOFTWARE. */
#include <htslib/synced_bcf_reader.h>
#include <htslib/vcfutils.h>
#include <htslib/faidx.h>
#include <htslib/hts_endian.h>
#include <inttypes.h>
#include "bcftools.h"
#include "filter.h"
Expand Down Expand Up @@ -899,36 +900,37 @@ static inline int get_ad(bcf1_t *line, bcf_fmt_t *ad_fmt_ptr, int ismpl, int *ia
{
int iv, ad = 0;
*ial = 0;
#define BRANCH_INT(type_t,missing,vector_end) { \
type_t *ptr = (type_t *) (ad_fmt_ptr->p + ad_fmt_ptr->size*ismpl); \
#define BRANCH_INT(type_t,convert,missing,vector_end) { \
uint8_t *x = ad_fmt_ptr->p + ad_fmt_ptr->size*ismpl; \
for (iv=1; iv<ad_fmt_ptr->n && iv<line->n_allele; iv++) \
{ \
if ( ptr[iv]==vector_end ) break; \
if ( ptr[iv]==missing ) continue; \
if ( ad < ptr[iv] ) { ad = ptr[iv]; *ial = iv; }\
type_t val = convert(&x[iv * sizeof(type_t)]); \
if ( val==vector_end ) break; \
if ( val==missing ) continue; \
if ( ad < val ) { ad = val; *ial = iv; }\
} \
}
switch (ad_fmt_ptr->type) {
case BCF_BT_INT8: BRANCH_INT(int8_t, bcf_int8_missing, bcf_int8_vector_end); break;
case BCF_BT_INT16: BRANCH_INT(int16_t, bcf_int16_missing, bcf_int16_vector_end); break;
case BCF_BT_INT32: BRANCH_INT(int32_t, bcf_int32_missing, bcf_int32_vector_end); break;
case BCF_BT_INT8: BRANCH_INT(int8_t, le_to_i8, bcf_int8_missing, bcf_int8_vector_end); break;
case BCF_BT_INT16: BRANCH_INT(int16_t, le_to_i16, bcf_int16_missing, bcf_int16_vector_end); break;
case BCF_BT_INT32: BRANCH_INT(int32_t, le_to_i32, bcf_int32_missing, bcf_int32_vector_end); break;
default: fprintf(stderr, "[E::%s] todo: %d\n", __func__, ad_fmt_ptr->type); exit(1); break;
}
#undef BRANCH_INT
return ad;
}
static inline int get_iad(bcf1_t *line, bcf_fmt_t *ad_fmt_ptr, int ismpl, int ial)
{
#define BRANCH_INT(type_t,missing,vector_end) { \
type_t *ptr = (type_t *) (ad_fmt_ptr->p + ad_fmt_ptr->size*ismpl); \
if ( ptr[ial]==vector_end ) return 0; \
if ( ptr[ial]==missing ) return 0; \
return ptr[ial]; \
#define BRANCH_INT(type_t,convert,missing,vector_end) { \
type_t val = convert(ad_fmt_ptr->p + ad_fmt_ptr->size*ismpl + ial*sizeof(type_t)); \
if ( val==vector_end ) return 0; \
if ( val==missing ) return 0; \
return val; \
}
switch (ad_fmt_ptr->type) {
case BCF_BT_INT8: BRANCH_INT(int8_t, bcf_int8_missing, bcf_int8_vector_end); break;
case BCF_BT_INT16: BRANCH_INT(int16_t, bcf_int16_missing, bcf_int16_vector_end); break;
case BCF_BT_INT32: BRANCH_INT(int32_t, bcf_int32_missing, bcf_int32_vector_end); break;
case BCF_BT_INT8: BRANCH_INT(int8_t, le_to_i8, bcf_int8_missing, bcf_int8_vector_end); break;
case BCF_BT_INT16: BRANCH_INT(int16_t, le_to_i16, bcf_int16_missing, bcf_int16_vector_end); break;
case BCF_BT_INT32: BRANCH_INT(int32_t, le_to_i32, bcf_int32_missing, bcf_int32_vector_end); break;
default: fprintf(stderr, "[E::%s] todo: %d\n", __func__, ad_fmt_ptr->type); exit(1); break;
}
#undef BRANCH_INT
Expand Down Expand Up @@ -957,36 +959,37 @@ static inline int calc_sample_depth(args_t *args, int ismpl, bcf_fmt_t *ad_fmt_p
{
if ( dp_fmt_ptr )
{
#define BRANCH_INT(type_t,missing,vector_end) { \
type_t *ptr = (type_t *) (dp_fmt_ptr->p + dp_fmt_ptr->size*ismpl); \
if ( *ptr==missing || *ptr==vector_end ) return -1; \
return *ptr; \
#define BRANCH_INT(type_t,convert,missing,vector_end) { \
type_t val = convert(dp_fmt_ptr->p + dp_fmt_ptr->size*ismpl); \
if ( val==missing || val==vector_end ) return -1; \
return val; \
}
switch (dp_fmt_ptr->type) {
case BCF_BT_INT8: BRANCH_INT(int8_t, bcf_int8_missing, bcf_int8_vector_end); break;
case BCF_BT_INT16: BRANCH_INT(int16_t, bcf_int16_missing, bcf_int16_vector_end); break;
case BCF_BT_INT32: BRANCH_INT(int32_t, bcf_int32_missing, bcf_int32_vector_end); break;
case BCF_BT_INT8: BRANCH_INT(int8_t, le_to_i8, bcf_int8_missing, bcf_int8_vector_end); break;
case BCF_BT_INT16: BRANCH_INT(int16_t, le_to_i16, bcf_int16_missing, bcf_int16_vector_end); break;
case BCF_BT_INT32: BRANCH_INT(int32_t, le_to_i32, bcf_int32_missing, bcf_int32_vector_end); break;
default: fprintf(stderr, "[E::%s] todo: %d\n", __func__, dp_fmt_ptr->type); exit(1); break;
}
#undef BRANCH_INT
}
if ( ad_fmt_ptr )
{
int iv, dp = 0, has_value = 0;
#define BRANCH_INT(type_t,missing,vector_end) { \
type_t *ptr = (type_t *) (ad_fmt_ptr->p + ad_fmt_ptr->size*ismpl); \
#define BRANCH_INT(type_t,convert,missing,vector_end) { \
uint8_t *x = ad_fmt_ptr->p + ad_fmt_ptr->size*ismpl; \
for (iv=0; iv<ad_fmt_ptr->n; iv++) \
{ \
if ( ptr[iv]==vector_end ) break; \
if ( ptr[iv]==missing ) continue; \
type_t val = convert(&x[iv * sizeof(type_t)]); \
if ( val==vector_end ) break; \
if ( val==missing ) continue; \
has_value = 1; \
dp += ptr[iv]; \
dp += val; \
} \
}
switch (ad_fmt_ptr->type) {
case BCF_BT_INT8: BRANCH_INT(int8_t, bcf_int8_missing, bcf_int8_vector_end); break;
case BCF_BT_INT16: BRANCH_INT(int16_t, bcf_int16_missing, bcf_int16_vector_end); break;
case BCF_BT_INT32: BRANCH_INT(int32_t, bcf_int32_missing, bcf_int32_vector_end); break;
case BCF_BT_INT8: BRANCH_INT(int8_t, le_to_i8, bcf_int8_missing, bcf_int8_vector_end); break;
case BCF_BT_INT16: BRANCH_INT(int16_t, le_to_i16, bcf_int16_missing, bcf_int16_vector_end); break;
case BCF_BT_INT32: BRANCH_INT(int32_t, le_to_i32, bcf_int32_missing, bcf_int32_vector_end); break;
default: fprintf(stderr, "[E::%s] todo: %d\n", __func__, ad_fmt_ptr->type); exit(1); break;
}
#undef BRANCH_INT
Expand Down
Loading