SAMbwa/Record.pm

filter: Statementstmt 90.9% 20 / 22 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 4 totaltotal 72.9% 27 / 37 SCAR 11.1
CC
3
Cov
85%
number_of_suboptimal_hits
2.1
alternative_mappings
2.0
number_of_mappings
2.0
CRAP 3.0
↑ Summary SAMbwa.pm »
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 1 $GenOOx::Data::File::SAMbwa::Record::VERSION = '0.0.4';
41  
42 #######################################################################
43 ####################### Load External modules #####################
44 #######################################################################
45 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48  
49 #######################################################################
50 ############################ Inheritance ##########################
51 #######################################################################
52 1 extends 'GenOO::Data::File::SAM::Record';
53  
54  
55 #######################################################################
56 ######################## Interface Methods ########################
57 #######################################################################
58 sub number_of_best_hits {
59 5 ▶ my ($self) = @_;
Subroutine number_of_best_hits: called CC=1 SCAR=0.0
Pod undocumented
60
61 5 return $self->tag('X0:i');
62 }
63  
64 sub number_of_suboptimal_hits {
65 5 ▶ my ($self) = @_;
Subroutine number_of_suboptimal_hits: called CC=2 SCAR=7.2
Pod undocumented
66
67 5 ▶ return $self->tag('X1:i') || 0;
Condition50%1/2
$self->tag('X1:i') || 0
l!l
05
MC/DC0%0/1
$self->tag('X1:i') || 0
$self->tag('X1:i')
Truth table50%1/2
A
A= $self->tag('X1:i')
Aresult
11
00
68 }
69  
70 sub number_of_mappings {
71 0 ▶ my ($self) = @_;
Subroutine number_of_mappings: not called CC=1 SCAR=6.9
Pod undocumented
72
73 0 return $self->number_of_best_hits + $self->number_of_suboptimal_hits;
74 }
75  
76 sub alternative_mappings {
77 1 ▶ my ($self) = @_;
Subroutine alternative_mappings: called CC=2 SCAR=7.0
Pod undocumented
78
79 1 my @alternative_mappings;
80 1 my $value = $self->tag('XA:Z');
81 1 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 1 0 1
82 1 @alternative_mappings = split(/;/,$value);
83 }
84 1 return @alternative_mappings;
85 }
86  
87  
88 #######################################################################
89 ############################ Finalize #############################
90 #######################################################################
91 1 __PACKAGE__->meta->make_immutable;
92  
93 1 1;
↑ Summary SAMbwa.pm »