File Coverage

blib/lib/Bio/Palantir/Parser/Motif.pm
Criterion Covered Total %
statement 37 38 97.3
branch 2 2 100.0
condition 2 6 33.3
subroutine 13 14 92.8
pod 4 4 100.0
total 58 64 90.6


line stmt bran cond sub pod time code
1             package Bio::Palantir::Parser::Motif;
2             # ABSTRACT: BiosynML DTD-derived internal class
3             $Bio::Palantir::Parser::Motif::VERSION = '0.211420';
4 1     1   712 use Moose;
  1         2  
  1         6  
5 1     1   6559 use namespace::autoclean;
  1         2  
  1         6  
6              
7             # AUTOGENERATED CODE! DO NOT MODIFY THIS FILE!
8              
9 1     1   83 use XML::Bare qw(forcearray);
  1         1  
  1         42  
10 1     1   5 use Data::UUID;
  1         14  
  1         57  
11              
12 1     1   7 use aliased 'Bio::Palantir::Parser::Qualifier';
  1         1  
  1         7  
13 1     1   103 use aliased 'Bio::Palantir::Parser::Location';
  1         3  
  1         6  
14              
15              
16             # private attributes
17             has '_root' => (
18             is => 'ro',
19             isa => 'HashRef',
20             required => 1,
21             );
22              
23              
24             has 'uui' => (
25             is => 'ro',
26             isa => 'Str',
27             init_arg => undef,
28             default => sub {
29             my $self = shift;
30             my $ug = Data::UUID->new;
31             my $uui = $ug->create_str();
32             return $uui;
33             }
34             );
35              
36             has 'rank' => (
37             is => 'ro',
38             isa => 'Num',
39             default => -1,
40             writer => '_set_rank',
41             );
42              
43              
44             # public array(s) of composed objects
45              
46              
47             has 'qualifiers' => (
48             traits => ['Array'],
49             is => 'ro',
50             isa => 'ArrayRef[Bio::Palantir::Parser::Qualifier]',
51             init_arg => undef,
52             lazy => 1,
53             builder => '_build_qualifiers',
54             handles => {
55             count_qualifiers => 'count',
56             all_qualifiers => 'elements',
57             get_qualifier => 'get',
58             next_qualifier => 'shift',
59             filter_qualifiers => 'grep',
60             },
61             );
62              
63              
64             ## no critic (ProhibitUnusedPrivateSubroutines)
65             sub _build_qualifiers {
66 8     8   16 my $self = shift;
67 96         2873 return [ map { Qualifier->new( _root => $_ ) } @{
68 8         16 forcearray $self->_root->{motif_qualifiers}->{qualifier}
69 8         224 } ];
70             }
71              
72              
73             ## use critic
74              
75              
76              
77             # public composed object(s)
78              
79              
80             has 'locations' => (
81             is => 'ro',
82             isa => 'Bio::Palantir::Parser::Location',
83             init_arg => undef,
84             lazy => 1,
85             builder => '_build_locations',
86             handles => {
87             genomic_dna_begin => 'dna_begin',
88             genomic_dna_end => 'dna_end',
89             genomic_dna_size => 'dna_size',
90             genomic_dna_coordinates => 'dna_coordinates',
91             genomic_prot_begin => 'prot_begin',
92             genomic_prot_end => 'prot_end',
93             genomic_prot_size => 'prot_size',
94             genomic_prot_coordinates => 'prot_coordinates',
95             },
96             );
97              
98             ## no critic (ProhibitUnusedPrivateSubroutines)
99              
100             sub _build_locations {
101 8     8   15 my $self = shift;
102             return Location->new(
103             _root => $self->_root->{motif_location}
104 8         225 );
105             }
106              
107             # use critic
108              
109              
110             # public deep methods
111              
112              
113             # public methods
114              
115              
116             sub name {
117 8   50 8 1 245 return shift->_root->{'motif_name'}->{'value'} // 'NA'
118             }
119              
120              
121             sub type {
122 1   50 1 1 38 return shift->_root->{'motif_type'}->{'value'} // 'NA'
123             }
124              
125              
126             sub sequence {
127 0   0 0 1 0 return shift->_root->{'sequence'}->{'value'} // 'NA'
128             }
129              
130              
131              
132             # public aliases
133              
134              
135             sub detail {
136 8     8 1 37 my $detail;
137              
138 8         21 for my $qualifier(shift->_get_filtered_qualifiers('note')) {
139 48         104 ($detail) = $qualifier =~ m/ NRPS\/PKS \s Motif: \s (.*) /xms;
140 48 100       106 last if $detail;
141             }
142            
143 8         266 return $detail;
144             }
145              
146             sub _get_filtered_qualifiers {
147 8     8   13 my $self = shift;
148 8         13 my $pattern = shift;
149              
150             my (@filtered_qualifiers)
151 8     88   315 = $self->filter_qualifiers( sub { $_->name eq $pattern} );
  88         186  
152 8         32 return map { $_->value } @filtered_qualifiers;
  80         169  
153             }
154              
155              
156             __PACKAGE__->meta->make_immutable;
157             1;
158              
159             __END__
160              
161             =pod
162              
163             =head1 NAME
164              
165             Bio::Palantir::Parser::Motif - BiosynML DTD-derived internal class
166              
167             =head1 VERSION
168              
169             version 0.211420
170              
171             =head1 SYNOPSIS
172              
173             # TODO
174              
175             =head1 DESCRIPTION
176              
177             # TODO
178              
179             =head1 ATTRIBUTES
180              
181             =head2 qualifiers
182              
183             ArrayRef of L<Bio::Palantir::Parser::Qualifier>
184              
185             =head2 locations
186              
187             L<Bio::Palantir::Parser::Location> composed object
188              
189             =head1 METHODS
190              
191             =head2 count_qualifiers
192              
193             Returns the number of Qualifiers of the Motif.
194              
195             # $motif is a Bio::Palantir::Parser::Motif
196             my $count = $motif->count_qualifiers;
197              
198             This method does not accept any arguments.
199              
200             =head2 all_qualifiers
201              
202             Returns all the Qualifiers of the Motif (not an array reference).
203              
204             # $motif is a Bio::Palantir::Parser::Motif
205             my @qualifiers = $motif->all_qualifiers;
206              
207             This method does not accept any arguments.
208              
209             =head2 get_qualifier
210              
211             Returns one Qualifier of the Motif by its index. You can also use
212             negative index numbers, just as with Perl's core array handling. If the
213             specified Qualifier does not exist, this method will return C<undef>.
214              
215             # $motif is a Bio::Palantir::Parser::Motif
216             my $qualifier = $motif->get_qualifier($index);
217             croak "Qualifier $index not found!" unless defined $qualifier;
218              
219             This method accepts just one argument (and not an array slice).
220              
221             =head2 next_qualifier
222              
223             Shifts the first Qualifier of the array off and returns it, shortening the
224             array by 1 and moving everything down. If there are no more Qualifiers in
225             the array, returns C<undef>.
226              
227             # $motif is a Bio::Palantir::Parser::Motif
228             while (my $qualifier = $motif->next_qualifier) {
229             # process $qualifier
230             # ...
231             }
232              
233             This method does not accept any arguments.
234              
235             =head2 name
236              
237             Returns the value of the element C<<motif_name>>.
238              
239             # $motif is a Bio::Palantir::Parser::Motif
240             my $name = $motif->name;
241              
242             This method does not accept any arguments.
243              
244             =head2 type
245              
246             Returns the value of the element C<<motif_type>>.
247              
248             # $motif is a Bio::Palantir::Parser::Motif
249             my $type = $motif->type;
250              
251             This method does not accept any arguments.
252              
253             =head2 sequence
254              
255             Returns the value of the element C<<sequence>>.
256              
257             # $motif is a Bio::Palantir::Parser::Motif
258             my $sequence = $motif->sequence;
259              
260             This method does not accept any arguments.
261              
262             =head2 detail
263              
264             Returns the value of the element C<<detail>>.
265              
266             # $gene is a Bio::FastParsers::Biosynml::Gene
267             my $detail = $gene->detail;
268              
269             This method does not accept any arguments.
270              
271             =head1 AUTHOR
272              
273             Loic MEUNIER <lmeunier@uliege.be>
274              
275             =head1 COPYRIGHT AND LICENSE
276              
277             This software is copyright (c) 2019 by University of Liege / Unit of Eukaryotic Phylogenomics / Loic MEUNIER and Denis BAURAIN.
278              
279             This is free software; you can redistribute it and/or modify it under
280             the same terms as the Perl 5 programming language system itself.
281              
282             =cut