File Coverage

lib/Sanger/CGP/Vagrent/Data/ComplexIndel.pm
Criterion Covered Total %
branch 14 28 50.0
subroutine 8 9 88.8
pod 4 4 100.0
total 26 41 63.4


line bran sub pod code
1       package Sanger::CGP::Vagrent::Data::ComplexIndel;
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   1   use strict;
26   1   use Data::Dumper;
27   1   use Sanger::CGP::Vagrent qw($VERSION);
28   1   use base qw(Sanger::CGP::Vagrent::Data::AbstractGenomicPosition Sanger::CGP::Vagrent::Data::AbstractVariation);
29        
30       1;
31        
32       sub _init {
33   230   my $self = shift;
34       my %vars = @_;
35       foreach my $k(keys(%vars)){
36 100     if($k eq 'delseq'){
  100      
37       $self->{_delseq} = $vars{delseq};
38       } elsif($k eq 'insseq'){
39       $self->{_insseq} = $vars{insseq};
40       }
41       }
42       }
43        
44       sub isValid {
45   230 1 my $self = shift;
46        
47 50     return 0 unless(defined($self->{_minpos}) && defined($self->{_maxpos}));
48 50     return 0 unless($self->{_minpos} <= $self->{_maxpos});
49 50     return 0 unless($self->{_minpos} > 0);
50        
51 50     return 0 unless(defined($self->{_delseq}));
52 50     return 0 unless(length($self->{_delseq}) > 0);
53 50     return 0 unless($self->{_delseq} =~ m/^[atcgn]+$/i);
54        
55 50     return 0 if(length($self->{_delseq}) != ($self->{_maxpos} - $self->{_minpos}) + 1);
56        
57 50     return 0 unless(exists($self->{_insseq}) && defined($self->{_insseq}));
58 50     return 0 unless(length($self->{_insseq}) > 0);
59 50     return 0 unless($self->{_insseq} =~ m/^[atcgn]+$/i);
60        
61       return 1;
62       }
63        
64       sub getDeletedSequence {
65   375 1 return shift->{_delseq};
66       }
67        
68       sub getInsertedSequence {
69   136 1 return shift->{_insseq};
70       }
71        
72       sub toString {
73   0 1 my $self = shift;
74       my $out = 'chr'.$self->getChr.':g.';
75 0     if($self->getMinPos == $self->getMaxPos){
76       $out .= $self->getMinPos.'del'.$self->getDeletedSequence;
77       } else {
78       $out .= $self->getMinPos.'_'.$self->getMaxPos.'del';
79 0     if(length($self->getDeletedSequence) <= 10){
80       $out .= $self->getDeletedSequence;
81       } else {
82       $out .= length($self->getDeletedSequence);
83       }
84       }
85       $out .= 'ins'.$self->getInsertedSequence;
86        
87       return $out;
88       }
89        
90       __END__
91        
92       =head1 NAME
93        
94       Sanger::CGP::Vagrent::Data::ComplexIndel - Data object representing a complex insertion deletion event
95        
96       =head1 DESCRIPTION
97        
98       This is a data class describing a complex insertion/deletion variant plotted to a genome.
99        
100       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>
101        
102       =head1 METHODS
103        
104       =head2 Constructor
105        
106       =head3 new
107        
108       =over
109        
110       =item Usage :
111        
112       my $cplx = Sanger::CGP::Vagrent::Data::ComplexIndel->new(%params);
113        
114       =item Function :
115        
116       Builds a new Sanger::CGP::Vagrent::Data::ComplexIndel object
117        
118       =item Returns :
119        
120       Sanger::CGP::Vagrent::Data::ComplexIndel object initialized with parameter values
121        
122       =item Params :
123        
124       Same as the constructor from L<Sanger::CGP::Vagrent::Data::AbstractGenomicPosition|Sanger::CGP::Vagrent::Data::AbstractGenomicPosition> plus
125        
126       delseq => the deleted sequence fragment
127       insseq => the inserted sequence fragment
128        
129       =back
130        
131       =head2 Attributes
132        
133       =head3 getDeletedSequence
134        
135       =over
136        
137       =item Usage :
138        
139       my $seq = $cplx->getDeletedSequence;
140        
141       =item Function :
142        
143       Returns the deleted sequence fragment
144        
145       =item Returns :
146        
147       String - DNA sequence
148        
149       =back
150        
151       =head3 getInsertedSequence
152        
153       =over
154        
155       =item Usage :
156        
157       my $seq = $cplx->getInsertedSequence;
158        
159       =item Function :
160        
161       Returns the inserted sequence fragment
162        
163       =item Returns :
164        
165       String - DNA sequence
166        
167       =back
168        
169       =head2 Functions
170        
171       =head3 toString
172        
173       =over
174        
175       =item Usage :
176        
177       print $variant->toString;
178        
179       =item Function :
180        
181       Returns a simple string representation of the variant in hgvs genomic syntax
182        
183       =item Returns :
184        
185       String
186        
187       =back