| 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::RepeatFeature - A feature representing a repeat on a piece of | ||
| 34 | sequence. | ||
| 35 | |||
| 36 | =head1 SYNOPSIS | ||
| 37 | |||
| 38 | my $rf = new Bio::EnsEMBL::Feature( | ||
| 39 | -start => 100, | ||
| 40 | -end => 220, | ||
| 41 | -strand => -1, | ||
| 42 | -slice => $slice, | ||
| 43 | -analysis => $analysis, | ||
| 44 | -repeat_consensus => $rc, | ||
| 45 | -hstart => 10, | ||
| 46 | -hend => 100, | ||
| 47 | -hstrand => 1, | ||
| 48 | -score => 83.2 | ||
| 49 | ); | ||
| 50 | |||
| 51 | my $hstart = $feat->hstart; | ||
| 52 | my $hend = $feat->hend; | ||
| 53 | |||
| 54 | # move the feature to the chromosomal coordinate system | ||
| 55 | $feature = $feature->transform('chromosome'); | ||
| 56 | |||
| 57 | # move the feature to a different slice | ||
| 58 | # (possibly on another coord system) | ||
| 59 | $feature = $feature->transfer($new_slice); | ||
| 60 | |||
| 61 | # project the feature onto another coordinate system possibly across | ||
| 62 | # boundaries: | ||
| 63 | @projection = @{ $feature->project('contig') }; | ||
| 64 | |||
| 65 | # change the start, end, and strand of the feature in place | ||
| 66 | $feature->move( $new_start, $new_end, $new_strand ); | ||
| 67 | |||
| 68 | =head1 DESCRIPTION | ||
| 69 | |||
| 70 | This a feature representing a repeat region on a sequence | ||
| 71 | |||
| 72 | =head1 METHODS | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | package Bio::EnsEMBL::RepeatFeature; | ||
| 77 | $Bio::EnsEMBL::RepeatFeature::VERSION = '114.0.0'; | ||
| 78 | use strict; | ||
| 79 | |||
| 80 | use Bio::EnsEMBL::Utils::Exception qw(throw); | ||
| 81 | use Bio::EnsEMBL::Utils::Argument qw(rearrange); | ||
| 82 | |||
| 83 | use base qw/Bio::EnsEMBL::Feature/; | ||
| 84 | |||
| 85 | use constant SEQUENCE_ONTOLOGY => { | ||
| 86 | acc => 'SO:0000657', | ||
| 87 | term => 'repeat_region', | ||
| 88 | }; | ||
| 89 | |||
| 90 | =head2 new | ||
| 91 | |||
| 92 | Arg [REPEAT_CONSENSUS] : Bio::EnsEMBL::RepeatConsensus (optional) | ||
| 93 | The repeat consensus for this repeat feature | ||
| 94 | Arg [HSTART] : int (optional) | ||
| 95 | The hit start on the consensus sequence | ||
| 96 | Arg [HEND] : int (optional) | ||
| 97 | The hit end on the consensus sequence | ||
| 98 | Arg [SCORE] : float (optional) | ||
| 99 | The score | ||
| 100 | Arg [...] : Named arguments to superclass constructor | ||
| 101 | (see Bio::EnsEMBL::Feaure) | ||
| 102 | Example : $rf = Bio::EnsEMBL::RepeatFeature->new(-REPEAT_CONSENSUS => $rc, | ||
| 103 | -HSTART => 10, | ||
| 104 | -HEND => 100, | ||
| 105 | -SCORE => 58.0, | ||
| 106 | -START => 1_000_100, | ||
| 107 | -END => 1_000_190, | ||
| 108 | -STRAND => 1, | ||
| 109 | -ANALYSIS => $an, | ||
| 110 | -SLICE => $chr_slice); | ||
| 111 | Description: Creates a new Bio::EnsEMBL::RepeatFeature object | ||
| 112 | Returntype : Bio::EnsEMBL::RepeatFeature | ||
| 113 | Exceptions : none | ||
| 114 | Caller : RepeatFeatureAdaptors | ||
| 115 | Status : Stable | ||
| 116 | |||
| 117 | =cut | ||
| 118 | |||
| 119 | sub new { | ||
| 120 | my $caller = shift; | ||
| 121 | |||
| 122 | my $class = ref($caller) || $caller; | ||
| 123 | |||
| 124 | my $self = $class->SUPER::new(@_); | ||
| 125 | |||
| 126 | my ($repeat_consensus, $hstart, $hend, $score) = | ||
| 127 | rearrange(['REPEAT_CONSENSUS','HSTART','HEND','SCORE'], @_); | ||
| 128 | |||
| 129 | $self->repeat_consensus($repeat_consensus); | ||
| 130 | $self->{'hstart'} = $hstart; | ||
| 131 | $self->{'hend'} = $hend; | ||
| 132 | $self->{'score'} = $score; | ||
| 133 | |||
| 134 | return $self; | ||
| 135 | } | ||
| 136 | |||
| 137 | |||
| 138 | =head2 repeat_consensus | ||
| 139 | |||
| 140 | Arg [1] : (optional) Bio::EnsEMBL::RepeatConsensus | ||
| 141 | Example : $repeat_consensus = $repeat->repeat_consensus; | ||
| 142 | Description: Getter/Setter for the repeat consensus of this repeat | ||
| 143 | Returntype : Bio::EnsEMBL::RepeatConsensus | ||
| 144 | Exceptions : none | ||
| 145 | Caller : general | ||
| 146 | Status : Stable | ||
| 147 | |||
| 148 | =cut | ||
| 149 | |||
| 150 | sub repeat_consensus { | ||
| 151 | my $self = shift; | ||
| 152 | |||
| 153 | if(@_) { | ||
| 154 | my $rc = shift; | ||
| 155 | if(defined($rc)) { | ||
| 156 | if(!ref($rc) || !$rc->isa('Bio::EnsEMBL::RepeatConsensus')) { | ||
| 157 | throw('RepeatConsensus arg must be a Bio::EnsEMBL::RepeatConsensus'); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | $self->{'repeat_consensus'} = $rc; | ||
| 161 | } | ||
| 162 | |||
| 163 | return $self->{'repeat_consensus'}; | ||
| 164 | } | ||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | =head2 hstart | ||
| 169 | |||
| 170 | Arg [1] : (optional) int $hstart | ||
| 171 | Example : $hit_start = $repeat->hstart; | ||
| 172 | Description: Getter/Setter for the start bp of this repeat match on the | ||
| 173 | consensus sequence. | ||
| 174 | Returntype : int | ||
| 175 | Exceptions : none | ||
| 176 | Caller : general | ||
| 177 | Status : Stable | ||
| 178 | |||
| 179 | =cut | ||
| 180 | |||
| 181 | sub hstart { | ||
| 182 | my $self = shift; | ||
| 183 | $self->{'hstart'} = shift if(@_); | ||
| 184 | return $self->{'hstart'}; | ||
| 185 | } | ||
| 186 | |||
| 187 | |||
| 188 | =head2 score | ||
| 189 | |||
| 190 | Arg [1] : (optional) float $score | ||
| 191 | Example : $score = $repeat->score(); | ||
| 192 | Description: Getter/Setter for the score of this repeat feature | ||
| 193 | Returntype : int | ||
| 194 | Exceptions : none | ||
| 195 | Caller : general | ||
| 196 | Status : Stable | ||
| 197 | |||
| 198 | =cut | ||
| 199 | |||
| 200 | sub score { | ||
| 201 | my $self = shift; | ||
| 202 | $self->{'score'} = shift if(@_); | ||
| 203 | return $self->{'score'}; | ||
| 204 | } | ||
| 205 | |||
| 206 | |||
| 207 | |||
| 208 | =head2 hend | ||
| 209 | |||
| 210 | Arg [1] : (optional) int $hend | ||
| 211 | Example : $hit_end = $repeat->hend; | ||
| 212 | Description: Getter/Setter for the end bp of this repeat match on the | ||
| 213 | consensus sequence. | ||
| 214 | Returntype : int | ||
| 215 | Exceptions : none | ||
| 216 | Caller : general | ||
| 217 | Status : Stable | ||
| 218 | |||
| 219 | =cut | ||
| 220 | |||
| 221 | sub hend { | ||
| 222 | my $self = shift; | ||
| 223 | $self->{'hend'} = shift if(@_); | ||
| 224 | return $self->{'hend'}; | ||
| 225 | } | ||
| 226 | |||
| 227 | |||
| 228 | |||
| 229 | =head2 hstrand | ||
| 230 | |||
| 231 | Arg [1] : none | ||
| 232 | Example : none | ||
| 233 | Description: always returns 1. method exists for consistancy with other | ||
| 234 | features. | ||
| 235 | Returntype : int | ||
| 236 | Exceptions : none | ||
| 237 | Caller : general | ||
| 238 | Status : Stable | ||
| 239 | |||
| 240 | =cut | ||
| 241 | |||
| 242 | sub hstrand { | ||
| 243 | return 1; | ||
| 244 | } | ||
| 245 | |||
| 246 | |||
| 247 | =head2 display_id | ||
| 248 | |||
| 249 | Arg [1] : none | ||
| 250 | Example : print $rf->display_id(); | ||
| 251 | Description: This method returns a string that is considered to be | ||
| 252 | the 'display' identifier. For repeat_features this is the | ||
| 253 | name of the repeat consensus if it is available otherwise it is | ||
| 254 | an empty string. | ||
| 255 | Returntype : string | ||
| 256 | Exceptions : none | ||
| 257 | Caller : web drawing code | ||
| 258 | Status : Stable | ||
| 259 | |||
| 260 | =cut | ||
| 261 | |||
| 262 | sub display_id { | ||
| 263 | my $self = shift; | ||
| 264 | |||
| 265 | my $id = ''; | ||
| 266 | |||
| 267 | my $rc = $self->{'repeat_consensus'}; | ||
| 268 | if($rc) { | ||
| 269 | $id = $rc->name(); | ||
| 270 | } | ||
| 271 | |||
| 272 | return $id; | ||
| 273 | } | ||
| 274 | |||
| 275 | |||
| 276 | =head2 summary_as_hash | ||
| 277 | |||
| 278 | Example : $repeat_feature_summary = $protein_feature->summary_as_hash(); | ||
| 279 | Description : Retrieves a textual summary of this Repeat feature. | ||
| 280 | Not inherited from Feature. | ||
| 281 | Returns : hashref of arrays of descriptive strings | ||
| 282 | Status : Intended for internal use | ||
| 283 | =cut | ||
| 284 | |||
| 285 | sub summary_as_hash { | ||
| 286 | my $self = shift; | ||
| 287 | my %summary; | ||
| 288 | $summary{'start'} = $self->seq_region_start; | ||
| 289 | $summary{'end'} = $self->seq_region_end; | ||
| 290 | $summary{'strand'} = $self->strand; | ||
| 291 | $summary{'seq_region_name'} = $self->seq_region_name; | ||
| 292 | $summary{'description'} = $self->display_id; | ||
| 293 | $summary{'assembly_name'} = $self->slice->coord_system->version(); | ||
| 294 | return \%summary; | ||
| 295 | } | ||
| 296 | |||
| 297 | |||
| 298 | |||
| 299 | 1; | ||
| 300 | |||
| 301 | __END__ |