GenOO/RegionCollection/Factory/SAM.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 92.8% 39 / 42 CC 4 SCAR 8.5
CC
4
Cov
97%
read_collection
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« GenOO/Data/File/SAM.pm ↑ Summary GenOO/Data/File/SAM/Record.pm »
1 # POD documentation - main docs before the code
2  
3 =head1 NAME
4  
5 GenOO::RegionCollection::Factory::SAM - Factory for creating GenOO::RegionCollection object from a SAM file
6  
7 =head1 SYNOPSIS
8  
9 # Creates GenOO::RegionCollection object from a SAM file
10  
11 # Preferably use it through the generic GenOO::RegionCollection::Factory
12 my $factory = GenOO::RegionCollection::Factory->new('SAM',
13 {
14 file => 'sample.sam'
15 }
16 );
17  
18 =head1 DESCRIPTION
19  
20 An instance of this class is a concrete factory for the creation of a
21 L<GenOO::RegionCollection> object from a SAM file. It offers the method
22 "read_collection" (as the consumed role requires) which returns the actual
23 L<GenOO::RegionCollection> object in the form of
24 L<GenOO::RegionCollection::Type::DoubleHashArray>. The latter is the implementation
25 of the L<GenOO::RegionCollection> class based on the complex data structure
26 L<GenOO::Data::Structure::DoubleHashArray>.
27  
28 =head1 EXAMPLES
29  
30 # Create a concrete factory
31 my $factory_implementation = GenOO::RegionCollection::Factory->new('SAM',
32 {
33 file => 'sample.sam'
34 }
35 );
36
37 # Return the actual GenOO::RegionCollection object
38 my $collection = $factory_implementation->read_collection;
39 print ref($collection) # GenOO::RegionCollection::Type::DoubleHashArray
40  
41 =cut
42  
43 # Let the code begin...
44  
45 package GenOO::RegionCollection::Factory::SAM;
46 1 $GenOO::RegionCollection::Factory::SAM::VERSION = '1.5.0';
47 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 1 ▶use GenOO::RegionCollection::Type::DoubleHashArray;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 1 ▶use GenOO::Data::File::SAM;
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 1 has 'file' => (is => 'Str', is => 'ro');
54 645 ▶has 'filter_code' => (isa => 'CodeRef', is => 'ro', default => sub{sub{return 1;}} );
Subroutine __ANON__: called CC=1 SCAR=0.0
55  
56 1 with 'GenOO::RegionCollection::Factory::Requires';
57  
58 #######################################################################
59 ######################## Interface Methods ########################
60 #######################################################################
61 sub read_collection {
62 1 ▶ my ($self) = @_;
Subroutine read_collection: called CC=4 SCAR=13.9
Pod undocumented
63
64 1 my $collection = GenOO::RegionCollection::Type::DoubleHashArray->new;
65
66 1 my $parser = GenOO::Data::File::SAM->new(
67 file => $self->file,
68 );
69 1 ▶ while (my $record = $parser->next_record) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $record = $parser->next_record) 978 1 979
70 978 ▶ if (($record->is_mapped) and ($self->filter_code->($record))){
Branch: 1 branch
BranchTrueFalseTotal
if ($record->is_mapped and $self->filter_code->($record)) 645 333 978
Condition66%2/3
$record->is_mapped and $self->filter_code->($record)
!ll&&!rl&&r
3330645
MC/DC50%1/2
$record->is_mapped and $self->filter_code->($record)
$record->is_mapped $self->filter_code->($record)
Truth table66%2/3
A and B
A= $record->is_mappedB= $self->filter_code->($record)
ABresult
0X0
100
111
71 645 $collection->add_record($record);
72 }
73 }
74
75 1 return $collection;
76 }
77  
78 1 1;
« GenOO/Data/File/SAM.pm ↑ Summary GenOO/Data/File/SAM/Record.pm »