Skip to content
Snippets Groups Projects
Commit 652b6a26 authored by Tiago Grego's avatar Tiago Grego
Browse files

cleanup parser code

parent 14146900
No related branches found
No related tags found
1 merge request!97[ENSCORESW-3106] BCF parser
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
=head1 LICENSE =head1 LICENSE
Copyright [2020] EMBL-European Bioinformatics Institute Copyright [2020] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
...@@ -16,15 +16,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -16,15 +16,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
=cut
=head1 NAME =head1 NAME
Bio::EnsEMBL::IO::Parser::BCF - A line-based parser devoted to BCF Bio::EnsEMBL::IO::Parser::BCF - A line-based parser devoted to BCF
=cut
=head1 DESCRIPTION =head1 DESCRIPTION
BCF is a binary format of VCF BCF is a binary format of VCF
...@@ -49,10 +44,8 @@ sub open { ...@@ -49,10 +44,8 @@ sub open {
# initialize generic parser # initialize generic parser
my $self = $class->SUPER::new(@other_args); my $self = $class->SUPER::new(@other_args);
$self->{record} = undef; $self->{record} = undef;
$self->{bcf_file} = Bio::DB::HTS::VCF->new( filename => $filename ); $self->{bcf_file} = Bio::DB::HTS::VCF->new( filename => $filename );
$self->{iterator} = undef; $self->{iterator} = undef;
return $self; return $self;
...@@ -83,6 +76,7 @@ sub seek { ...@@ -83,6 +76,7 @@ sub seek {
sub next_block { sub next_block {
my $self = shift; my $self = shift;
if (!defined $self->{iterator}) { if (!defined $self->{iterator}) {
exit 1; exit 1;
} }
...@@ -91,14 +85,17 @@ sub next_block { ...@@ -91,14 +85,17 @@ sub next_block {
} }
sub read_block { sub read_block {
my $self = shift; my $self = shift;
$self->{waiting_block} = $self->{iterator}->next;
$self->{waiting_block} = $self->{iterator}->next;
} }
sub close { sub close {
my $self = shift; my $self = shift;
$self->{iterator}->close if $self->{iterator}; $self->{iterator}->close if $self->{iterator};
my $report = $self->{bcf_file}->DESTROY; my $report = $self->{bcf_file}->DESTROY;
return (defined $report) ? 0 : 1; return (defined $report) ? 0 : 1;
} }
...@@ -138,5 +135,4 @@ sub read_record { ...@@ -138,5 +135,4 @@ sub read_record {
return $self->{record}; return $self->{record};
} }
1; 1;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment