SAMstar/Record.pm

filter: Statementstmt 100% 24 / 24 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 4 totaltotal 84.7% 39 / 46 CC 7 SCAR 9.2
CC
7
Cov
92%
is_uniquelly_mapped
3.0
is_primary_alignment
3.0
is_secondary_alignment
3.0
CRAP 2.5
↑ Summary SAMstar.pm »
1 # POD documentation - main docs before the code
2  
3 =head1 NAME
4  
5 GenOOx::Data::File::SAMstar::Record - Represents a record of a SAM format file generated by STAR
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::SAMstar::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 STAR 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::SAMstar::Record;
40 1 $GenOOx::Data::File::SAMstar::Record::VERSION = '0.0.2';
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_mappings {
59 3 ▶ my ($self) = @_;
Subroutine number_of_mappings: called CC=1 SCAR=0.0
Pod undocumented
60
61 3 return $self->tag('NH:i');
62 }
63  
64 sub is_uniquelly_mapped {
65 3 ▶ my ($self) = @_;
Subroutine is_uniquelly_mapped: called CC=3 SCAR=11.0
Pod undocumented
66
67 3 ▶ return 0 if $self->is_unmapped;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_unmapped 0 3 3
68 3 ▶ return 1 if $self->mapq == 255;
Branch: 1 branch
BranchTrueFalseTotal
if $self->mapq == 255 1 2 3
69 2 return 0;
70 }
71  
72 sub is_primary_alignment {
73 3 ▶ my ($self) = @_;
Subroutine is_primary_alignment: called CC=3 SCAR=11.0
Pod undocumented
74
75 3 ▶ return 0 if $self->is_unmapped;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_unmapped 0 3 3
76 3 ▶ return 0 if $self->flag & 256;
Branch: 1 branch
BranchTrueFalseTotal
if $self->flag & 256 1 2 3
77 2 return 1;
78 }
79  
80 sub is_secondary_alignment {
81 3 ▶ my ($self) = @_;
Subroutine is_secondary_alignment: called CC=3 SCAR=11.0
Pod undocumented
82
83 3 ▶ return 0 if $self->is_unmapped;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_unmapped 0 3 3
84 3 ▶ return 1 if $self->flag & 256;
Branch: 1 branch
BranchTrueFalseTotal
if $self->flag & 256 1 2 3
85 2 return 0;
86 }
87  
88  
89 #######################################################################
90 ############################ Finalize #############################
91 #######################################################################
92 1 __PACKAGE__->meta->make_immutable;
93  
94 1 1;
↑ Summary SAMstar.pm »