| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# POD documentation - main docs before the code |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
GenOOx::Data::File::SAMbwa::Record - Represents a record of a SAM format file generated by BWA |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Object representing a record of a sam file |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# To initialize |
|
12
|
|
|
|
|
|
|
my $sam_record = GenOOx::Data::File::SAMbwa::Record->new( |
|
13
|
|
|
|
|
|
|
fields => [qname,flag, rname, pos, mapq, cigar, |
|
14
|
|
|
|
|
|
|
rnext, pnext, tlen, seq, qual, tags] |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This object represents a record of a sam file generated by BWA and offers methods for accessing the different |
|
21
|
|
|
|
|
|
|
attributes. It implements several additional methods that transform original attributes in more manageable |
|
22
|
|
|
|
|
|
|
attributes. eg. from the FLAG attribute the actual strand is extracted etc. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Check if the record corresponds to a match |
|
27
|
|
|
|
|
|
|
my $mapped = $sam_record->is_mapped; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Check if the record corresponds to a non match |
|
30
|
|
|
|
|
|
|
my $unmapped = $sam_record->is_unmapped; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Parse the FLAG attribute and return 1 or -1 for the strand |
|
33
|
|
|
|
|
|
|
my $strand = $sam_record->strand; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Let the code begin... |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package GenOOx::Data::File::SAMbwa::Record; |
|
40
|
|
|
|
|
|
|
$GenOOx::Data::File::SAMbwa::Record::VERSION = '0.0.5'; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
####################################################################### |
|
43
|
|
|
|
|
|
|
####################### Load External modules ##################### |
|
44
|
|
|
|
|
|
|
####################################################################### |
|
45
|
1
|
|
|
1
|
|
850046
|
use Moose; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
46
|
1
|
|
|
1
|
|
7239
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
####################################################################### |
|
50
|
|
|
|
|
|
|
############################ Inheritance ########################## |
|
51
|
|
|
|
|
|
|
####################################################################### |
|
52
|
|
|
|
|
|
|
extends 'GenOO::Data::File::SAM::Record'; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
####################################################################### |
|
56
|
|
|
|
|
|
|
######################## Interface Methods ######################## |
|
57
|
|
|
|
|
|
|
####################################################################### |
|
58
|
|
|
|
|
|
|
sub number_of_best_hits { |
|
59
|
5
|
|
|
5
|
0
|
712
|
my ($self) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
5
|
|
100
|
|
|
31
|
return $self->tag('X0:i') || 0; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub number_of_suboptimal_hits { |
|
65
|
5
|
|
|
5
|
0
|
696
|
my ($self) = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
5
|
|
50
|
|
|
19
|
return $self->tag('X1:i') || 0; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub number_of_mappings { |
|
71
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
return $self->number_of_best_hits + $self->number_of_suboptimal_hits; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub alternative_mappings { |
|
77
|
1
|
|
|
1
|
0
|
679
|
my ($self) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
8
|
my @alternative_mappings; |
|
80
|
1
|
|
|
|
|
11
|
my $value = $self->tag('XA:Z'); |
|
81
|
1
|
50
|
|
|
|
397
|
if (defined $value) { |
|
82
|
1
|
|
|
|
|
64
|
@alternative_mappings = split(/;/,$value); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
1
|
|
|
|
|
8
|
return @alternative_mappings; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
####################################################################### |
|
89
|
|
|
|
|
|
|
############################ Finalize ############################# |
|
90
|
|
|
|
|
|
|
####################################################################### |
|
91
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |