GeneticVariation.VCF.filter(reader) fails when encounters missing filter
gtollefson opened this issue · 3 comments
I am using the VCF.filter(reader) function to examine records in a vcf file that has missing values in the filter element of some records. I am trying to select records with VCF.filter(reader) = PASS but the function fails and throws an error (pasted below) when it encounters VCF.filter(reader) = missing
ERROR: filter is missing
Stacktrace:
[1] filter(::GeneticVariation.VCF.Record) at /Users/George/.julia/test/v0.6/GeneticVariation/src/vcf/record.jl:446
[2] io_pass_filter(::GeneticVariation.VCF.Reader) at ./REPL[3]:9
I would like to be able to access Filter elements of VCF.reader objects that are equal to missing.
Is this a bug?
I'm using GeneticVariation.jl v0.3.1 in Julia 0.6.3 on Mac OS
@gtollefson, the filter method for VCF records is currently defined as:
function filter(record::Record)::Vector{String}
checkfilled(record)
if isempty(record.filter)
missingerror(:filter)
end
return [String(record.data[r]) for r in record.filter]
end
So if there is no filter info, then it throws a missing error, rather than retuning missing
(which I believe is a julia 0.7 addition not in julia 0.6).
You can use the VCF.hasfilter
method to check if the record has filter infomation:
function hasfilter(record::Record)
return isfilled(record) && !isempty(record.filter)
end
Is this what you're looking for? Can you show us what you are scripting, and maybe some example VCF lines?
@benjward Using VCF.hasfilter() worked for me. Thank you for the helpful response!