File Coverage

lib/Sanger/CGP/Vcf/Contig.pm
Criterion Covered Total %
branch 5 52 9.6
subroutine 10 11 90.9
pod 0 7 0.0
total 15 70 21.4


line bran sub pod code
1       package Sanger::CGP::Vcf::Contig;
2        
3       ##########LICENCE##########
4       # Copyright (c) 2014,2015 Genome Research Ltd.
5       #
6       # Author: Jon Hinton <cgpit@sanger.ac.uk>
7       #
8       # This file is part of cgpVcf.
9       #
10       # cgpVcf 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       #
23       # 1. The usage of a range of years within a copyright statement contained within
24       # this distribution should be interpreted as being equivalent to a list of years
25       # including the first and last year specified and all consecutive years between
26       # them. For example, a copyright statement that reads ‘Copyright (c) 2005, 2007-
27       # 2009, 2011-2012’ should be interpreted as being identical to a statement that
28       # reads ‘Copyright (c) 2005, 2007, 2008, 2009, 2011, 2012’ and a copyright
29       # statement that reads ‘Copyright (c) 2005-2012’ should be interpreted as being
30       # identical to a statement that reads ‘Copyright (c) 2005, 2006, 2007, 2008,
31       # 2009, 2010, 2011, 2012’."
32       ########## LICENCE ##########
33        
34        
35   3   use Sanger::CGP::Vcf;
36       our $VERSION = Sanger::CGP::Vcf->VERSION;
37        
38   3   use strict;
39   3   use Carp qw(croak);
40   3   use warnings FATAL => 'all';
41        
42       1;
43        
44       sub new{
45   5 0 my $proto = shift;
46       my (%args) = @_;
47       my $class = ref($proto) || $proto;
48        
49       my $self = {
50       _name => $args{'-name'},
51       _length => $args{'-length'},
52       _species => $args{'-species'},
53       _assembly => $args{'-assembly'},
54       _checksum => $args{'-checksum'},
55       };
56       bless $self, $class;
57       return $self;
58       }
59        
60       sub name{
61   3 0 my($self,$value) = @_;
62 50     $self->{_name} = $value if defined $value;
63       return $self->{_name};
64       }
65        
66       sub length{
67   3 0 my($self,$value) = @_;
68 50     $self->{_length} = $value if defined $value;
69       return $self->{_length};
70       }
71        
72       sub species{
73   3 0 my($self,$value) = @_;
74 50     $self->{_species} = $value if defined $value;
75       return $self->{_species};
76       }
77        
78       sub assembly{
79   3 0 my($self,$value) = @_;
80 50     $self->{_assembly} = $value if defined $value;
81       return $self->{_assembly};
82       }
83        
84       sub checksum{
85   3 0 my($self,$value) = @_;
86 50     $self->{_checksum} = $value if defined $value;
87       return $self->{_checksum};
88       }
89        
90       sub compare{
91   0 0 my($self,$contig) = @_;
92 0     croak 'Incorrect input' unless ref $contig eq 'Sanger::CGP::Vcf::Contig';
93        
94       # check for defined mismatch
95 0     return 0 if((defined $contig->name ? 1 : 0) != (defined $self->{_name} ? 1 : 0));
  0      
  0      
96 0     return 0 if((defined $contig->length ? 1 : 0) != (defined $self->{_length} ? 1 : 0));
  0      
  0      
97 0     return 0 if((defined $contig->assembly ? 1 : 0) != (defined $self->{_assembly} ? 1 : 0));
  0      
  0      
98 0     return 0 if((defined $contig->species ? 1 : 0) != (defined $self->{_species} ? 1 : 0));
  0      
  0      
99 0     return 0 if((defined $contig->checksum ? 1 : 0) != (defined $self->{_checksum} ? 1 : 0));
  0      
  0      
100        
101 0     return 0 if defined $self->{_name} && $contig->name ne $self->{_name};
102 0     return 0 if defined $self->{_length} && $contig->length != $self->{_length};
103 0     return 0 if defined $self->{_assembly} && $contig->assembly ne $self->{_assembly};
104 0     return 0 if defined $self->{_species} && $contig->species ne $self->{_species};
105 0     return 0 if defined $self->{_checksum} && $contig->checksum ne $self->{_checksum};
106        
107       return 1;
108        
109       # $same = 0 unless $contig->name eq $self->{_name};
110       # $same = 0 unless $contig->length eq $self->{_length};
111       # $same = 0 unless $contig->assembly eq $self->{_assembly};
112       # $same = 0 unless $contig->species eq $self->{_species};
113       # if(defined ($contig->checksum) && defined ($self->{_checksum})){
114       # $same = 0 unless $contig->checksum eq $self->{_checksum};
115       # }
116       # return $same;
117       }