From 595d9e36a8d97bf57eef1ce6760af96b7732e532 Mon Sep 17 00:00:00 2001 From: Leo Gordon <lg4@ebi.ac.uk> Date: Wed, 7 Mar 2012 15:27:16 +0000 Subject: [PATCH] added support for reading compressed files --- modules/Bio/EnsEMBL/Hive/RunnableDB/FastaFactory.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/Bio/EnsEMBL/Hive/RunnableDB/FastaFactory.pm b/modules/Bio/EnsEMBL/Hive/RunnableDB/FastaFactory.pm index 67bdbf260..7f6633e6d 100644 --- a/modules/Bio/EnsEMBL/Hive/RunnableDB/FastaFactory.pm +++ b/modules/Bio/EnsEMBL/Hive/RunnableDB/FastaFactory.pm @@ -72,7 +72,12 @@ sub fetch_input { my $self = shift @_; my $inputfile = $self->param('inputfile') || die "'inputfile' is an obligatory parameter"; - my $input_seqio = Bio::SeqIO->new(-file => '<'.$inputfile) || die "Could not open or parse '$inputfile', please investigate"; + die "Cannot read '$inputfile'" unless(-r $inputfile); + + if($inputfile=~/\.(?:gz|Z)$/) { + $inputfile = "gunzip -c $inputfile |"; + } + my $input_seqio = Bio::SeqIO->new(-file => $inputfile) || die "Could not open or parse '$inputfile', please investigate"; $self->param('input_seqio', $input_seqio); } -- GitLab