Commit 21c43846 authored by Andy Yates's avatar Andy Yates
Browse files

Removing seek() call and not using the filesystem. IO::String does the same job

parent 5009ec78
...@@ -2,7 +2,6 @@ use strict; ...@@ -2,7 +2,6 @@ use strict;
use warnings; use warnings;
use Test::More; use Test::More;
use File::Temp qw/tempfile/;
use IO::String; use IO::String;
use Bio::EnsEMBL::Utils::IO::FASTASerializer; use Bio::EnsEMBL::Utils::IO::FASTASerializer;
...@@ -32,21 +31,16 @@ my $slice = Bio::EnsEMBL::Slice->new( ...@@ -32,21 +31,16 @@ my $slice = Bio::EnsEMBL::Slice->new(
); );
# ensure Serializer produces output identical to the well-used SeqDumper. # ensure Serializer produces output identical to the well-used SeqDumper.
my $fh_SeqDumper = tempfile(); my $fh_SeqDumper = IO::String->new();
Bio::EnsEMBL::Utils::SeqDumper->dump_fasta( $slice, $fh_SeqDumper); Bio::EnsEMBL::Utils::SeqDumper->dump_fasta( $slice, $fh_SeqDumper);
my $fh_Serializer = tempfile(); my $fh_Serializer = IO::String->new();
my $serializer = Bio::EnsEMBL::Utils::IO::FASTASerializer->new($fh_Serializer); my $serializer = Bio::EnsEMBL::Utils::IO::FASTASerializer->new($fh_Serializer);
$serializer->print_Seq($slice); $serializer->print_Seq($slice);
$fh_SeqDumper->seek(0,0); my $SeqDumper_output = ${$fh_SeqDumper->string_ref()};
$fh_Serializer->seek(0,0); my $Serializer_output = ${$fh_Serializer->string_ref()};
local $/ = undef;
my $SeqDumper_output = <$fh_SeqDumper>;
my $Serializer_output = <$fh_Serializer>;
$fh_SeqDumper->close; $fh_SeqDumper->close;
$fh_Serializer->close; $fh_Serializer->close;
...@@ -62,11 +56,10 @@ my $custom_header = sub { ...@@ -62,11 +56,10 @@ my $custom_header = sub {
return "It's a FASTA header"; return "It's a FASTA header";
}; };
$fh_Serializer = tempfile(); $fh_Serializer = IO::String->new();
$serializer = Bio::EnsEMBL::Utils::IO::FASTASerializer->new($fh_Serializer, $custom_header); $serializer = Bio::EnsEMBL::Utils::IO::FASTASerializer->new($fh_Serializer, $custom_header);
$serializer->print_Seq($slice); $serializer->print_Seq($slice);
$fh_Serializer->seek(0,0); $Serializer_output = ${$fh_Serializer->string_ref()};
$Serializer_output = <$fh_Serializer>;
note $Serializer_output; note $Serializer_output;
......
Markdown is supported
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