line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Tradis::Parser::Cigar; |
2
|
|
|
|
|
|
|
$Bio::Tradis::Parser::Cigar::VERSION = '1.3.2'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Take in a cigar string and output start and end relative to the reference sequence |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
99982
|
use Moose; |
|
5
|
|
|
|
|
390477
|
|
|
5
|
|
|
|
|
33
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'cigar' => ( is => 'ro', isa => 'Str', required => 1 ); |
9
|
|
|
|
|
|
|
has 'coordinate' => ( is => 'ro', isa => 'Num', required => 1 ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '_results' => (is => 'ro', isa => 'HashRef', lazy => 1, builder => '_build__results'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _build__results |
14
|
|
|
|
|
|
|
{ |
15
|
8
|
|
|
8
|
|
23
|
my($self) = @_; |
16
|
8
|
|
|
|
|
31
|
my %results = ( start => 0, end => 0); |
17
|
8
|
|
|
|
|
230
|
my $current_coordinate = $self->coordinate; |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
|
|
|
142
|
my @cigar_parts = $self->cigar =~ /(\d+[MIDNSHP=X])/g; |
20
|
8
|
|
|
|
|
21
|
for my $cigar_item (@cigar_parts) |
21
|
|
|
|
|
|
|
{ |
22
|
19
|
50
|
|
|
|
54
|
if( $cigar_item =~ /(\d+)([MIDNSHP=X])/) |
23
|
|
|
|
|
|
|
{ |
24
|
19
|
|
|
|
|
33
|
my $number = $1; |
25
|
19
|
|
|
|
|
27
|
my $action = $2; |
26
|
|
|
|
|
|
|
|
27
|
19
|
100
|
66
|
|
|
100
|
if($action eq 'M' || $action eq 'X' || $action eq '=' ) |
|
|
100
|
66
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
11
|
100
|
|
|
|
30
|
$results{start} = $current_coordinate if($results{start} == 0); |
30
|
11
|
|
|
|
|
19
|
$current_coordinate += $number; |
31
|
11
|
50
|
|
|
|
30
|
$results{end} = $current_coordinate -1 if($results{end} < $current_coordinate); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif($action eq 'S' || $action eq 'D' || $action eq 'N') |
34
|
|
|
|
|
|
|
{ |
35
|
6
|
|
|
|
|
14
|
$current_coordinate += $number; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif($action eq 'I' ) |
38
|
|
|
|
|
|
|
{ |
39
|
|
|
|
|
|
|
# do nothing |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
8
|
|
|
|
|
151
|
return \%results; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub start |
48
|
|
|
|
|
|
|
{ |
49
|
8
|
|
|
8
|
0
|
23
|
my($self) = @_; |
50
|
8
|
|
|
|
|
247
|
return $self->_results->{start}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub end |
54
|
|
|
|
|
|
|
{ |
55
|
8
|
|
|
8
|
0
|
20
|
my($self) = @_; |
56
|
8
|
|
|
|
|
267
|
return $self->_results->{end}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
59
|
5
|
|
|
5
|
|
32231
|
no Moose; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
27
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding UTF-8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Bio::Tradis::Parser::Cigar - Take in a cigar string and output start and end relative to the reference sequence |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 1.3.2 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Take in a cigar string and output start and end relative to the reference sequence |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use Bio::Tradis::Parser::Cigar; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $cigar = Bio::Tradis::Parser::Cigar->new(coordinate => 123, cigar => '10S90M'); |
83
|
|
|
|
|
|
|
$cigar->start; |
84
|
|
|
|
|
|
|
$cigar->end; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Carla Cummins <path-help@sanger.ac.uk> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This is free software, licensed under: |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |