File Coverage

lib/Sanger/CGP/Vagrent/Data/Deletion.pm
Criterion Covered Total %
branch 9 20 45.0
subroutine 7 8 87.5
pod 3 3 100.0
total 19 31 61.2


line bran sub pod code
1       package Sanger::CGP::Vagrent::Data::Deletion;
2        
3       ##########LICENCE##########
4       # Copyright (c) 2014 Genome Research Ltd.
5       #
6       # Author: Cancer Genome Project cgpit@sanger.ac.uk
7       #
8       # This file is part of VAGrENT.
9       #
10       # VAGrENT is free software: you can redistribute it and/or modify it under
11       # the terms of the GNU Affero General Public License as published by the Free
12       # Software Foundation; either version 3 of the License, or (at your option) any
13       # later version.
14       #
15       # This program is distributed in the hope that it will be useful, but WITHOUT
16       # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17       # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18       # details.
19       #
20       # You should have received a copy of the GNU Affero General Public License
21       # along with this program. If not, see <http://www.gnu.org/licenses/>.
22       ##########LICENCE##########
23        
24        
25   2   use strict;
26   2   use Data::Dumper;
27   2   use Sanger::CGP::Vagrent qw($VERSION);
28   2   use base qw(Sanger::CGP::Vagrent::Data::AbstractGenomicPosition Sanger::CGP::Vagrent::Data::AbstractVariation);
29        
30       1;
31        
32       sub _init {
33   296   my $self = shift;
34       my %vars = @_;
35       foreach my $k(keys(%vars)){
36 100     if($k eq 'delseq'){
37       $self->{_delseq} = $vars{delseq};
38       }
39       }
40       }
41        
42       sub isValid {
43   282 1 my $self = shift;
44        
45 50     return 0 unless(defined($self->{_minpos}) && defined($self->{_maxpos}));
46 50     return 0 unless($self->{_minpos} <= $self->{_maxpos});
47 50     return 0 unless($self->{_minpos} > 0);
48        
49 50     return 0 unless(defined($self->{_delseq}));
50 50     return 0 unless(length($self->{_delseq}) > 0);
51 50     return 0 unless($self->{_delseq} =~ m/^[atcgn]+$/i);
52        
53 50     return 0 if(length($self->{_delseq}) != ($self->{_maxpos} - $self->{_minpos}) + 1);
54        
55       return 1;
56       }
57        
58       sub getDeletedSequence {
59   688 1 return shift->{_delseq};
60       }
61        
62       sub toString {
63   0 1 my $self = shift;
64       my $out = 'chr'.$self->getChr.':g.';
65 0     if($self->getMinPos == $self->getMaxPos){
66       $out .= $self->getMinPos.'del'.$self->getDeletedSequence;
67       } else {
68       $out .= $self->getMinPos.'_'.$self->getMaxPos.'del';
69 0     if(length($self->getDeletedSequence) <= 10){
70       $out .= $self->getDeletedSequence;
71       } else {
72       $out .= length($self->getDeletedSequence);
73       }
74       }
75       return $out;
76       }
77        
78       __END__
79        
80       =head1 NAME
81        
82       Sanger::CGP::Vagrent::Data::Deletion - Data object representing a deletion
83        
84       =head1 DESCRIPTION
85        
86       This is a data class describing a deletion plotted to a genome.
87        
88       It inherits from L<Sanger::CGP::Vagrent::Data::AbstractGenomicPosition|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition> and L<Sanger::CGP::Vagrent::Data::AbstractVariation|Sanger::CGP::Vagrent::Data::AbstractVariation>
89        
90       =head1 METHODS
91        
92       =head2 Constructor
93        
94       =head3 new
95        
96       =over
97        
98       =item Usage :
99        
100       my $del = Sanger::CGP::Vagrent::Data::Deletion->new(%params);
101        
102       =item Function :
103        
104       Builds a new Sanger::CGP::Vagrent::Data::Deletion object
105        
106       =item Returns :
107        
108       Sanger::CGP::Vagrent::Data::Deletion object initialized with parameter values
109        
110       =item Params :
111        
112       Same as the constructor from L<Sanger::CGP::Vagrent::Data::AbstractGenomicPosition|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition> plus
113        
114       delseq => the deleted sequence fragment
115        
116       =back
117        
118       =head2 Attributes
119        
120       =head3 getDeletedSequence
121        
122       =over
123        
124       =item Usage :
125        
126       my $seq = $del->getDeletedSequence;
127        
128       =item Function :
129        
130       Returns the deleted sequence fragment
131        
132       =item Returns :
133        
134       String - DNA sequence
135        
136       =back
137        
138       =head2 Functions
139        
140       =head3 toString
141        
142       =over
143        
144       =item Usage :
145        
146       print $variant->toString;
147        
148       =item Function :
149        
150       Returns a simple string representation of the variant in hgvs genomic syntax
151        
152       =item Returns :
153        
154       String
155        
156       =back