From 6d74ccf26dc9bdc6284e6b459ba8aac9bb70f2b6 Mon Sep 17 00:00:00 2001 From: Benjamin Chu Date: Thu, 27 Jun 2024 15:03:44 -0700 Subject: [PATCH] consider the case when VCF file contain multiple chr --- src/make_hdf5.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/make_hdf5.jl b/src/make_hdf5.jl index 354fe071..d8dc108e 100644 --- a/src/make_hdf5.jl +++ b/src/make_hdf5.jl @@ -78,15 +78,16 @@ function get_block( chr_i = VCF.chrom(record) pos_i = VCF.pos(record) alt_i = VCF.alt(record) - _, _, _, _, _, alt_freq, _, _, _, maf, hwepval = gtstats(record, nothing) gtkey = VariantCallFormat.findgenokey(record, "GT") + _, _, _, _, _, alt_freq, _, _, _, maf, hwepval = gtstats(record, nothing) # quick exit - validate(record, chr_i, pos_i, prev_pos, alt_i) + validate(record, chr_i, pos_i, prev_pos, alt_i, gtkey) chr_i = parse(Int, chr_i) + chr_i < chr && continue + chr_i > chr && break pos_i < start_bp && continue pos_i > end_bp && break - chr_i > chr && break (isnan(maf) || maf < min_maf) && continue hwepval < min_hwe && continue @@ -122,8 +123,8 @@ function get_block( return Matrix(X), df end -function validate(record, chr_i, pos_i, prev_pos, alt_i) - if VariantCallFormat.findgenokey(record, "GT") === nothing +function validate(record, chr_i, pos_i, prev_pos, alt_i, gtkey) + if gtkey === nothing error("chr $chr_i at pos $pos_i has no GT field!") end if length(alt_i) > 1