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
33 Bio::EnsEMBL:SeqEdit - A
class representing a post transcriptional edit to a
41 # construct a SeqEdit object using a Transcript attribute
43 ($attribute) = @{ $translation->get_all_Attributes(
'_rna_edit') };
47 print $seq_edit->start(),
"\n";
48 print $seq_edit->end(),
"\n";
49 print $seq_edit->alt_seq(),
"\n";
51 # apply the edit to some sequence
52 $seq = $transcript->spliced_seq();
53 print
"Before modifiction: $seq\n";
55 $seq_edit->apply_edit( \$seq );
56 print
"After modification: $seq\n";
58 # construct an attribute object from a SeqEdit and add it to a
62 -CODE =>
'_selenocysteine',
63 -NAME =>
'Selenocysteine',
64 -DESC =>
'Selenocysteine',
71 $translation->add_Attributes($attribute);
75 This is a
class used to represent post transcriptional
76 modifications to sequences.
SeqEdit objects are stored as ordinary
77 Bio::EnsEMBL::Attributes with a parseable value and can be used to
78 represent RNA editing, selenocysteines etc.
80 Also see B<Bio::EnsEMBL::Attribute>
100 Can only be provided if no other constructor arguments
102 Arg [-START] : The start position of the edit.
103 Arg [-END] : The end position of the edit.
104 Arg [-ALT_SEQ] : The alternate sequence
105 Arg [-CODE] : A code for this
SeqEdit
106 Arg [-NAME] : A name for this
SeqEdit
107 Arg [-DESCRIPTION] : Arg passed to superclass constructor
113 -CODE => '_rna_edit',
115 -DESCRIPTION => 'RNA edit');
116 Description: Constructs a
SeqEdit representing a single edit to a
117 sequence, such as an rna modification or a selenocysteine.
119 Exceptions : throws if attribute set and other args aswell
120 throws if start and end not set correctly of attribure not set
129 my ($attrib, $start, $end, $alt_seq, $name, $desc, $code) =
130 rearrange([qw(ATTRIB START END ALT_SEQ NAME DESCRIPTION CODE)], @_);
135 if(defined($start) || defined($end) || defined($alt_seq) ||
136 defined($name) || defined($desc) || defined($code)) {
137 throw(
"Cannot specify -ATTRIB argument with additional arguments.");
140 if(!ref($attrib) || !$attrib->isa(
'Bio::EnsEMBL::Attribute')) {
141 throw(
'Bio::EnsEMBL::Attribute argument expected.');
144 ($start, $end, $alt_seq) = split(/\s+/, $attrib->value());
146 if($start !~ /\d+/ || $end !~ /\d+/) {
147 throw(
'Could not parse value of attribute: '.$attrib->value());
150 $name = $attrib->name();
151 $code = $attrib->code();
152 $desc = $attrib->description();
157 if(defined($end) && defined($start) && $start > $end+1) {
158 throw(
"start must be less than or equal to end + 1");
161 if(defined($start) && $start < 1) {
162 throw(
"start must be greater than or equal to 1");
165 if(defined($end) && $end < 0) {
166 throw(
"end must be greater than or equal to 0");
171 return bless {
'start' => $start,
173 'alt_seq' => $alt_seq,
174 'description' => $desc,
176 'code' => $code}, $class;
183 Arg [1] : (optional)
int $start - the
new start position
184 Example : $start = $se_attrib->start();
185 Description: Getter/Setter
for the start position of the region replaced
188 Coordinates are inclusive and one-based, which means that
189 inserts are unusually represented by a start 1bp higher than
192 E.g. start = 1, end = 1 is a replacement of the first base but
193 start = 1, end = 0 is an insert BEFORE the first base.
206 if(defined($start) && $start < 1) {
207 throw(
"start must be greater than or equal to 1");
209 $self->{
'start'} = $start;
212 return $self->{
'start'};
218 Arg [1] : (optional)
int $end - the
new end position
219 Example : $end = $se_attrib->
end();
220 Description: Getter/Setter
for the end position of the region replaced
223 Coordinates are inclusive and one-based, which means that
224 inserts are unusually represented by a start 1bp higher than
227 E.g. start = 1, end = 1 is a replacement of the first base but
228 start = 1, end = 0 is an insert BEFORE the first base.
230 Exceptions :
throws if end <= 0
231 Caller : Transcript, Translation
241 if(defined($end) && $end < 0) {
242 throw(
"end must be greater than or equal to 0");
244 $self->{
'end'} = $end;
247 return $self->{
'end'};
253 Arg [1] : (optional)
string $alt_seq
254 Example : my $alt_seq = $se_attrib->alt_seq();
255 Description: Getter/Setter
for the replacement sequence used by
this edit.
256 The sequence may either be a
string of amino acids or
257 nucleotides depending on the context in which
this edit is
260 In the
case of a deletion the replacement sequence is an empty
264 Caller : Transcript, Translation
271 $self->{
'alt_seq'} = shift ||
'' if(@_);
272 return $self->{
'alt_seq'};
279 Example : my $diff = $sea->length_diff();
280 Description: Returns the difference in length caused by applying
this
281 edit to a sequence. This may be be negative (deletion),
282 positive (insertion) or 0 (replacement).
284 If either start or end are not defined 0 is returned.
295 return 0
if(!defined($self->{
'end'}) || !defined($self->{
'start'}));
297 return length($self->{
'alt_seq'}) - ($self->{
'end'} - $self->{
'start'} + 1);
304 Arg [1] : (optional)
string $name
305 Example : my $name = $seqedit->name();
306 Description: Getter/Setter
for the name of
this SeqEdit
316 $self->{
'name'} = shift
if(@_);
317 return $self->{
'name'};
325 Arg [1] : (optional)
string $code
326 Example : my $code = $seqedit->code();
327 Description: Getter/Setter
for the code of
this SeqEdit
337 $self->{
'code'} = shift
if(@_);
338 return $self->{
'code'};
345 Arg [1] : (optional)
string $desc
346 Example : my $desc = $seqedit->description();
347 Description: Getter/Setter
for the description of
this SeqEdit
357 $self->{
'description'} = shift
if(@_);
358 return $self->{
'description'};
366 Example : my $attrib = $seqedit->get_Attribute();
367 $transcript->add_Attributes($attrib);
368 Description: Converts a SeqEdit
object into an Attribute
object. This
369 allows the SeqEdit to be stored as any other attribute in the
370 ensembl database. The start/end and alt_seq properties
371 should be set before calling
this method.
373 Exceptions : warning
if start/end or alt_seq properties are not defined
382 my $start = $self->start();
383 my $end = $self->end();
384 my $alt_seq = $self->alt_seq();
388 if(defined($start) && defined($end) && defined($alt_seq)) {
389 $value = join(
' ', $start, $end, $alt_seq);
391 warning(
'Attribute value cannot be created unless start, end and alt_seq' .
392 'properties are defined');
398 -NAME => $self->name(),
399 -DESCRIPTION => $self->description());
405 Arg [1] : reference to
string $seqref
406 Example : $sequence =
'ACTGAATATTTAAGGCA';
407 $seqedit->apply_edit(\$sequence);
408 print $sequence,
"\n";
409 Description: Applies
this edit directly to a sequence which is
410 passed by reference. The coordinates of
this SeqEdit
411 are assumed to be relative to the start of the sequence
413 If either the start or end of
this SeqEdit are not defined
414 this function will not
do anything to the passed sequence.
415 Returntype : reference to the same sequence that was passed in
417 Caller : Transcript, Translation
426 if(ref($seqref) ne
'SCALAR') {
427 throw(
"Reference to scalar argument expected");
430 if(!defined($self->{
'start'}) || !defined($self->{
'end'})) {
434 my $len = $self->{
'end'} - $self->{
'start'} + 1;
435 substr($$seqref, $self->{
'start'} - 1, $len) = $self->{
'alt_seq'};