| 1 | =head1 NAME | ||
| 2 | |||
| 3 | CLIPSeqTools::Role::Option::Genes - Role to enable reading a GTF file with genes/transcripts from the command line | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | Role to enable reading a GTF file with genes/transcripts from the command line | ||
| 8 | |||
| 9 | Defines options. | ||
| 10 | -gtf <Str> GTF file for transcripts. | ||
| 11 | |||
| 12 | Provides attributes. | ||
| 13 | gene_collection the collection of genes that is read from the GTF | ||
| 14 | transcript_collection the collection of transcripts that is read from the GTF | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | |||
| 19 | package CLIPSeqTools::Role::Option::Genes; | ||
| 20 | $CLIPSeqTools::Role::Option::Genes::VERSION = '0.1.1'; | ||
| 21 | |||
| 22 | ####################################################################### | ||
| 23 | ####################### Load External modules ##################### | ||
| 24 | ####################################################################### | ||
| 25 | use Modern::Perl; | ||
| 26 | use MooseX::App::Role; | ||
| 27 | |||
| 28 | |||
| 29 | ####################################################################### | ||
| 30 | ######################## Load GenOO modules ####################### | ||
| 31 | ####################################################################### | ||
| 32 | use GenOO::GeneCollection::Factory; | ||
| 33 | use GenOO::TranscriptCollection::Factory; | ||
| 34 | |||
| 35 | |||
| 36 | ####################################################################### | ||
| 37 | ####################### Command line options ###################### | ||
| 38 | ####################################################################### | ||
| 39 | option 'gtf' => ( | ||
| 40 | is => 'rw', | ||
| 41 | isa => 'Str', | ||
| 42 | required => 1, | ||
| 43 | documentation => 'GTF file with genes/transcripts', | ||
| 44 | ); | ||
| 45 | |||
| 46 | |||
| 47 | ####################################################################### | ||
| 48 | ###################### Interface Attributes ####################### | ||
| 49 | ####################################################################### | ||
| 50 | has 'gene_collection' => ( | ||
| 51 | traits => ['NoGetopt'], | ||
| 52 | is => 'rw', | ||
| 53 | builder => '_read_gene_collection', | ||
| 54 | lazy => 1, | ||
| 55 | ); | ||
| 56 | |||
| 57 | has 'transcript_collection' => ( | ||
| 58 | traits => ['NoGetopt'], | ||
| 59 | is => 'rw', | ||
| 60 | builder => '_read_transcript_collection', | ||
| 61 | lazy => 1, | ||
| 62 | ); | ||
| 63 | |||
| 64 | |||
| 65 | ####################################################################### | ||
| 66 | ######################## Interface Methods ######################## | ||
| 67 | ####################################################################### | ||
| 68 | sub validate_args {} | ||
| 69 | |||
| 70 | |||
| 71 | ####################################################################### | ||
| 72 | ######################### Private Methods ######################### | ||
| 73 | ####################################################################### | ||
| 74 | sub _read_gene_collection { | ||
| 75 | my ($self) = @_; | ||
| 76 | |||
| 77 | return GenOO::GeneCollection::Factory->create('GTF', { | ||
| 78 | file => $self->gtf | ||
| 79 | })->read_collection; | ||
| 80 | } | ||
| 81 | |||
| 82 | sub _read_transcript_collection { | ||
| 83 | my ($self) = @_; | ||
| 84 | |||
| 85 | return GenOO::TranscriptCollection::Factory->create('FromGeneCollection', { | ||
| 86 | gene_collection => $self->gene_collection | ||
| 87 | })->read_collection; | ||
| 88 | } | ||
| 89 | |||
| 90 | |||
| 91 | 1; |