Commit bbb81025 authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

Use a row cache and fetchall_arrayref() instead of single calls to

fetchrow_arrayref().
parent 4e00396a
...@@ -1275,40 +1275,42 @@ sub _objs_from_sth { ...@@ -1275,40 +1275,42 @@ sub _objs_from_sth {
my $slice_name = $this->slice()->name(); my $slice_name = $this->slice()->name();
my $slice_start = $this->slice()->start(); my $slice_start = $this->slice()->start();
while ( my $entry = $sth->fetchrow_arrayref() ) { while ( my $rowcache = $sth->fetchall_arrayref( undef, 1000 ) ) {
if ( !defined($segment) while ( my $entry = shift( @{$rowcache} ) ) {
|| $segment != if ( !defined($segment)
$SEQ_REG_MAP{$slice_name}{ $entry->[ENTRY_SEQREGIONID] } ) || $segment !=
{ $SEQ_REG_MAP{$slice_name}{ $entry->[ENTRY_SEQREGIONID] } )
$segment = {
$SEQ_REG_MAP{$slice_name}{ $entry->[ENTRY_SEQREGIONID] }; $segment =
$segment_slice = $segment->to_Slice(); $SEQ_REG_MAP{$slice_name}{ $entry->[ENTRY_SEQREGIONID] };
$segment_slice_start = $segment_slice->start(); $segment_slice = $segment->to_Slice();
$segment_slice_strand = $segment_slice->strand(); $segment_slice_start = $segment_slice->start();
$segment_slice_strand = $segment_slice->strand();
if ( $segment_slice_strand == -1 ) {
$segment_offset = $segment->from_end(); if ( $segment_slice_strand == -1 ) {
} else { $segment_offset = $segment->from_end();
$segment_offset = $segment->from_start(); } else {
$segment_offset = $segment->from_start();
}
} }
}
my $start = $slice_start + $segment_offset; my $start = $slice_start + $segment_offset;
my $end = $start; my $end = $start;
if ( $segment_slice_strand == -1 ) { if ( $segment_slice_strand == -1 ) {
$start -= $entry->[ENTRY_SEQREGIONEND] - $segment_slice_start; $start -= $entry->[ENTRY_SEQREGIONEND] - $segment_slice_start;
$end -= $entry->[ENTRY_SEQREGIONSTART] - $segment_slice_start; $end -= $entry->[ENTRY_SEQREGIONSTART] - $segment_slice_start;
} else { # Assumes '0' is really the positive strand. } else { # Assumes '0' is really the positive strand.
$start += $entry->[ENTRY_SEQREGIONSTART] - $segment_slice_start; $start += $entry->[ENTRY_SEQREGIONSTART] - $segment_slice_start;
$end += $entry->[ENTRY_SEQREGIONEND] - $segment_slice_start; $end += $entry->[ENTRY_SEQREGIONEND] - $segment_slice_start;
} }
$entry->[ENTRY_SEQREGIONSTART] = $start - 1; $entry->[ENTRY_SEQREGIONSTART] = $start - 1;
$entry->[ENTRY_SEQREGIONEND] = $end - 1; $entry->[ENTRY_SEQREGIONEND] = $end - 1;
push( @features, [ @{$entry} ] ); push( @features, [ @{$entry} ] );
} ## end while ( my $entry = $sth->fetchrow_arrayref... } ## end while ( my $entry = shift...
} ## end while ( my $rowcache = $sth...
$sth->finish(); $sth->finish();
return \@features; return \@features;
......
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