diff --git a/modules/Bio/EnsEMBL/DBSQL/AssemblyAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/AssemblyAdaptor.pm index aba0b6bb7279bac92c1159c819dd2c83533fa653..5ea710722ad7f4121cc658fd2fb121a173d9d17a 100644 --- a/modules/Bio/EnsEMBL/DBSQL/AssemblyAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/AssemblyAdaptor.pm @@ -109,27 +109,26 @@ sub fetch_info { $assembly_info{'schema_build'} = $schema_build; } - #fetch available coordinate systems - + #fetch available coordinate systems my $csa = $self->db()->get_adaptor('CoordSystem'); - my %versions; - foreach my $cs (@{$csa->fetch_all()}) { - $versions{$cs->version()} = 1; - } - my @coord_system_versions = keys %versions; - - $assembly_info{'coord_system_versions'} = \@coord_system_versions; + my $coord_systems = $csa->fetch_all(); + my %versions = map { $_->version(), 1 } @{$coord_systems}; + $assembly_info{'coord_system_versions'} = [keys %versions]; + my ($default_assembly) = @{$coord_systems}; + $assembly_info{default_coord_system_version} = $default_assembly->version(); #fetch top level seq_region names my $sa = $self->db()->get_adaptor('Slice'); my $slices = $sa->fetch_all('toplevel'); - my %unique = map { $_->seq_region_name(), 0 } @{$slices}; my $names = [sort { $a cmp $b } keys %unique]; $assembly_info{'top_level_seq_region_names'} = $names; + my $karyotype = $sa->fetch_all_karyotype(); + $assembly_info{karyotype} = [ map { $_->seq_region_name() } @{$karyotype}]; + return \%assembly_info; } diff --git a/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm index 3382a397be76d7da52fde61514ee9396d27701c8..fd513ce7d8fbfd084e7aaf6f6bfed6553d36072d 100644 --- a/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/SliceAdaptor.pm @@ -1147,18 +1147,18 @@ sub fetch_all_karyotype { my $sth = $self->prepare( 'SELECT sr.seq_region_id, sr.name, ' - . 'sr.length, sr.coord_system_id ' + . 'sr.length, sr.coord_system_id, sra.value ' . 'FROM seq_region sr, seq_region_attrib sra, ' . 'attrib_type at, coord_system cs ' . 'WHERE at.code = "karyotype_rank" ' . 'AND at.attrib_type_id = sra.attrib_type_id ' . 'AND sra.seq_region_id = sr.seq_region_id ' . 'AND sr.coord_system_id = cs.coord_system_id ' - . 'AND cs.species_id = ?' ); + . 'AND cs.species_id = ?'); $sth->bind_param( 1, $self->species_id(), SQL_INTEGER ); $sth->execute(); - my ( $seq_region_id, $name, $length, $cs_id ); - $sth->bind_columns( \( $seq_region_id, $name, $length, $cs_id ) ); + my ( $seq_region_id, $name, $length, $cs_id, $rank ); + $sth->bind_columns( \( $seq_region_id, $name, $length, $cs_id, $rank ) ); my @out; while($sth->fetch()) { @@ -1166,17 +1166,22 @@ sub fetch_all_karyotype { my $slice = Bio::EnsEMBL::Slice->new_fast({ 'start' => 1, - 'end' => $length, + 'end' => ($length+0), 'strand' => 1, 'seq_region_name' => $name, - 'seq_region_length'=> $length, + 'seq_region_length'=> ($length+0), 'coord_system' => $cs, - 'adaptor' => $self}); + 'adaptor' => $self, + 'karyotype' => 1, + 'karyotype_rank' => ($rank+0), + }); push @out, $slice; - } + #Sort using Perl as value in MySQL is a text field and not portable + @out = sort { $a->{karyotype_rank} <=> $b->{karyotype_rank} } @out; + return \@out; } diff --git a/modules/Bio/EnsEMBL/Slice.pm b/modules/Bio/EnsEMBL/Slice.pm index 342e2b02feaf6b4cfaa8e17b46060b13ff9907fd..7332928515184f5934c74ffe95aaa40d8b112103 100644 --- a/modules/Bio/EnsEMBL/Slice.pm +++ b/modules/Bio/EnsEMBL/Slice.pm @@ -551,6 +551,24 @@ sub has_karyotype { return $self->{'karyotype'}; } +=head2 karyotype_rank + Arg : none + Example : my $rank = $slice->karyotype_rank() + Description: Returns the numeric ranking in the karyotype. Otherwise 0 is returned + Returntype : int + Caller : general + Status : At Risk + +=cut + +sub karyotype_rank { + my ($self) = @_; + if(! defined( $self->{karyotype_rank})) { + my $rank = $self->adaptor()->get_karyotype_rank($self->get_seq_region_id()); + $self->{karyotype_rank} = $rank if $rank; + } + return $self->{karyotype_rank} || 0; +} =head2 is_circular Arg : none