Commit 7e8d2490 authored by Andy Yates's avatar Andy Yates
Browse files

Made the circular slice code compartmentalised to just SliceAdaptor (making...

Made the circular slice code compartmentalised to just SliceAdaptor (making cache initalisation code easier) and we now only build circular slices when the seqregion it is based off is flagged as circular
parent 0fe32d38
...@@ -398,18 +398,24 @@ sub fetch_by_region { ...@@ -398,18 +398,24 @@ sub fetch_by_region {
if ( !defined($end) ) { $end = $length } if ( !defined($end) ) { $end = $length }
#If this was given then check if we've got a circular seq region otherwise
#let it fall through to the normal Slice method
if ( $end + 1 < $start ) { if ( $end + 1 < $start ) {
my $new_sl = my $cs_id = $cs->dbID();
Bio::EnsEMBL::CircularSlice->new( my $seq_region_id = $self->{'sr_name_cache'}->{"$seq_region_name:$cs_id"} = $arr->[0];
-COORD_SYSTEM => $cs, if($self->is_circular($seq_region_id)) {
-SEQ_REGION_NAME => $seq_region_name, my $new_sl =
-SEQ_REGION_LENGTH => $length, Bio::EnsEMBL::CircularSlice->new(
-START => $start, -COORD_SYSTEM => $cs,
-END => $end, -SEQ_REGION_NAME => $seq_region_name,
-STRAND => 1, -SEQ_REGION_LENGTH => $length,
-ADAPTOR => $self ); -START => $start,
-END => $end,
return $new_sl; -STRAND => 1,
-ADAPTOR => $self );
return $new_sl;
}
} }
if ( defined( $self->{'lrg_region_test'} ) if ( defined( $self->{'lrg_region_test'} )
...@@ -1048,6 +1054,26 @@ sub is_reference { ...@@ -1048,6 +1054,26 @@ sub is_reference {
return 1; return 1;
} }
=head2 is_circular
Arg[1] : int seq_region_id
Example : my $circular = $slice_adptor->is_circular($seq_region_id);
Description : Indicates if the sequence region was circular or not
Returntype : Boolean
=cut
sub is_circular {
my ($self, $id) = @_;
if (! defined $self->{is_circular}) {
$self->_build_circular_slice_cache();
}
return 0 if $self->{is_circular} == 0;
return (exists $self->{circular_sr_id_cache}->{$id}) ? 1 : 0;
}
=head2 fetch_by_band =head2 fetch_by_band
Title : fetch_by_band Title : fetch_by_band
......
...@@ -532,29 +532,19 @@ sub is_toplevel { ...@@ -532,29 +532,19 @@ sub is_toplevel {
Description: Returns 1 if slice is a circular slice else 0 Description: Returns 1 if slice is a circular slice else 0
Returntype : int Returntype : int
Caller : general Caller : general
Status : At Risk Status : Stable
=cut =cut
sub is_circular { sub is_circular {
my ($self) = @_; my ($self) = @_;
my $adaptor = $self->adaptor();
if ( !defined( $self->adaptor() ) ) { return 0 } return 0 if ! defined $adaptor;
if (! exists $self->{'circular'}) {
if ( !defined( $self->{'circular'} ) ) { my $id = $adaptor->get_seq_region_id($self);
$self->{'circular'} = 0; $self->{circular} = $adaptor->is_circular($id);
if ( !defined($self->adaptor()->{'is_circular'}) ){
$self->adaptor()->_build_circular_slice_cache();
}
if ($self->adaptor()->{'is_circular'}) {
if ( exists($self->adaptor()->{'circular_sr_id_cache'}->{ $self->adaptor()->get_seq_region_id($self) } ) ) {
$self->{'circular'} = 1;
}
}
} }
return $self->{'circular'}; return $self->{circular};
} }
=head2 invert =head2 invert
......
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