[bug 2714]
[bioperl-live.git] / Bio / LiveSeq / Mutation.pm
blob98ba2d9e5ac0742b8475ebb2462f6cec5f5b3529
1 # $Id$
3 # BioPerl module for Bio::LiveSeq::Mutation
5 # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
7 # Copyright Heikki Lehvaslaiho
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 =head1 NAME
15 Bio::LiveSeq::Mutation - Mutation event descriptor class
17 =head1 SYNOPSIS
19 # full descrition of a point mutation
20 $mutation1a = Bio::LiveSeq::Mutation->new ( -seq => 'A',
21 -seqori => 'T',
22 -pos => 100,
23 -len => 1 # optional, defaults to length(seq)
26 # minimal information for a point mutation
27 $mutation1b = Bio::LiveSeq::Mutation->new ( -seq => 'A',
28 -pos => 100
30 # insertion
31 $mutation2 = Bio::LiveSeq::Mutation->new ( -seq => 'ATT',
32 -pos => 100,
33 -len => 0
35 # deletion
36 $mutation3 = Bio::LiveSeq::Mutation->new ( -seq => '', # optional
37 -seqori => 'TTG', # optional
38 -pos => 100
39 -len => 3
41 # complex
42 $mutation4 = Bio::LiveSeq::Mutation->new ( -seq => 'CC',
43 -seqori => 'TTG', # optional
44 -pos => 100
45 -len => 3
49 =head1 DESCRIPTION
51 This class describes a local mutation event using minimalistic
52 description. It is not necessary to know anything about the original
53 sequence. You need to give the changed sequence, the position of the
54 mutation in the (unidentified) reference sequence, and the length of
55 the affected subsequence in the reference sequence. If the original
56 allele sequence is given, the objects applying the mutation into the
57 reference sequence (e.g. L<Bio::LiveSeq::Mutator>) might check for its
58 validity.
60 =head1 FEEDBACK
62 =head2 Mailing Lists
64 User feedback is an integral part of the evolution of this and other
65 Bioperl modules. Send your comments and suggestions preferably to the
66 Bioperl mailing lists Your participation is much appreciated.
68 bioperl-l@bioperl.org - General discussion
69 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
71 =head2 Reporting Bugs
73 report bugs to the Bioperl bug tracking system to help us keep track
74 the bugs and their resolution. Bug reports can be submitted via the
75 web:
77 http://bugzilla.open-bio.org/
79 =head1 AUTHOR - Heikki Lehvaslaiho
81 Email: heikki-at-bioperl-dot-org
83 =head1 APPENDIX
85 The rest of the documentation details each of the object
86 methods. Internal methods are usually preceded with a _
88 =cut
91 # Let the code begin...
93 package Bio::LiveSeq::Mutation;
94 use strict;
96 # Object preamble - inheritance
99 use base qw(Bio::Root::Root);
101 sub new {
102 my($class,@args) = @_;
103 my $self;
104 $self = {};
105 bless $self, $class;
107 my ($seq, $seqori, $pos, $len, $label) =
108 $self->_rearrange([qw(SEQ
109 SEQORI
113 @args);
115 $seq && $self->seq($seq);
116 $seqori && $self->seqori($seqori);
117 $pos && $self->pos($pos);
118 defined($len) && $self->len($len); # defined() added otherwise won't work for len==0
120 return $self; # success - we hope!
124 =head2 seq
126 Title : seq
127 Usage : $obj->seq();
128 Function:
130 Sets and returns the mutated sequence. No checking is done
131 to validate the symbols.
133 Example :
134 Returns : string
135 Args : integer
137 =cut
140 sub seq {
141 my ($self,$value) = @_;
142 if( defined $value) {
143 $self->{'seq'} = $value;
145 return $self->{'seq'} || '';
149 =head2 seqori
151 Title : seqori
152 Usage : $obj->seqori();
153 Function:
155 Sets and returns the original subsequence in the reference
156 sequence. No checking is done to validate the symbols.
157 Optional value.
159 Example :
160 Returns : string
161 Args : string
163 =cut
166 sub seqori {
167 my ($self,$value) = @_;
168 if( defined $value) {
169 $self->{'seqori'} = $value;
171 return $self->{'seqori'} || '';
175 =head2 pos
177 Title : pos
178 Usage : $obj->pos();
179 Function:
181 Sets and returns the position of the first element in the
182 sequence.
184 Example :
185 Returns : string
186 Args : integer
188 =cut
191 sub pos {
192 my ($self,$value) = @_;
193 if( defined $value) {
194 if ( $value !~ /^([+-])?\d+$/ ) {
195 $self->throw("[$value] for pos has to be an integer\n");
196 } else {
197 $self->{'pos'} = $value;
200 return $self->{'pos'};
203 =head2 len
205 Title : len
206 Usage : $obj->len();
207 Function:
209 Sets and returns the len of the affected original allele
210 sequence. If value is not set, defaults to the lenght of
211 the mutated sequence (seq).
213 Example :
214 Returns : string
215 Args : string
217 =cut
219 sub len {
220 my ($self,$value) = @_;
221 if ( defined $value) {
222 $self->{'len'} = $value;
224 if ( ! exists $self->{'len'} ) {
225 return length $self->{'seq'};
227 return $self->{'len'};
230 =head2 label
232 Title : label
233 Usage : $obj->label();
234 Function:
236 Sets and returns the label of the affected original allele
237 location. Label is a stable identifier whereas location
238 can be changed by mutations. Label comes from
239 l<Bio::LiveSeq::Gene>.
241 Example :
242 Returns : string
243 Args : string
245 =cut
247 sub label {
248 my ($self,$value) = @_;
249 if ( defined $value) {
250 $self->{'label'} = $value;
252 if ( ! exists $self->{'label'} ) {
253 return;
255 return $self->{'label'};
259 =head2 transpos
261 Title : transpos
262 Usage : $obj->transpos();
263 Function:
265 Sets and returns the transcript position of the mutation.
266 Set when associated with a reference sequence. Value
267 depends on reference molecule and the co-ordinate system
268 used.
270 Example :
271 Returns : string
272 Args : integer
274 =cut
277 sub transpos {
278 my ($self,$value) = @_;
279 if( defined $value) {
280 if ( $value !~ /^([+-])?\d+$/ ) {
281 $self->throw("[$value] for transpos has to be an integer\n");
282 } else {
283 $self->{'transpos'} = $value;
286 return $self->{'transpos'};
290 =head2 issue
292 Title : issue
293 Usage : $obj->issue();
294 Function:
296 Sets and returns the position of the mutation in an array
297 of mutations to be issued. Set after the validity of the
298 mutation has been confirmed.
300 Example :
301 Returns : string
302 Args : integer
304 =cut
307 sub issue {
308 my ($self,$value) = @_;
309 if( defined $value) {
310 if ( $value !~ /^([+-])?\d+$/ ) {
311 $self->throw("[$value] for issue has to be an integer\n");
312 } else {
313 $self->{'issue'} = $value;
316 return $self->{'issue'};
320 =head2 prelabel
322 Title : prelabel
323 Usage : $obj->prelabel();
324 Function:
326 Sets and returns the prelabel of the affected original allele
327 location. Prelabel is a stable identifier whereas location
328 can be changed by mutations. Prelabel comes from
329 l<Bio::LiveSeq::Gene>.
331 Example :
332 Returns : string
333 Args : string
335 =cut
337 sub prelabel {
338 my ($self,$value) = @_;
339 if ( defined $value) {
340 $self->{'prelabel'} = $value;
342 if ( ! exists $self->{'prelabel'} ) {
343 return;
345 return $self->{'prelabel'};
349 =head2 postlabel
351 Title : postlabel
352 Usage : $obj->postlabel();
353 Function:
355 Sets and returns the postlabel of the affected original allele
356 location. Postlabel is a stable identifier whereas location
357 can be changed by mutations. Postlabel comes from
358 l<Bio::LiveSeq::Gene>.
360 Example :
361 Returns : string
362 Args : string
364 =cut
366 sub postlabel {
367 my ($self,$value) = @_;
368 if ( defined $value) {
369 $self->{'postlabel'} = $value;
371 if ( ! exists $self->{'postlabel'} ) {
372 return;
374 return $self->{'postlabel'};
378 =head2 lastlabel
380 Title : lastlabel
381 Usage : $obj->lastlabel();
382 Function:
384 Sets and returns the lastlabel of the affected original allele
385 location. Lastlabel is a stable identifier whereas location
386 can be changed by mutations. Lastlabel comes from
387 l<Bio::LiveSeq::Gene>.
389 Example :
390 Returns : string
391 Args : string
393 =cut
395 sub lastlabel {
396 my ($self,$value) = @_;
397 if ( defined $value) {
398 $self->{'lastlabel'} = $value;
400 if ( ! exists $self->{'lastlabel'} ) {
401 return;
403 return $self->{'lastlabel'};