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

Only do block retrieval of repeats when we are caching our hits. Otherwise...

Only do block retrieval of repeats when we are caching our hits. Otherwise we're bringing back more data for no reason
parent 41614056
No related branches found
No related tags found
No related merge requests found
......@@ -217,10 +217,10 @@ sub seq {
my $soft_mask = $self->soft_mask();
my $not_default_masking_cases = $self->not_default_masking_cases;
my $repeats = [];
my @repeats;
foreach my $l (@$logic_names) {
push @{$repeats}, @{$self->get_all_RepeatFeatures($l)};
push @repeats, @{$self->get_all_RepeatFeatures($l)};
}
#
......@@ -231,12 +231,10 @@ sub seq {
#
# mask the dna
#
$self->_mask_features(\$dna,$repeats,$soft_mask,$not_default_masking_cases);
$self->_mask_features(\$dna,\@repeats,$soft_mask,$not_default_masking_cases);
return $dna;
}
=head2 subseq
Arg [1] : none
......@@ -251,58 +249,58 @@ sub seq {
=cut
sub subseq {
my $self = shift;
my $start = shift;
my $end = shift;
my $strand = shift;
#
# get all the features
#
my $logic_names = $self->repeat_mask_logic_names();
my $soft_mask = $self->soft_mask();
my $not_default_masking_cases = $self->not_default_masking_cases;
my $subsequence_slice = $self->sub_Slice($start, $end, $strand);
# If frequent subseqs happen on repeatMasked sequence this results in
# a lot of feature retrieval from the database. To avoid this, features
# are only retrieved from subslices with fixed space boundaries.
# The access happens in block to make cache hits more likely
# The blocksize can be defined on the top of this module.
my $seq_region_slice = $self->seq_region_Slice();
my $block_min = ($self->start()-1) >> $BLOCK_PWR;
my $block_max = ($self->end()-1) >> $BLOCK_PWR;
my $repeats = [];
my $sub_start = ($block_min << $BLOCK_PWR)+1;
my $sub_end = ($block_max+1)<<$BLOCK_PWR;
if ($sub_end > $seq_region_slice->length) {
$sub_end = $seq_region_slice->length ;
# ONLY DO IF WE ARE CACHING
my $subslice;
if(! $self->adaptor()->db()->no_cache()) {
my $seq_region_slice = $self->seq_region_Slice();
# The blocksize can be defined on the top of this module.
my $block_min = ($self->start()-1) >> $BLOCK_PWR;
my $block_max = ($self->end()-1) >> $BLOCK_PWR;
my $sub_start = ($block_min << $BLOCK_PWR)+1;
my $sub_end = ($block_max+1)<<$BLOCK_PWR;
if ($sub_end > $seq_region_slice->length) {
$sub_end = $seq_region_slice->length ;
}
$subslice = $seq_region_slice->sub_Slice($sub_start, $sub_end);
}
my $subslice = $seq_region_slice->sub_Slice( $sub_start, $sub_end);
foreach my $l (@$logic_names) {
push @{$repeats}, @{$subslice->get_all_RepeatFeatures($l)};
else {
$subslice = $subsequence_slice;
}
#
# get the dna
# get all the features
#
my $subsequence_slice = $self->sub_Slice( $start, $end, $strand );
my $dna = $subsequence_slice->seq();
my $logic_names = $self->repeat_mask_logic_names();
my $soft_mask = $self->soft_mask();
my $not_default_masking_cases = $self->not_default_masking_cases;
my @repeats;
foreach my $l (@$logic_names) {
push @repeats, @{$subslice->get_all_RepeatFeatures($l)};
}
#
# mask the dna
#
$subsequence_slice->_mask_features(\$dna,$repeats,$soft_mask,$not_default_masking_cases);
my $dna = $subsequence_slice->seq();
$subsequence_slice->_mask_features(\$dna,\@repeats,$soft_mask,$not_default_masking_cases);
return $dna;
}
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