| 1 | =head1 LICENSE | ||
| 2 | |||
| 3 | See the NOTICE file distributed with this work for additional information | ||
| 4 | regarding copyright ownership. | ||
| 5 | |||
| 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 | ||
| 9 | |||
| 10 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | |||
| 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. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | |||
| 21 | =head1 CONTACT | ||
| 22 | |||
| 23 | Please email comments or questions to the public Ensembl | ||
| 24 | developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. | ||
| 25 | |||
| 26 | Questions may also be sent to the Ensembl help desk at | ||
| 27 | <http://www.ensembl.org/Help/Contact>. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | Bio::EnsEMBL::DBSQL::KaryotypeBand | ||
| 34 | |||
| 35 | =head1 SYNOPSIS | ||
| 36 | |||
| 37 | use Bio::EnsEMBL::KaryotypeBand; | ||
| 38 | |||
| 39 | # Create and populate a karyotype band (normally done by adaptor) | ||
| 40 | $kb = Bio::EnsEMBL::KaryotyeBand( | ||
| 41 | -START => 1, | ||
| 42 | -END => 1_000_000, | ||
| 43 | -SLICE => $chrX_slice, | ||
| 44 | -NAME => 'q31', | ||
| 45 | -STAIN => 'gpos50', | ||
| 46 | -ADAPTOR => $db->get_KaryotypeBandAdaptor(), | ||
| 47 | -DBID => 10 | ||
| 48 | ); | ||
| 49 | |||
| 50 | # Can tranform this band into other coord systems, just like other | ||
| 51 | # features | ||
| 52 | $kb = $kb->transform('supercontig'); | ||
| 53 | |||
| 54 | $start = $kb->start(); | ||
| 55 | $end = $kb->end(); | ||
| 56 | $seq_region = $kb->slice->seq_region_name(); | ||
| 57 | |||
| 58 | # Karyotypes have internal ids as well | ||
| 59 | $kary_id = $kb->dbID(); | ||
| 60 | |||
| 61 | =head1 DESCRIPTION | ||
| 62 | |||
| 63 | KaryotypeBand objects encapsulate data pertaining to a | ||
| 64 | single karyotype band. Access these objects through a | ||
| 65 | Bio::EnsEMBL::DBSQL::KaryotypeBandAdaptor. | ||
| 66 | |||
| 67 | KarytoypeBand inherits from Bio::EnsEMBL::Feature and can be used just | ||
| 68 | as any other feature can be. | ||
| 69 | |||
| 70 | =head1 METHODS | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | package Bio::EnsEMBL::KaryotypeBand; | ||
| 75 | $Bio::EnsEMBL::KaryotypeBand::VERSION = '114.0.0'; | ||
| 76 | use strict; | ||
| 77 | use vars qw(@ISA); | ||
| 78 | |||
| 79 | use Bio::EnsEMBL::Feature; | ||
| 80 | use Bio::EnsEMBL::Utils::Argument qw(rearrange); | ||
| 81 | use Bio::EnsEMBL::Utils::Exception qw(warning); | ||
| 82 | |||
| 83 | @ISA = qw(Bio::EnsEMBL::Feature); | ||
| 84 | |||
| 85 | use constant SEQUENCE_ONTOLOGY => { | ||
| 86 | acc => 'SO:0000341', | ||
| 87 | term => 'chromosome_band', | ||
| 88 | }; | ||
| 89 | |||
| 90 | =head2 new | ||
| 91 | |||
| 92 | Arg [NAME] : string (optional) | ||
| 93 | The name of this band | ||
| 94 | Arg [STAIN]: string (optional) | ||
| 95 | The stain of this band | ||
| 96 | Arg [...] : Arguments passed to superclass constructor. | ||
| 97 | See Bio::EnsEMBL::Feature | ||
| 98 | Example : $kb = Bio::EnsEMBL::KaryotypeBand->new(-START => $start, | ||
| 99 | -END => $end, | ||
| 100 | -SLICE => $slice, | ||
| 101 | -NAME => 'q11.21', | ||
| 102 | -STAIN => 'gneg'); | ||
| 103 | Description: Constructor. Creates a new KaryotypeBand object, which can be | ||
| 104 | treated as any other feature object. Note that karyotypes | ||
| 105 | bands always have strand = 0. | ||
| 106 | Returntype : Bio::EnsEMBL::KarytotypeBand | ||
| 107 | Exceptions : none | ||
| 108 | Caller : Bio::EnsEMBL::KaryotypeBandAdaptor | ||
| 109 | Status : Stable | ||
| 110 | |||
| 111 | =cut | ||
| 112 | |||
| 113 | sub new { | ||
| 114 | my $class = shift; | ||
| 115 | |||
| 116 | my $self = $class->SUPER::new(@_); | ||
| 117 | |||
| 118 | my ($name, $stain) = rearrange(['NAME','STAIN'],@_); | ||
| 119 | $self->{'name'} = $name; | ||
| 120 | $self->{'stain'} = $stain; | ||
| 121 | $self->{'strand'} = 0; | ||
| 122 | |||
| 123 | return $self; | ||
| 124 | } | ||
| 125 | |||
| 126 | |||
| 127 | =head2 name | ||
| 128 | |||
| 129 | Arg [1] : (optional) string $value | ||
| 130 | Example : my $band_name = $band->name(); | ||
| 131 | Description: Getter/Setter for the name of this band | ||
| 132 | Returntype : string | ||
| 133 | Exceptions : none | ||
| 134 | Caller : general | ||
| 135 | Status : Stable | ||
| 136 | |||
| 137 | =cut | ||
| 138 | |||
| 139 | sub name{ | ||
| 140 | my $self = shift; | ||
| 141 | $self->{'name'} = shift if(@_); | ||
| 142 | return $self->{'name'}; | ||
| 143 | } | ||
| 144 | |||
| 145 | |||
| 146 | |||
| 147 | =head2 stain | ||
| 148 | |||
| 149 | Arg [1] : (optional) string $value | ||
| 150 | Example : my $band_stain = $band->stain(); | ||
| 151 | Description: get/set for the band stain (e.g. 'gpos50') | ||
| 152 | Returntype : string | ||
| 153 | Exceptions : none | ||
| 154 | Caller : general | ||
| 155 | Status : Stable | ||
| 156 | |||
| 157 | =cut | ||
| 158 | |||
| 159 | sub stain{ | ||
| 160 | my $self = shift; | ||
| 161 | $self->{'stain'} = shift if(@_); | ||
| 162 | return $self->{'stain'}; | ||
| 163 | } | ||
| 164 | |||
| 165 | |||
| 166 | |||
| 167 | =head2 strand | ||
| 168 | |||
| 169 | Arg [1] : none | ||
| 170 | Example : $strand = $karyotype_feat->strand(); | ||
| 171 | Description: Overrides the Feature strand method to always return a | ||
| 172 | value of 0 for karyotype features (they are unstranded features) | ||
| 173 | Returntype : int (always 0) | ||
| 174 | Exceptions : none | ||
| 175 | Caller : general | ||
| 176 | Status : Stable | ||
| 177 | |||
| 178 | =cut | ||
| 179 | |||
| 180 | sub strand { | ||
| 181 | my $self = shift; | ||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | |||
| 186 | =head2 move | ||
| 187 | |||
| 188 | Arg [1] : $start - The new end of this band | ||
| 189 | Arg [2] : $end - The new start of this band | ||
| 190 | Arg [3] : $strand - ignored always set to 0 | ||
| 191 | Example : $kb->move(1, 10_000); | ||
| 192 | Description: Overrides superclass move() method to ensure strand is always 0. | ||
| 193 | See Bio::EnsEMBL::Feature::move | ||
| 194 | Returntype : none | ||
| 195 | Exceptions : none | ||
| 196 | Caller : general | ||
| 197 | Status : Stable | ||
| 198 | |||
| 199 | =cut | ||
| 200 | |||
| 201 | sub move { | ||
| 202 | my ($self, $start, $end, $strand) = @_; | ||
| 203 | |||
| 204 | #maintain a strandedness of 0 | ||
| 205 | return $self->SUPER::move($start,$end,0); | ||
| 206 | } | ||
| 207 | |||
| 208 | |||
| 209 | =head2 display_id | ||
| 210 | |||
| 211 | Arg [1] : none | ||
| 212 | Example : print $kb->display_id(); | ||
| 213 | Description: This method returns a string that is considered to be | ||
| 214 | the 'display' identifier. For karyotype bands this is the | ||
| 215 | name of the karyotype band or '' if no name is defined. | ||
| 216 | Returntype : string | ||
| 217 | Exceptions : none | ||
| 218 | Caller : web drawing code | ||
| 219 | Status : Stable | ||
| 220 | |||
| 221 | =cut | ||
| 222 | |||
| 223 | sub display_id { | ||
| 224 | my $self = shift; | ||
| 225 | return $self->{'name'} || ''; | ||
| 226 | } | ||
| 227 | |||
| 228 | |||
| 229 | =head2 summary_as_hash | ||
| 230 | |||
| 231 | Example : $karyotype_band_summary = $band->summary_as_hash(); | ||
| 232 | Description : Extends Feature::summary_as_hash | ||
| 233 | Retrieves a summary of this Karyotype object. | ||
| 234 | |||
| 235 | Returns : hashref of arrays of descriptive strings | ||
| 236 | Status : Intended for internal use | ||
| 237 | =cut | ||
| 238 | |||
| 239 | sub summary_as_hash { | ||
| 240 | my $self = shift; | ||
| 241 | my $summary_ref = $self->SUPER::summary_as_hash; | ||
| 242 | $summary_ref->{'stain'} = $self->stain; | ||
| 243 | |||
| 244 | return $summary_ref; | ||
| 245 | } | ||
| 246 | |||
| 247 | |||
| 248 | 1; |