line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
|
|
|
|
$GenOO::RegionCollection::Factory::SAM::VERSION = '1.5.1'; |
47
|
1
|
|
|
1
|
|
3356
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
48
|
1
|
|
|
1
|
|
5136
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
80
|
use GenOO::RegionCollection::Type::DoubleHashArray; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
51
|
1
|
|
|
1
|
|
3
|
use GenOO::Data::File::SAM; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
162
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has 'file' => (is => 'Str', is => 'ro'); |
54
|
|
|
|
|
|
|
has 'filter_code' => (isa => 'CodeRef', is => 'ro', default => sub{sub{return 1;}} ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
with 'GenOO::RegionCollection::Factory::Requires'; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
####################################################################### |
59
|
|
|
|
|
|
|
######################## Interface Methods ######################## |
60
|
|
|
|
|
|
|
####################################################################### |
61
|
|
|
|
|
|
|
sub read_collection { |
62
|
1
|
|
|
1
|
0
|
1859
|
my ($self) = @_; |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
61
|
my $collection = GenOO::RegionCollection::Type::DoubleHashArray->new; |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
48
|
my $parser = GenOO::Data::File::SAM->new( |
67
|
|
|
|
|
|
|
file => $self->file, |
68
|
|
|
|
|
|
|
); |
69
|
1
|
|
|
|
|
20
|
while (my $record = $parser->next_record) { |
70
|
978
|
100
|
66
|
|
|
1999
|
if (($record->is_mapped) and ($self->filter_code->($record))){ |
71
|
645
|
|
|
|
|
1580
|
$collection->add_record($record); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
26
|
return $collection; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |