| 1 | # POD documentation - main docs before the code | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | GenOO::TranscriptCollection::Factory::FromGeneCollection - Factory to create GenOO::TranscriptCollection object from a GeneCollection | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | # Creates GenOO::TranscriptCollection object from a GeneCollection | ||
| 10 | |||
| 11 | # Preferably use it through the generic GenOO::TranscriptCollection::Factory | ||
| 12 | my $factory = GenOO::TranscriptCollection::Factory->create('FromGeneCollection',{ | ||
| 13 | gene_collection => $gene_collection | ||
| 14 | }); | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | An instance of this class is a concrete factory for the creation of a | ||
| 19 | L<GenOO::TranscriptCollection> object from a GeneCollection. | ||
| 20 | It offers the method "read_collection" (as the consumed role requires) which returns the actual | ||
| 21 | L<GenOO::TranscriptCollection> object in the form of L<GenOO::RegionCollection::Type::DoubleHashArray>. | ||
| 22 | The latter is the implementation of the L<GenOO::RegionCollection> class based on the complex | ||
| 23 | data structure L<GenOO::Data::Structure::DoubleHashArray>. | ||
| 24 | |||
| 25 | =head1 EXAMPLES | ||
| 26 | |||
| 27 | # Create a concrete factory | ||
| 28 | my $factory_implementation = GenOO::TranscriptCollection::Factory->create('FromTranscriptCollection',{ | ||
| 29 | gene_collection => $gene_collection | ||
| 30 | }); | ||
| 31 | |||
| 32 | # Return the actual GenOO::TranscriptCollection object | ||
| 33 | my $collection = $factory_implementation->read_collection; | ||
| 34 | print ref($collection) # GenOO::RegionCollection::Type::DoubleHashArray | ||
| 35 | |||
| 36 | =cut | ||
| 37 | |||
| 38 | # Let the code begin... | ||
| 39 | |||
| 40 | package GenOO::TranscriptCollection::Factory::FromGeneCollection; | ||
| 41 | 1 | $GenOO::TranscriptCollection::Factory::FromGeneCollection::VERSION = '1.5.0'; | |
| 42 | |||
| 43 | ####################################################################### | ||
| 44 | ####################### Load External modules ##################### | ||
| 45 | ####################################################################### | ||
| 46 | 1 | ▶ | use Modern::Perl; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 47 | 1 | ▶ | use autodie; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 48 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 49 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 50 | |||
| 51 | |||
| 52 | ####################################################################### | ||
| 53 | ####################### Load GenOO modules ##################### | ||
| 54 | ####################################################################### | ||
| 55 | 1 | ▶ | use GenOO::RegionCollection::Type::DoubleHashArray; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 56 | |||
| 57 | |||
| 58 | ####################################################################### | ||
| 59 | ####################### Interface attributes ###################### | ||
| 60 | ####################################################################### | ||
| 61 | 1 | has 'gene_collection' => ( | |
| 62 | isa => 'GenOO::RegionCollection', | ||
| 63 | is => 'ro', | ||
| 64 | required => 1 | ||
| 65 | ); | ||
| 66 | |||
| 67 | |||
| 68 | ####################################################################### | ||
| 69 | ########################## Consumed Roles ######################### | ||
| 70 | ####################################################################### | ||
| 71 | 1 | with 'GenOO::RegionCollection::Factory::Requires'; | |
| 72 | |||
| 73 | |||
| 74 | ####################################################################### | ||
| 75 | ######################## Interface Methods ######################## | ||
| 76 | ####################################################################### | ||
| 77 | sub read_collection { | ||
| 78 | 1 | ▶ | my ($self) = @_; |
|
Subroutine
read_collection: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 79 | |||
| 80 | 1 | my $collection = GenOO::RegionCollection::Type::DoubleHashArray->new; | |
| 81 | 1 | my @all_transcripts = map {@{$_->transcripts}} $self->gene_collection->all_records; | |
| 82 | 1 | map {$collection->add_record($_)} @all_transcripts; | |
| 83 | |||
| 84 | 1 | return $collection; | |
| 85 | } | ||
| 86 | |||
| 87 | 1 | 1; | |