Skip to content
Snippets Groups Projects
Commit e3474924 authored by Andy Yates's avatar Andy Yates
Browse files

ENSCORESW-140. Bringing edits back from HEAD to sort out the bug.

parent 7e97568d
No related branches found
No related tags found
No related merge requests found
......@@ -164,22 +164,17 @@ sub print_Seq {
my $start = 1;
my $end = $slice->length();
# my $FORMAT = sprintf ("^%s
#", ('<'x($width-1)) );
#chunk the sequence to conserve memory, and print
my $here = $start;
while($here < $end) {
while($here <= $end) {
my $there = $here + $chunk_size - 1;
$there = $end if($there > $end);
my $seq = $slice->subseq($here, $there);
$seq =~ s/(.{1,$width})/$1\n/g;
print $fh $seq;
# $self->formatted_write($FORMAT, $seq);
$here = $there + 1;
}
......
......@@ -8,6 +8,7 @@ use IO::String;
use Bio::EnsEMBL::Utils::IO::FASTASerializer;
use Bio::EnsEMBL::Slice;
use Bio::EnsEMBL::CoordSystem;
use Bio::Seq;
#
# TEST - Slice creation from adaptor
......@@ -77,7 +78,7 @@ $fh_Serializer->close;
my $s = Bio::EnsEMBL::Slice->new(-SEQ_REGION_NAME => 'a', -COORD_SYSTEM => $coord_system, -SEQ => $seq, -SEQ_REGION_LENGTH => 120, -START => 1, -END => 120);
my $header = sub { return 'a'; };
my $io = IO::String->new();
my $ser = Bio::EnsEMBL::Utils::IO::FASTASerializer->new($io, $header, 60, 20);
my $ser = Bio::EnsEMBL::Utils::IO::FASTASerializer->new($io, $header, 6, 20);
my $expected = <<'FASTA';
>a
AAAAAAAAAAAAAAAAAAAA
......@@ -91,4 +92,31 @@ FASTA
is(${$io->string_ref()}, $expected, 'Testing round number serialisation');
}
{
my $seq = 'A'x21;
my $s = Bio::EnsEMBL::Slice->new(-SEQ_REGION_NAME => 'a', -COORD_SYSTEM => $coord_system, -SEQ => $seq, -SEQ_REGION_LENGTH => 21, -START => 1, -END => 21);
my $header = sub { return 'a'; };
my $io = IO::String->new();
my $ser = Bio::EnsEMBL::Utils::IO::FASTASerializer->new($io, $header, 1, 20);
my $expected = <<'FASTA';
>a
AAAAAAAAAAAAAAAAAAAA
A
FASTA
$ser->print_Seq($s);
is(${$io->string_ref()}, $expected, 'Testing odd (as in strange) number line length serialisation');
}
{
my $seq = Bio::Seq->new(-SEQ => 'M', -DISPLAY_ID => 'A');
my $io = IO::String->new();
my $ser = Bio::EnsEMBL::Utils::IO::FASTASerializer->new($io);
my $expected = <<'FASTA';
>A
M
FASTA
$ser->print_Seq($seq);
is(${$io->string_ref()}, $expected, 'Testing single base serialisation');
}
done_testing();
\ No newline at end of file
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