t/AlignIO/AlignIO.t: fix number of tests in plan (fixup c523e6bed866)
[bioperl-live.git] / Bio / LiveSeq / Mutation.pm
blob823ae8c5f95661ddfbb14525c66d5f6aec867faf
2 # BioPerl module for Bio::LiveSeq::Mutation
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
8 # Copyright Heikki Lehvaslaiho
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::LiveSeq::Mutation - Mutation event descriptor class
18 =head1 SYNOPSIS
20 # full description of a point mutation
21 $mutation1a = Bio::LiveSeq::Mutation->new ( -seq => 'A',
22 -seqori => 'T',
23 -pos => 100,
24 -len => 1 # optional, defaults to length(seq)
27 # minimal information for a point mutation
28 $mutation1b = Bio::LiveSeq::Mutation->new ( -seq => 'A',
29 -pos => 100
31 # insertion
32 $mutation2 = Bio::LiveSeq::Mutation->new ( -seq => 'ATT',
33 -pos => 100,
34 -len => 0
36 # deletion
37 $mutation3 = Bio::LiveSeq::Mutation->new ( -seq => '', # optional
38 -seqori => 'TTG', # optional
39 -pos => 100
40 -len => 3
42 # complex
43 $mutation4 = Bio::LiveSeq::Mutation->new ( -seq => 'CC',
44 -seqori => 'TTG', # optional
45 -pos => 100
46 -len => 3
50 =head1 DESCRIPTION
52 This class describes a local mutation event using minimalistic
53 description. It is not necessary to know anything about the original
54 sequence. You need to give the changed sequence, the position of the
55 mutation in the (unidentified) reference sequence, and the length of
56 the affected subsequence in the reference sequence. If the original
57 allele sequence is given, the objects applying the mutation into the
58 reference sequence (e.g. L<Bio::LiveSeq::Mutator>) might check for its
59 validity.
61 =head1 FEEDBACK
63 =head2 Mailing Lists
65 User feedback is an integral part of the evolution of this and other
66 Bioperl modules. Send your comments and suggestions preferably to the
67 Bioperl mailing lists Your participation is much appreciated.
69 bioperl-l@bioperl.org - General discussion
70 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
72 =head2 Support
74 Please direct usage questions or support issues to the mailing list:
76 I<bioperl-l@bioperl.org>
78 rather than to the module maintainer directly. Many experienced and
79 reponsive experts will be able look at the problem and quickly
80 address it. Please include a thorough description of the problem
81 with code and data examples if at all possible.
83 =head2 Reporting Bugs
85 report bugs to the Bioperl bug tracking system to help us keep track
86 the bugs and their resolution. Bug reports can be submitted via the
87 web:
89 https://github.com/bioperl/bioperl-live/issues
91 =head1 AUTHOR - Heikki Lehvaslaiho
93 Email: heikki-at-bioperl-dot-org
95 =head1 APPENDIX
97 The rest of the documentation details each of the object
98 methods. Internal methods are usually preceded with a _
100 =cut
103 # Let the code begin...
105 package Bio::LiveSeq::Mutation;
106 use strict;
108 # Object preamble - inheritance
111 use base qw(Bio::Root::Root);
113 sub new {
114 my($class,@args) = @_;
115 my $self;
116 $self = {};
117 bless $self, $class;
119 my ($seq, $seqori, $pos, $len, $label) =
120 $self->_rearrange([qw(SEQ
121 SEQORI
125 @args);
127 $seq && $self->seq($seq);
128 $seqori && $self->seqori($seqori);
129 $pos && $self->pos($pos);
130 defined($len) && $self->len($len); # defined() added otherwise won't work for len==0
132 return $self; # success - we hope!
136 =head2 seq
138 Title : seq
139 Usage : $obj->seq();
140 Function:
142 Sets and returns the mutated sequence. No checking is done
143 to validate the symbols.
145 Example :
146 Returns : string
147 Args : integer
149 =cut
152 sub seq {
153 my ($self,$value) = @_;
154 if( defined $value) {
155 $self->{'seq'} = $value;
157 return $self->{'seq'} || '';
161 =head2 seqori
163 Title : seqori
164 Usage : $obj->seqori();
165 Function:
167 Sets and returns the original subsequence in the reference
168 sequence. No checking is done to validate the symbols.
169 Optional value.
171 Example :
172 Returns : string
173 Args : string
175 =cut
178 sub seqori {
179 my ($self,$value) = @_;
180 if( defined $value) {
181 $self->{'seqori'} = $value;
183 return $self->{'seqori'} || '';
187 =head2 pos
189 Title : pos
190 Usage : $obj->pos();
191 Function:
193 Sets and returns the position of the first element in the
194 sequence.
196 Example :
197 Returns : string
198 Args : integer
200 =cut
203 sub pos {
204 my ($self,$value) = @_;
205 if( defined $value) {
206 if ( $value !~ /^([+-])?\d+$/ ) {
207 $self->throw("[$value] for pos has to be an integer\n");
208 } else {
209 $self->{'pos'} = $value;
212 return $self->{'pos'};
215 =head2 len
217 Title : len
218 Usage : $obj->len();
219 Function:
221 Sets and returns the len of the affected original allele
222 sequence. If value is not set, defaults to the length of
223 the mutated sequence (seq).
225 Example :
226 Returns : string
227 Args : string
229 =cut
231 sub len {
232 my ($self,$value) = @_;
233 if ( defined $value) {
234 $self->{'len'} = $value;
236 if ( ! exists $self->{'len'} ) {
237 return length $self->{'seq'};
239 return $self->{'len'};
242 =head2 label
244 Title : label
245 Usage : $obj->label();
246 Function:
248 Sets and returns the label of the affected original allele
249 location. Label is a stable identifier whereas location
250 can be changed by mutations. Label comes from
251 l<Bio::LiveSeq::Gene>.
253 Example :
254 Returns : string
255 Args : string
257 =cut
259 sub label {
260 my ($self,$value) = @_;
261 if ( defined $value) {
262 $self->{'label'} = $value;
264 if ( ! exists $self->{'label'} ) {
265 return;
267 return $self->{'label'};
271 =head2 transpos
273 Title : transpos
274 Usage : $obj->transpos();
275 Function:
277 Sets and returns the transcript position of the mutation.
278 Set when associated with a reference sequence. Value
279 depends on reference molecule and the co-ordinate system
280 used.
282 Example :
283 Returns : string
284 Args : integer
286 =cut
289 sub transpos {
290 my ($self,$value) = @_;
291 if( defined $value) {
292 if ( $value !~ /^([+-])?\d+$/ ) {
293 $self->throw("[$value] for transpos has to be an integer\n");
294 } else {
295 $self->{'transpos'} = $value;
298 return $self->{'transpos'};
302 =head2 issue
304 Title : issue
305 Usage : $obj->issue();
306 Function:
308 Sets and returns the position of the mutation in an array
309 of mutations to be issued. Set after the validity of the
310 mutation has been confirmed.
312 Example :
313 Returns : string
314 Args : integer
316 =cut
319 sub issue {
320 my ($self,$value) = @_;
321 if( defined $value) {
322 if ( $value !~ /^([+-])?\d+$/ ) {
323 $self->throw("[$value] for issue has to be an integer\n");
324 } else {
325 $self->{'issue'} = $value;
328 return $self->{'issue'};
332 =head2 prelabel
334 Title : prelabel
335 Usage : $obj->prelabel();
336 Function:
338 Sets and returns the prelabel of the affected original allele
339 location. Prelabel is a stable identifier whereas location
340 can be changed by mutations. Prelabel comes from
341 l<Bio::LiveSeq::Gene>.
343 Example :
344 Returns : string
345 Args : string
347 =cut
349 sub prelabel {
350 my ($self,$value) = @_;
351 if ( defined $value) {
352 $self->{'prelabel'} = $value;
354 if ( ! exists $self->{'prelabel'} ) {
355 return;
357 return $self->{'prelabel'};
361 =head2 postlabel
363 Title : postlabel
364 Usage : $obj->postlabel();
365 Function:
367 Sets and returns the postlabel of the affected original allele
368 location. Postlabel is a stable identifier whereas location
369 can be changed by mutations. Postlabel comes from
370 l<Bio::LiveSeq::Gene>.
372 Example :
373 Returns : string
374 Args : string
376 =cut
378 sub postlabel {
379 my ($self,$value) = @_;
380 if ( defined $value) {
381 $self->{'postlabel'} = $value;
383 if ( ! exists $self->{'postlabel'} ) {
384 return;
386 return $self->{'postlabel'};
390 =head2 lastlabel
392 Title : lastlabel
393 Usage : $obj->lastlabel();
394 Function:
396 Sets and returns the lastlabel of the affected original allele
397 location. Lastlabel is a stable identifier whereas location
398 can be changed by mutations. Lastlabel comes from
399 l<Bio::LiveSeq::Gene>.
401 Example :
402 Returns : string
403 Args : string
405 =cut
407 sub lastlabel {
408 my ($self,$value) = @_;
409 if ( defined $value) {
410 $self->{'lastlabel'} = $value;
412 if ( ! exists $self->{'lastlabel'} ) {
413 return;
415 return $self->{'lastlabel'};