File Coverage

Bio/Variation/DNAMutation.pm
Criterion Covered Total %
statement 92 109 84.4
branch 70 102 68.6
condition 21 42 50.0
subroutine 8 9 88.8
pod 5 5 100.0
total 196 267 73.4


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Variation::DNAMutation
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Heikki Lehvaslaiho
7             #
8             # Copyright Heikki Lehvaslaiho
9             #
10             # You may distribute this module under the same terms as perl itself
11              
12             # POD documentation - main docs before the code
13              
14             =head1 NAME
15              
16             Bio::Variation::DNAMutation - DNA level mutation class
17              
18             =head1 SYNOPSIS
19              
20             $dnamut = Bio::Variation::DNAMutation->new
21             ('-start' => $start,
22             '-end' => $end,
23             '-length' => $len,
24             '-upStreamSeq' => $upflank,
25             '-dnStreamSeq' => $dnflank,
26             '-proof' => $proof,
27             '-isMutation' => 1,
28             '-mut_number' => $mut_number
29             );
30             $a1 = Bio::Variation::Allele->new;
31             $a1->seq('a');
32             $dnamut->allele_ori($a1);
33             my $a2 = Bio::Variation::Allele->new;
34             $a2->seq('t');
35             $dnamut->add_Allele($a2);
36              
37             print "Restriction changes are ", $dnamut->restriction_changes, "\n";
38              
39             # add it to a SeqDiff container object
40             $seqdiff->add_Variant($dnamut);
41              
42              
43             =head1 DESCRIPTION
44              
45             The instantiable class Bio::Variation::DNAMutation describes basic
46             sequence changes in genomic DNA level. It uses methods defined in
47             superclass Bio::Variation::VariantI. See L
48             for details.
49              
50             If the variation described by a DNAMutation object is transcibed, link
51             the corresponding Bio::Variation::RNAChange object to it using
52             method RNAChange(). See L for more information.
53              
54             =head1 FEEDBACK
55              
56             =head2 Mailing Lists
57              
58             User feedback is an integral part of the evolution of this and other
59             Bioperl modules. Send your comments and suggestions preferably to the
60             Bioperl mailing lists Your participation is much appreciated.
61              
62             bioperl-l@bioperl.org - General discussion
63             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
64              
65             =head2 Support
66              
67             Please direct usage questions or support issues to the mailing list:
68              
69             I
70              
71             rather than to the module maintainer directly. Many experienced and
72             reponsive experts will be able look at the problem and quickly
73             address it. Please include a thorough description of the problem
74             with code and data examples if at all possible.
75              
76             =head2 Reporting Bugs
77              
78             Report bugs to the Bioperl bug tracking system to help us keep track
79             the bugs and their resolution. Bug reports can be submitted via the
80             web:
81              
82             https://github.com/bioperl/bioperl-live/issues
83              
84             =head1 AUTHOR - Heikki Lehvaslaiho
85              
86             Email: heikki-at-bioperl-dot-org
87              
88             =head1 APPENDIX
89              
90             The rest of the documentation details each of the object
91             methods. Internal methods are usually preceded with a _
92              
93             =cut
94              
95              
96             # Let the code begin...
97              
98              
99             package Bio::Variation::DNAMutation;
100 5     5   1509 use strict;
  5         5  
  5         125  
101              
102             # Object preamble - inheritance
103              
104 5     5   27 use base qw(Bio::Variation::VariantI);
  5         5  
  5         1665  
105              
106             sub new {
107 31     31 1 157 my($class,@args) = @_;
108 31         111 my $self = $class->SUPER::new(@args);
109            
110 31         208 my ($start, $end, $length, $strand, $primary, $source,
111             $frame, $score, $gff_string,
112             $allele_ori, $allele_mut, $upstreamseq, $dnstreamseq,
113             $label, $status, $proof, $region, $region_value, $region_dist, $numbering,
114             $cpg, $mut_number, $ismutation) =
115             $self->_rearrange([qw(START
116             END
117             LENGTH
118             STRAND
119             PRIMARY
120             SOURCE
121             FRAME
122             SCORE
123             GFF_STRING
124             ALLELE_ORI
125             ALLELE_MUT
126             UPSTREAMSEQ
127             DNSTREAMSEQ
128             LABEL
129             STATUS
130             PROOF
131             REGION
132             REGION_VALUE
133             REGION_DIST
134             NUMBERING
135             CPG
136             MUT_NUMBER
137             ISMUTATION
138             )],
139             @args);
140              
141 31         170 $self->primary_tag("Variation");
142              
143 31         46 $self->{ 'alleles' } = [];
144              
145 31 100       118 $start && $self->start($start);
146 31 100       114 $end && $self->end($end);
147 31 100       86 $length && $self->length($length);
148 31 50       67 $strand && $self->strand($strand);
149 31 50       49 $primary && $self->primary_tag($primary);
150 31 50       44 $source && $self->source_tag($source);
151 31 50       44 $frame && $self->frame($frame);
152 31 50       43 $score && $self->score($score);
153 31 50       41 $gff_string && $self->_from_gff_string($gff_string);
154            
155 31 50       50 $allele_ori && $self->allele_ori($allele_ori);
156 31 50       44 $allele_mut && $self->allele_mut($allele_mut);
157 31 100       55 $upstreamseq && $self->upStreamSeq($upstreamseq);
158 31 100       60 $dnstreamseq && $self->dnStreamSeq($dnstreamseq);
159            
160 31 50       45 $label && $self->label($label);
161 31 50       47 $status && $self->status($status);
162 31 100       58 $proof && $self->proof($proof);
163 31 50       51 $region && $self->region($region);
164 31 50       51 $region_value && $self->region_value($region_value);
165 31 50       43 $region_dist && $self->region_dist($region_dist);
166 31 50       45 $numbering && $self->numbering($numbering);
167 31 100       64 $mut_number && $self->mut_number($mut_number);
168 31 100       55 $ismutation && $self->isMutation($ismutation);
169              
170 31 50       48 $cpg && $self->CpG($cpg);
171            
172 31         79 return $self; # success - we hope!
173             }
174              
175              
176             =head2 CpG
177              
178             Title : CpG
179             Usage : $obj->CpG()
180             Function: sets and returns boolean values for variation
181             hitting a CpG site. Unset value return -1.
182             Example : $obj->CpG()
183             Returns : boolean
184             Args : optional true of false value
185              
186              
187             =cut
188              
189              
190             sub CpG {
191 19     19 1 20 my ($obj,$value) = @_;
192 19 50       49 if( defined $value) {
    50          
193 0 0       0 $value ? ($value = 1) : ($value = 0);
194 0         0 $obj->{'cpg'} = $value;
195             }
196             elsif (not defined $obj->{'label'}) {
197 0         0 $obj->{'cpg'} = $obj->_CpG_value;
198             }
199             else {
200 19         68 return $obj->{'cpg'};
201             }
202             }
203              
204              
205              
206             sub _CpG_value {
207 0     0   0 my ($self) = @_;
208 0 0 0     0 if ($self->allele_ori eq $self->allele_mut and length ($self->allele_ori) == 1 ) {
209            
210             # valid only for point mutations
211             # CpG methylation-mediated deamination:
212             # CG -> TG | CG -> CA substitutions
213             # implementation here is less strict: if CpG dinucleotide was hit
214            
215 0 0 0     0 if ( ( ($self->allele_ori eq 'c') && (substr($self->upStreamSeq, 0, 1) eq 'g') ) ||
      0        
      0        
216             ( ($self->allele_ori eq 'g') && (substr($self->dnStreamSeq, -1, 1) eq 'c') ) ) {
217 0         0 return 1;
218             }
219             else {
220 0         0 return 0;
221             }
222             } else {
223 0         0 $self->warn('CpG makes sense only in the context of point mutation');
224 0         0 return;
225             }
226             }
227              
228              
229             =head2 RNAChange
230              
231             Title : RNAChange
232             Usage : $mutobj = $obj->RNAChange;
233             : $mutobj = $obj->RNAChange($objref);
234             Function: Returns or sets the link-reference to a mutation/change object.
235             If there is no link, it will return undef
236             Returns : an obj_ref or undef
237              
238             =cut
239              
240              
241             sub RNAChange {
242 21     21 1 16 my ($self,$value) = @_;
243 21 50       34 if (defined $value) {
244 21 50       45 if( ! $value->isa('Bio::Variation::RNAChange') ) {
245 0         0 $self->throw("Is not a Bio::Variation::RNAChange object but a [$self]");
246 0         0 return;
247             }
248             else {
249 21         28 $self->{'RNAChange'} = $value;
250             }
251             }
252 21 50       32 unless (exists $self->{'RNAChange'}) {
253 0         0 return;
254             } else {
255 21         32 return $self->{'RNAChange'};
256             }
257             }
258              
259              
260             =head2 label
261              
262             Title : label
263             Usage : $obj->label();
264             Function:
265              
266             Sets and returns mutation event label(s). If value is not
267             set, or no argument is given returns false. Each
268             instantiable subclass of L needs
269             to implement this method. Valid values are listed in
270             'Mutation event controlled vocabulary' in
271             http://www.ebi.ac.uk/mutations/recommendations/mutevent.html.
272              
273             Example :
274             Returns : string
275             Args : string
276              
277             =cut
278              
279              
280             sub label {
281 90     90 1 63 my ($self, $value) = @_;
282 90         58 my ($o, $m, $type);
283 90 100 66     122 $o = $self->allele_ori->seq if $self->allele_ori and $self->allele_ori->seq;
284 90 100 66     147 $m = $self->allele_mut->seq if $self->allele_mut and $self->allele_mut->seq;
285            
286 90 50 66     563 if (not $o and not $m ) {
    100 100        
    100 100        
    100 66        
287 0         0 $self->warn("[DNAMutation, label] Both alleles should not be empty!\n");
288 0         0 $type = 'no change'; # is this enough?
289             }
290             elsif ($o && $m && length($o) == length($m) && length($o) == 1) {
291 60         53 $type = 'point';
292 60         72 $type .= ", ". _point_type_label($o, $m);
293             }
294             elsif (not $o ) {
295 12         12 $type = 'insertion';
296             }
297             elsif (not $m ) {
298 12         9 $type = 'deletion';
299             }
300             else {
301 6         6 $type = 'complex';
302             }
303 90         99 $self->{'label'} = $type;
304 90         244 return $self->{'label'};
305             }
306              
307              
308             sub _point_type_label {
309 60     60   51 my ($o, $m) = @_;
310 60         40 my ($type);
311 60         125 my %transition = ('a' => 'g',
312             'g' => 'a',
313             'c' => 't',
314             't' => 'c');
315 60         53 $o = lc $o;
316 60         37 $m = lc $m;
317 60 50       104 if ($o eq $m) {
    100          
318 0         0 $type = 'no change';
319             }
320             elsif ($transition{$o} eq $m ) {
321 31         63 $type = 'transition';
322             }
323             else {
324 29         74 $type = 'transversion';
325             }
326             }
327              
328              
329             =head2 sysname
330              
331             Title : sysname
332             Usage : $self->sysname
333             Function:
334              
335             This subroutine creates a string corresponding to the
336             'systematic name' of the mutation. Systematic name is
337             specified in Antonorakis & MDI Nomenclature Working Group:
338             Human Mutation 11:1-3, 1998.
339            
340             Returns : string
341              
342             =cut
343              
344              
345             sub sysname {
346 17     17 1 13 my ($self,$value) = @_;
347 17 50       22 if( defined $value) {
348 0         0 $self->{'sysname'} = $value;
349             } else {
350 17 50       33 $self->warn('Mutation start position is not defined')
351             if not defined $self->start;
352 17         17 my $sysname = '';
353             # show the alphabet only if $self->SeqDiff->alphabet is set;
354 17         12 my $mol = '';
355              
356 17 50       31 if ($self->SeqDiff ) {
357 17 100 33     28 if ($self->SeqDiff && $self->SeqDiff->alphabet && $self->SeqDiff->alphabet eq 'dna') {
    50 66        
      33        
358 4         5 $mol = 'g.';
359             }
360             elsif ($self->SeqDiff->alphabet && $self->SeqDiff->alphabet eq 'rna') {
361 13         13 $mol = 'c.';
362             }
363             }
364 17         24 my $sep;
365 17 100       27 if ($self->isMutation) {
366 15         13 $sep = '>';
367             } else {
368 2         2 $sep = '|';
369             }
370 17         14 my $sign = '+';
371 17 100       28 $sign = '' if $self->start < 1;
372 17         20 $sysname .= $mol ;#if $mol;
373 17         28 $sysname .= $sign. $self->start;
374              
375 17         39 my @alleles = $self->each_Allele;
376 17         32 $self->allele_mut($alleles[0]);
377              
378 17 100       27 $sysname .= 'del' if $self->label =~ /deletion/;
379 17 100       22 $sysname .= 'ins' if $self->label =~ /insertion/;
380 17 100       23 $sysname .= uc $self->allele_ori->seq if $self->allele_ori->seq;
381              
382              
383              
384             #push @alleles, $self->allele_mut if $self->allele_mut;
385 17         25 foreach my $allele (@alleles) {
386 18         24 $self->allele_mut($allele);
387 18 100 100     25 $sysname .= $sep if $self->label =~ /point/ or $self->label =~ /complex/;
388 18 100       29 $sysname .= uc $self->allele_mut->seq if $self->allele_mut->seq;
389             }
390 17         44 $self->{'sysname'} = $sysname;
391             #$self->{'sysname'} = $sign. $self->start.
392             # uc $self->allele_ori->seq. $sep. uc $self->allele_mut->seq;
393             }
394 17         36 return $self->{'sysname'};
395             }
396              
397             1;