Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -398,18 +398,24 @@ sub fetch_by_region {
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 ) {
my $new_sl =
Bio::EnsEMBL::CircularSlice->new(
-COORD_SYSTEM => $cs,
-SEQ_REGION_NAME => $seq_region_name,
-SEQ_REGION_LENGTH => $length,
-START => $start,
-END => $end,
-STRAND => 1,
-ADAPTOR => $self );
return $new_sl;
my $cs_id = $cs->dbID();
my $seq_region_id = $self->{'sr_name_cache'}->{"$seq_region_name:$cs_id"} = $arr->[0];
if($self->is_circular($seq_region_id)) {
my $new_sl =
Bio::EnsEMBL::CircularSlice->new(
-COORD_SYSTEM => $cs,
-SEQ_REGION_NAME => $seq_region_name,
-SEQ_REGION_LENGTH => $length,
-START => $start,
-END => $end,
-STRAND => 1,
-ADAPTOR => $self );
return $new_sl;
}
}
if ( defined( $self->{'lrg_region_test'} )
......@@ -1048,6 +1054,26 @@ sub is_reference {
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
Title : fetch_by_band
......
......@@ -532,29 +532,19 @@ sub is_toplevel {
Description: Returns 1 if slice is a circular slice else 0
Returntype : int
Caller : general
Status : At Risk
Status : Stable
=cut
sub is_circular {
my ($self) = @_;
if ( !defined( $self->adaptor() ) ) { return 0 }
if ( !defined( $self->{'circular'} ) ) {
$self->{'circular'} = 0;
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;
}
}
my $adaptor = $self->adaptor();
return 0 if ! defined $adaptor;
if (! exists $self->{'circular'}) {
my $id = $adaptor->get_seq_region_id($self);
$self->{circular} = $adaptor->is_circular($id);
}
return $self->{'circular'};
return $self->{circular};
}
=head2 invert
......
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