| 1 | # POD documentation - main docs before the code | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | GenOO::RegionCollection::Factory::BED - Factory for creating GenOO::RegionCollection object from a BED file | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | # Creates GenOO::RegionCollection object from a BED file | ||||||||||
| 10 | |||||||||||
| 11 | # Preferably use it through the generic GenOO::RegionCollection::Factory | ||||||||||
| 12 | my $factory = GenOO::RegionCollection::Factory->create('BED', | ||||||||||
| 13 | { | ||||||||||
| 14 | file => 'sample.bed' | ||||||||||
| 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 BED 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->create('BED', | ||||||||||
| 32 | { | ||||||||||
| 33 | file => 'sample.bed' | ||||||||||
| 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::BED; | ||||||||||
| 46 | 1 | $GenOO::RegionCollection::Factory::BED::VERSION = '1.5.0'; | |||||||||
| 47 | |||||||||||
| 48 | ####################################################################### | ||||||||||
| 49 | ####################### Load External modules ##################### | ||||||||||
| 50 | ####################################################################### | ||||||||||
| 51 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 52 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | ####################################################################### | ||||||||||
| 56 | ######################### Load GenOO modules ###################### | ||||||||||
| 57 | ####################################################################### | ||||||||||
| 58 | 1 | ▶ | use GenOO::RegionCollection::Type::DoubleHashArray; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 59 | 1 | ▶ | use GenOO::Data::File::BED; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 60 | |||||||||||
| 61 | |||||||||||
| 62 | ####################################################################### | ||||||||||
| 63 | ####################### Interface attributes ###################### | ||||||||||
| 64 | ####################################################################### | ||||||||||
| 65 | 1 | has 'file' => ( | |||||||||
| 66 | isa => 'Str', | ||||||||||
| 67 | is => 'ro', | ||||||||||
| 68 | required => 1 | ||||||||||
| 69 | ); | ||||||||||
| 70 | |||||||||||
| 71 | 1 | has 'redirect_score_to_copy_number' => ( | |||||||||
| 72 | traits => ['Bool'], | ||||||||||
| 73 | is => 'rw', | ||||||||||
| 74 | isa => 'Bool', | ||||||||||
| 75 | default => 0, | ||||||||||
| 76 | lazy => 1 | ||||||||||
| 77 | ); | ||||||||||
| 78 | |||||||||||
| 79 | has 'filter_code' => ( | ||||||||||
| 80 | isa => 'CodeRef', | ||||||||||
| 81 | is => 'ro', | ||||||||||
| 82 | 18 | ▶ | default => sub { sub {return 1} } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 83 | 1 | ); | |||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | ####################################################################### | ||||||||||
| 87 | ########################## Consumed roles ######################### | ||||||||||
| 88 | ####################################################################### | ||||||||||
| 89 | 1 | with 'GenOO::RegionCollection::Factory::Requires'; | |||||||||
| 90 | |||||||||||
| 91 | |||||||||||
| 92 | ####################################################################### | ||||||||||
| 93 | ######################## Interface Methods ######################## | ||||||||||
| 94 | ####################################################################### | ||||||||||
| 95 | sub read_collection { | ||||||||||
| 96 | 3 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
read_collection: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 97 | |||||||||||
| 98 | 3 | my $collection = GenOO::RegionCollection::Type::DoubleHashArray->new; | |||||||||
| 99 | |||||||||||
| 100 | 3 | my $parser = GenOO::Data::File::BED->new( | |||||||||
| 101 | file => $self->file, | ||||||||||
| 102 | redirect_score_to_copy_number => $self->redirect_score_to_copy_number, | ||||||||||
| 103 | ); | ||||||||||
| 104 | |||||||||||
| 105 | 3 | ▶ | while (my $record = $parser->next_record) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 27 | ▶ | $collection->add_record($record) if $self->filter_code->($record); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | 3 | return $collection; | |||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | 1 | 1; | |||||||||