| 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 = '1.0.0'; | ||
| 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 | use MooseX::Getopt; | ||
| 35 | |||
| 36 | |||
| 37 | ####################################################################### | ||
| 38 | ####################### Command line options ###################### | ||
| 39 | ####################################################################### | ||
| 40 | option 'gtf' => ( | ||
| 41 | is => 'rw', | ||
| 42 | isa => 'Str', | ||
| 43 | required => 1, | ||
| 44 | documentation => 'GTF file with genes/transcripts', | ||
| 45 | ); | ||
| 46 | |||
| 47 | |||
| 48 | ####################################################################### | ||
| 49 | ###################### Interface Attributes ####################### | ||
| 50 | ####################################################################### | ||
| 51 | has 'gene_collection' => ( | ||
| 52 | traits => ['NoGetopt'], | ||
| 53 | is => 'rw', | ||
| 54 | builder => '_read_gene_collection', | ||
| 55 | lazy => 1, | ||
| 56 | ); | ||
| 57 | |||
| 58 | has 'transcript_collection' => ( | ||
| 59 | traits => ['NoGetopt'], | ||
| 60 | is => 'rw', | ||
| 61 | builder => '_read_transcript_collection', | ||
| 62 | lazy => 1, | ||
| 63 | ); | ||
| 64 | |||
| 65 | |||
| 66 | ####################################################################### | ||
| 67 | ######################## Interface Methods ######################## | ||
| 68 | ####################################################################### | ||
| 69 | sub validate_args {} | ||
| 70 | |||
| 71 | |||
| 72 | ####################################################################### | ||
| 73 | ######################### Private Methods ######################### | ||
| 74 | ####################################################################### | ||
| 75 | sub _read_gene_collection { | ||
| 76 | my ($self) = @_; | ||
| 77 | |||
| 78 | return GenOO::GeneCollection::Factory->create('GTF', { | ||
| 79 | file => $self->gtf | ||
| 80 | })->read_collection; | ||
| 81 | } | ||
| 82 | |||
| 83 | sub _read_transcript_collection { | ||
| 84 | my ($self) = @_; | ||
| 85 | |||
| 86 | return GenOO::TranscriptCollection::Factory->create('FromGeneCollection', { | ||
| 87 | gene_collection => $self->gene_collection | ||
| 88 | })->read_collection; | ||
| 89 | } | ||
| 90 | |||
| 91 | |||
| 92 | 1; |