3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
37 $kary_adaptor = $db_adaptor->get_KaryotypeBandAdaptor();
39 foreach $band ( @{ $kary_adaptor->fetch_all_by_Slice($slice) } ) {
40 # do something with band
45 my @bands = @{ $kary_adaptor->fetch_all_by_chr_name(
'X') };
47 my $band = $kary_adaptor->fetch_by_chr_band(
'4',
'q23' );
51 Database adaptor to provide access to KaryotypeBand objects
57 package Bio::EnsEMBL::DBSQL::KaryotypeBandAdaptor;
72 the karyotype bands to store in the database
73 Example : $karyotype_adaptor->store(@karyotype_band);
74 Description: Stores a list of karyotype band objects in the database
76 Exceptions : thrown
if @k is not defined,
if any of the features
do not
77 have an attached slice.
87 if( scalar(@k) == 0 ) {
88 throw(
"Must call store with list of karyotype bands");
91 my $sth = $self->prepare
92 (
"INSERT INTO karyotype (seq_region_id, seq_region_start, " .
93 "seq_region_end, band, " .
95 "VALUES (?,?,?,?,?)");
98 my $slice_adaptor = $db->get_SliceAdaptor();
100 BAND:
foreach my $k ( @k ) {
102 if( !ref $k || !$k->isa(
"Bio::EnsEMBL::KaryotypeBand") ) {
103 throw(
"KaryotypeBand must be an Ensembl KaryotypeBand, " .
104 "not a [".ref($k).
"]");
107 if($k->is_stored($db)) {
108 warning(
"KaryotypeBand [".$k->dbID.
"] is already stored" .
109 " in this database.");
115 ($k, $seq_region_id) = $self->_pre_store($k);
117 $sth->bind_param(1,$seq_region_id,SQL_INTEGER);
118 $sth->bind_param(2,$k->start,SQL_INTEGER);
119 $sth->bind_param(3,$k->end,SQL_INTEGER);
120 $sth->bind_param(4,$k->name,SQL_VARCHAR);
121 $sth->bind_param(5,$k->stain,SQL_VARCHAR);
125 $original->dbID($self->last_insert_id(
'karyotype_id', undef,
'karyotype'));
126 $original->adaptor($self);
135 # Description: PROTECTED Implementation of abstract superclass method to
136 # provide the name of the tables to query
137 # Returntype : string
145 return ([
'karyotype',
'k'])
153 # Description: PROTECTED Implementation of abstract superclass method to
154 # provide the name of the columns to query
155 # Returntype : list of strings
162 #warning _objs_from_sth implementation depends on ordering
174 my ($self, $sth) = @_;
175 my $db = $self->db();
176 my $slice_adaptor = $db->get_SliceAdaptor();
181 my($karyotype_id,$seq_region_id,$seq_region_start,$seq_region_end,
184 $sth->bind_columns(\$karyotype_id, \$seq_region_id, \$seq_region_start,
185 \$seq_region_end, \$band, \$stain);
187 while ( $sth->fetch() ) {
188 #need to get the internal_seq_region, if present
189 $seq_region_id = $self->get_seq_region_id_internal($seq_region_id);
191 my $slice = $slice_cache{$seq_region_id} ||=
192 $slice_adaptor->fetch_by_seq_region_id($seq_region_id);
195 $self->_create_feature(
'Bio::EnsEMBL::KaryotypeBand', {
196 -START => $seq_region_start,
197 -END => $seq_region_end,
200 -DBID => $karyotype_id,
212 =head2 fetch_all_by_chr_name
214 Arg [1] :
string $chr_name
215 Name of the chromosome from which to retrieve band objects
216 Example : @bands=@{$karyotype_band_adaptor->fetch_all_by_chr_name(
'X')};
217 Description: Fetches all the karyotype band objects from the database
for the
220 (assembly) coordinates
227 sub fetch_all_by_chr_name {
228 my ($self,$chr_name) = @_;
230 throw(
'Chromosome name argument expected')
if(!$chr_name);
233 $self->db->get_SliceAdaptor->fetch_by_region(undef, $chr_name);
235 warning(
"Cannot retrieve chromosome $chr_name");
238 return $self->fetch_all_by_Slice($slice);
243 sub fetch_all_by_chr_band {
244 my ($self, $chr_name, $band) = @_;
246 throw(
'Chromosome name argument expected')
if(!$chr_name);
247 throw(
'Band argument expected')
if(!$band);
249 my $slice = $self->db->get_SliceAdaptor->fetch_by_region(undef,
252 my $constraint =
"k.band like '$band%'";
253 return $self->fetch_all_by_Slice_constraint($slice,$constraint);
260 Example : @kary_ids = @{$karyotype_band_adaptor->list_dbIDs()};
261 Description: Gets an array of
internal ids
for all karyotype bands in the
263 Arg[1] : <optional>
int. not 0
for the ids to be sorted by the seq_region.
264 Returntype : reference to a list of ints
272 my ($self, $ordered) = @_;
274 return $self->_list_dbIDs(
"karyotype",undef, $ordered);