Skip to content

Commit 59021af

Browse files
committed
fix bug in vcf_attributes method so it properly parses INFO and tolerate null attributes
1 parent db98ab4 commit 59021af

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/Bio/ToolBox/Data/Feature.pm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,9 @@ sub vcf_attributes {
623623
unless ($self->{data}->name(7) eq 'INFO') {
624624
croak "VCF column INFO is missing or improperly formatted!";
625625
}
626-
my %info = map {$_[0] => defined $_[1] ? $_[1] : 1}
627-
map { [ split /=/ ] }
628-
( split /;/, $self->value(7) );
626+
my %info = map {$_->[0] => defined $_->[1] ? $_->[1] : 1}
627+
map { [split(/=/, $_)] }
628+
split(/;/, $self->value(7));
629629
$self->{attributes}->{INFO} = \%info;
630630
$self->{attributes}->{7} = \%info;
631631

@@ -637,7 +637,9 @@ sub vcf_attributes {
637637
foreach my $i (9 .. $self->{data}->number_columns - 1) {
638638
my $name = $self->{data}->name($i);
639639
my @sampleVals = split /:/, $self->value($i);
640-
my %sample = map { $formatKeys[$_] => $sampleVals[$_] } (0 .. $#formatKeys);
640+
my %sample = map {
641+
$formatKeys[$_] => defined $sampleVals[$_] ? $sampleVals[$_] : undef }
642+
(0 .. $#formatKeys);
641643
$self->{attributes}->{$name} = \%sample;
642644
$self->{attributes}->{$i} = \%sample;
643645
}

0 commit comments

Comments
 (0)