| 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::AssemblyExceptionFeature - A feature that represents an assembly exception | ||
| 34 | |||
| 35 | =head1 SYNOPSIS | ||
| 36 | |||
| 37 | use Bio::EnsEMBL::AssemblyExceptionFeature; | ||
| 38 | |||
| 39 | $feature = Bio::EnsEMBL::AssemblyExceptionFeature->new( | ||
| 40 | -start => 100, | ||
| 41 | -end => 220, | ||
| 42 | -type => 'HAP', | ||
| 43 | -slice => $slice, | ||
| 44 | -adaptor => $adaptor | ||
| 45 | ); | ||
| 46 | |||
| 47 | =head1 DESCRIPTION | ||
| 48 | |||
| 49 | Certain features, e.g. Haplotypes and PARs, are represented as | ||
| 50 | "exceptions" to the normal assembly. This class represents such | ||
| 51 | features. | ||
| 52 | |||
| 53 | =head1 METHODS | ||
| 54 | |||
| 55 | =cut | ||
| 56 | |||
| 57 | package Bio::EnsEMBL::AssemblyExceptionFeature; | ||
| 58 | $Bio::EnsEMBL::AssemblyExceptionFeature::VERSION = '114.0.0'; | ||
| 59 | use strict; | ||
| 60 | |||
| 61 | use vars qw(@ISA); | ||
| 62 | |||
| 63 | use Bio::EnsEMBL::Feature; | ||
| 64 | use Bio::EnsEMBL::Utils::Argument qw(rearrange); | ||
| 65 | use Scalar::Util qw(weaken isweak); | ||
| 66 | |||
| 67 | @ISA = qw(Bio::EnsEMBL::Feature); | ||
| 68 | |||
| 69 | |||
| 70 | =head2 new | ||
| 71 | |||
| 72 | Arg [TYPE] : The type (e.g. HAP for haplotype, PAR for PAR) | ||
| 73 | Arg [...] : Named arguments passed to superclass | ||
| 74 | Example : $feature = Bio::EnsEMBL::AssemblyExceptionFeature->new | ||
| 75 | (-start => 1, | ||
| 76 | -end => 100, | ||
| 77 | -slice => $slice, | ||
| 78 | -alternate_slice => $alt_slice, | ||
| 79 | -adaptor => $adaptor, | ||
| 80 | -type => 'HAP') | ||
| 81 | Description: Constructs a new Bio::EnsEMBL::Feature. Generally subclasses | ||
| 82 | of this method are instantiated, rather than this class itself. | ||
| 83 | Returntype : Bio::EnsEMBL::Feature | ||
| 84 | Exceptions : Thrown on invalid -SLICE arguments | ||
| 85 | Caller : general, subclass constructors | ||
| 86 | Status : Stable | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | sub new { | ||
| 91 | |||
| 92 | my $caller = shift; | ||
| 93 | |||
| 94 | # allow this to be called as class or object method | ||
| 95 | my $class = ref($caller) || $caller; | ||
| 96 | my $self = $class->SUPER::new(@_); | ||
| 97 | |||
| 98 | my ($type, $alternate_slice) = rearrange(['TYPE', 'ALTERNATE_SLICE'],@_); | ||
| 99 | $self->{'type'} = $type; | ||
| 100 | $self->{'alternate_slice'} = $alternate_slice; | ||
| 101 | |||
| 102 | return $self; | ||
| 103 | } | ||
| 104 | |||
| 105 | |||
| 106 | =head2 type | ||
| 107 | |||
| 108 | Arg [1] : (optional) string $value | ||
| 109 | Example : $type = $assembly_exception_feature->type(); | ||
| 110 | Description: Getter/Setter for the type associated with this | ||
| 111 | feature. | ||
| 112 | Returntype : string | ||
| 113 | Exceptions : none | ||
| 114 | Caller : general | ||
| 115 | Status : Stable | ||
| 116 | |||
| 117 | =cut | ||
| 118 | |||
| 119 | sub type { | ||
| 120 | |||
| 121 | my $self = shift; | ||
| 122 | |||
| 123 | $self->{'type'} = shift if(@_); | ||
| 124 | |||
| 125 | return $self->{'type'}; | ||
| 126 | } | ||
| 127 | |||
| 128 | |||
| 129 | =head2 alternate_slice | ||
| 130 | |||
| 131 | Arg [1] : (optional) string $value | ||
| 132 | Example : $alt_slice = $assembly_exception_feature->alternate_slice(); | ||
| 133 | Description: Getter/Setter for the alternate slice associated with this feature. | ||
| 134 | The alternate slice represents the "other side" of the AssemblyExceptionFeature. | ||
| 135 | Returntype : Bio::EnsEMBL::Slice | ||
| 136 | Exceptions : none | ||
| 137 | Caller : general | ||
| 138 | Status : Stable | ||
| 139 | |||
| 140 | =cut | ||
| 141 | |||
| 142 | sub alternate_slice { | ||
| 143 | |||
| 144 | my $self = shift; | ||
| 145 | |||
| 146 | $self->{'alternate_slice'} = shift if(@_); | ||
| 147 | |||
| 148 | return $self->{'alternate_slice'}; | ||
| 149 | } | ||
| 150 | |||
| 151 | |||
| 152 | |||
| 153 | =head2 display_id | ||
| 154 | |||
| 155 | Arg [1] : none | ||
| 156 | Example : print $aef->display_id(); | ||
| 157 | Description: This method returns a string that is considered to be | ||
| 158 | the 'display' identifier. For assembly exception features | ||
| 159 | this is the name of the alternate seqregion or '' if the | ||
| 160 | alternate slice is not defined. | ||
| 161 | Returntype : string | ||
| 162 | Exceptions : none | ||
| 163 | Caller : web drawing code | ||
| 164 | Status : Stable | ||
| 165 | |||
| 166 | =cut | ||
| 167 | |||
| 168 | sub display_id { | ||
| 169 | my $self = shift; | ||
| 170 | my $slice = $self->{'alternate_slice'}; | ||
| 171 | return '' if(!$slice); | ||
| 172 | return $slice->seq_region_name(); | ||
| 173 | } | ||
| 174 | |||
| 175 | |||
| 176 | |||
| 177 | 1; |