File Coverage

blib/lib/Bio/Palantir/Parser/Gene.pm
Criterion Covered Total %
statement 47 114 41.2
branch 4 28 14.2
condition 0 6 0.0
subroutine 15 34 44.1
pod 22 22 100.0
total 88 204 43.1


line stmt bran cond sub pod time code
1             package Bio::Palantir::Parser::Gene;
2             # ABSTRACT: BiosynML DTD-derived internal class
3             $Bio::Palantir::Parser::Gene::VERSION = '0.200700';
4 1     1   515 use Moose;
  1         2  
  1         5  
5 1     1   5275 use namespace::autoclean;
  1         3  
  1         5  
6              
7             # AUTOGENERATED CODE! DO NOT MODIFY THIS FILE!
8              
9 1     1   66 use XML::Bare qw(forcearray);
  1         2  
  1         69  
10 1     1   7 use Data::UUID;
  1         2  
  1         47  
11              
12 1     1   5 use aliased 'Bio::Palantir::Parser::Domain';
  1         1  
  1         6  
13 1     1   101 use aliased 'Bio::Palantir::Parser::Motif';
  1         2  
  1         5  
14 1     1   143 use aliased 'Bio::Palantir::Parser::Qualifier';
  1         3  
  1         3  
15 1     1   155 use aliased 'Bio::Palantir::Parser::Location';
  1         3  
  1         4  
16              
17              
18             # private attributes
19             has '_root' => (
20             is => 'ro',
21             isa => 'HashRef',
22             required => 1,
23             );
24              
25              
26             has 'uui' => (
27             is => 'ro',
28             isa => 'Str',
29             init_arg => undef,
30             default => sub {
31             my $self = shift;
32             my $ug = Data::UUID->new;
33             my $uui = $ug->create_str();
34             return $uui;
35             }
36             );
37              
38             has 'rank' => (
39             is => 'ro',
40             isa => 'Num',
41             default => -1,
42             writer => '_set_rank',
43             );
44              
45              
46             # public array(s) of composed objects
47              
48              
49             has 'domains' => (
50             traits => ['Array'],
51             is => 'ro',
52             isa => 'ArrayRef[Bio::Palantir::Parser::Domain]',
53             handles => {
54             count_domains => 'count',
55             all_domains => 'elements',
56             get_domain => 'get',
57             next_domain => 'shift',
58             },
59             );
60              
61              
62             ## no critic (ProhibitUnusedPrivateSubroutines)
63              
64              
65             ## use critic
66              
67              
68              
69             has 'orphan_motifs' => (
70             traits => ['Array'],
71             is => 'ro',
72             isa => 'ArrayRef[Bio::Palantir::Parser::Motif]',
73             handles => {
74             count_orphan_motifs => 'count',
75             all_orphan_motifs => 'elements',
76             get_orphan_motif => 'get',
77             next_orphan_motif => 'shift',
78             },
79             );
80              
81              
82             ## no critic (ProhibitUnusedPrivateSubroutines)
83              
84              
85             ## use critic
86              
87              
88              
89             has 'qualifiers' => (
90             traits => ['Array'],
91             is => 'ro',
92             isa => 'ArrayRef[Bio::Palantir::Parser::Qualifier]',
93             init_arg => undef,
94             lazy => 1,
95             builder => '_build_qualifiers',
96             handles => {
97             count_qualifiers => 'count',
98             all_qualifiers => 'elements',
99             get_qualifier => 'get',
100             next_qualifier => 'shift',
101             filter_qualifiers => 'grep',
102             },
103             );
104              
105              
106             ## no critic (ProhibitUnusedPrivateSubroutines)
107             sub _build_qualifiers {
108 79     79   101 my $self = shift;
109 279         7397 return [ map { Qualifier->new( _root => $_ ) } @{
110 79         90 forcearray $self->_root->{gene_qualifiers}->{qualifier}
111 79         1903 } ];
112             }
113              
114              
115             ## use critic
116              
117              
118              
119             # public composed object(s)
120              
121              
122             has 'locations' => (
123             is => 'ro',
124             isa => 'Bio::Palantir::Parser::Location',
125             init_arg => undef,
126             lazy => 1,
127             builder => '_build_locations',
128             handles => {
129             genomic_dna_begin => 'dna_begin',
130             genomic_dna_end => 'dna_end',
131             genomic_dna_size => 'dna_size',
132             genomic_dna_coordinates => 'dna_coordinates',
133             genomic_prot_begin => 'prot_begin',
134             genomic_prot_end => 'prot_end',
135             genomic_prot_size => 'prot_size',
136             genomic_prot_coordinates => 'prot_coordinates',
137             },
138             );
139              
140             ## no critic (ProhibitUnusedPrivateSubroutines)
141              
142             sub _build_locations {
143 79     79   93 my $self = shift;
144             return Location->new(
145             _root => $self->_root->{gene_location}
146 79         1750 );
147             }
148              
149             # use critic
150              
151              
152             # public deep methods
153              
154              
155             # public methods
156              
157              
158             sub name {
159 0   0 0 1 0 return shift->_root->{'gene_name'}->{'value'} // 'NA'
160             }
161              
162              
163             sub sequence {
164 0   0 0 1 0 return shift->_root->{'sequence'}->{'value'} // 'NA'
165             }
166              
167              
168             sub operon {
169 0   0 0 1 0 return shift->_root->{'operon'}->{'value'} // 'NA'
170             }
171              
172              
173              
174             # public aliases
175              
176              
177             sub transcript_id {
178 0     0 1 0 my $transcript_id;
179              
180 0         0 for my $qualifier(shift->_get_filtered_qualifiers('note')) {
181 0         0 ($transcript_id) = $qualifier =~ m/ transcript_id \= (.*) /xms;
182 0 0       0 last if $transcript_id;
183             }
184            
185 0         0 return $transcript_id;
186             }
187              
188            
189             sub protein_sequence {
190 0     0 1 0 return shift->_get_filtered_qualifiers('translation')
191             }
192              
193            
194             sub gene_id {
195 0     0 1 0 return shift->_get_filtered_qualifiers('gene')
196             }
197              
198            
199             sub protein_id {
200 0     0 1 0 return shift->_get_filtered_qualifiers('protein_id')
201             }
202              
203            
204             sub product_id {
205 0     0 1 0 return shift->_get_filtered_qualifiers('product')
206             }
207              
208            
209             sub locus_tag {
210 15     15 1 62 return shift->_get_filtered_qualifiers('locus_tag')
211             }
212              
213              
214             sub smcog {
215 0     0 1 0 my $smcog;
216              
217 0         0 for my $qualifier(shift->_get_filtered_qualifiers('smCOG')) {
218 0         0 ($smcog) = $qualifier =~ m/ SMCOG \d+ : \s (.*) /xms;
219 0 0       0 last if $smcog;
220             }
221            
222 0         0 return $smcog;
223             }
224              
225              
226             sub uniprot_id {
227 0     0 1 0 my $uniprot_id;
228              
229 0         0 for my $qualifier(shift->_get_filtered_qualifiers('db_xref')) {
230 0         0 ($uniprot_id) = $qualifier =~ m/ Uniprot\/SPTREMBL: (.*) /xms;
231 0 0       0 last if $uniprot_id;
232             }
233            
234 0         0 return $uniprot_id;
235             }
236              
237              
238             sub go_ids {
239 0     0 1 0 my @go_ids;
240              
241 0         0 for my $qualifier (shift->_get_filtered_qualifiers('db_xref')) {
242 0         0 my ($go_id) = $qualifier =~ m/ GO: (.*) /xms;
243 0 0       0 push @go_ids, $go_id
244             if $go_id;
245             }
246              
247 0         0 return @go_ids;
248             }
249              
250              
251             sub uniparc_id {
252 0     0 1 0 my $uniparc_id;
253              
254 0         0 for my $qualifier(shift->_get_filtered_qualifiers('db_xref')) {
255 0         0 ($uniparc_id) = $qualifier =~ m/ UniParc: (.*) /xms;
256 0 0       0 last if $uniparc_id;
257             }
258            
259 0         0 return $uniparc_id;
260             }
261              
262              
263             sub type {
264 0     0 1 0 my $type;
265              
266 0         0 for my $qualifier(shift->_get_filtered_qualifiers('sec_met')) {
267 0         0 ($type) = $qualifier =~ m/ Type: \s (.*) /xms;
268 0 0       0 last if $type;
269             }
270            
271 0         0 return $type;
272             }
273              
274              
275             sub domains_detail {
276 0     0 1 0 my $domains_detail;
277              
278 0         0 for my $qualifier(shift->_get_filtered_qualifiers('sec_met')) {
279 0         0 ($domains_detail) = $qualifier =~ m/ Domains \s detected: \s (.*) /xms;
280 0 0       0 last if $domains_detail;
281             }
282            
283 0         0 return $domains_detail;
284             }
285              
286              
287             sub kind {
288 0     0 1 0 my $kind;
289              
290 0         0 for my $qualifier(shift->_get_filtered_qualifiers('sec_met')) {
291 0         0 ($kind) = $qualifier =~ m/ Kind: \s (.)* /xms;
292 0 0       0 last if $kind;
293             }
294            
295 0         0 return $kind;
296             }
297              
298              
299             sub subtype {
300 0     0 1 0 my $subtype;
301              
302 0         0 for my $qualifier(shift->_get_filtered_qualifiers('sec_met')) {
303 0         0 ($subtype) = $qualifier =~ m/ NRPS\/PKS \s subtype: \s (.*) /xms;
304 0 0       0 last if $subtype;
305             }
306            
307 0         0 return $subtype;
308             }
309              
310              
311             sub bgc_domains {
312 15     15 1 51 my @bgc_domains;
313              
314 15         45 for my $qualifier (shift->_get_filtered_qualifiers('sec_met')) {
315 10         33 my ($bgc_domain) = $qualifier =~ m/ NRPS\/PKS \s Domain: \s (.*) /xms;
316 10 100       24 push @bgc_domains, $bgc_domain
317             if $bgc_domain;
318             }
319              
320 15         32 return @bgc_domains;
321             }
322              
323              
324             sub monomers {
325 94     94 1 183 my @monomers;
326              
327 94         203 for my $qualifier (shift->_get_filtered_qualifiers('sec_met')) {
328 49         120 my ($monomer) = $qualifier =~ m/ Substrate \s specificity
329             \s predictions: .*? , \s ( [\w,]* )
330             \s \(consensus\) /xms;
331 49 100       86 push @monomers, $monomer
332             if $monomer;
333             }
334              
335 94         212 return @monomers;
336             }
337              
338              
339             sub nrpspredictor_monomers {
340 0     0 1 0 my @nrpspredictor_monomers;
341              
342 0         0 for my $qualifier (shift->_get_filtered_qualifiers('sec_met')) {
343 0         0 my ($nrpspredictor_monomer) = $qualifier =~ m/ Substrate \s specificity
344             \s predictions: \s ( [\w,]* )
345             \s \(NRPSPredictor2 \s SVM\) /xms;
346 0 0       0 push @nrpspredictor_monomers, $nrpspredictor_monomer
347             if $nrpspredictor_monomer;
348             }
349              
350 0         0 return @nrpspredictor_monomers;
351             }
352              
353              
354             sub stachelhaus_monomers {
355 0     0 1 0 my @stachelhaus_monomers;
356              
357 0         0 for my $qualifier (shift->_get_filtered_qualifiers('sec_met')) {
358 0         0 my ($stachelhaus_monomer) = $qualifier =~ m/ Substrate \s specificity
359             \s predictions: .*? , \s ( [\w,]* )
360             \s \(Stachelhaus \s code\) /xms;
361 0 0       0 push @stachelhaus_monomers, $stachelhaus_monomer
362             if $stachelhaus_monomer;
363             }
364              
365 0         0 return @stachelhaus_monomers;
366             }
367              
368              
369             sub minowa_monomers {
370 0     0 1 0 my @minowa_monomers;
371              
372 0         0 for my $qualifier (shift->_get_filtered_qualifiers('sec_met')) {
373 0         0 my ($minowa_monomer) = $qualifier =~ m/ Substrate \s specificity
374             \s predictions: .*? , \s ( [\w,]* )
375             \s \(Minowa\) /xms;
376 0 0       0 push @minowa_monomers, $minowa_monomer
377             if $minowa_monomer;
378             }
379              
380 0         0 return @minowa_monomers;
381             }
382              
383             sub _get_filtered_qualifiers {
384 124     124   152 my $self = shift;
385 124         141 my $pattern = shift;
386              
387             my (@filtered_qualifiers)
388 124     453   4186 = $self->filter_qualifiers( sub { $_->name eq $pattern} );
  453         826  
389 124         495 return map { $_->value } @filtered_qualifiers;
  74         137  
390             }
391              
392              
393             __PACKAGE__->meta->make_immutable;
394             1;
395              
396             __END__
397              
398             =pod
399              
400             =head1 NAME
401              
402             Bio::Palantir::Parser::Gene - BiosynML DTD-derived internal class
403              
404             =head1 VERSION
405              
406             version 0.200700
407              
408             =head1 SYNOPSIS
409              
410             # TODO
411              
412             =head1 DESCRIPTION
413              
414             # TODO
415              
416             =head1 ATTRIBUTES
417              
418             =head2 domains
419              
420             ArrayRef of L<Bio::Palantir::Parser::Domain>
421              
422             =head2 orphan_motifs
423              
424             ArrayRef of L<Bio::Palantir::Parser::Motif>
425              
426             =head2 qualifiers
427              
428             ArrayRef of L<Bio::Palantir::Parser::Qualifier>
429              
430             =head2 locations
431              
432             L<Bio::Palantir::Parser::Location> composed object
433              
434             =head1 METHODS
435              
436             =head2 count_domains
437              
438             Returns the number of Domains of the Gene.
439              
440             # $gene is a Bio::Palantir::Parser::Gene
441             my $count = $gene->count_domains;
442              
443             This method does not accept any arguments.
444              
445             =head2 all_domains
446              
447             Returns all the Domains of the Gene (not an array reference).
448              
449             # $gene is a Bio::Palantir::Parser::Gene
450             my @domains = $gene->all_domains;
451              
452             This method does not accept any arguments.
453              
454             =head2 get_domain
455              
456             Returns one Domain of the Gene by its index. You can also use
457             negative index numbers, just as with Perl's core array handling. If the
458             specified Domain does not exist, this method will return C<undef>.
459              
460             # $gene is a Bio::Palantir::Parser::Gene
461             my $domain = $gene->get_domain($index);
462             croak "Domain $index not found!" unless defined $domain;
463              
464             This method accepts just one argument (and not an array slice).
465              
466             =head2 next_domain
467              
468             Shifts the first Domain of the array off and returns it, shortening the
469             array by 1 and moving everything down. If there are no more Domains in
470             the array, returns C<undef>.
471              
472             # $gene is a Bio::Palantir::Parser::Gene
473             while (my $domain = $gene->next_domain) {
474             # process $domain
475             # ...
476             }
477              
478             This method does not accept any arguments.
479              
480             =head2 count_orphan_motifs
481              
482             Returns the number of Motifs of the Gene.
483              
484             # $gene is a Bio::Palantir::Parser::Gene
485             my $count = $gene->count_orphan_motifs;
486              
487             This method does not accept any arguments.
488              
489             =head2 all_orphan_motifs
490              
491             Returns all the Motifs of the Gene (not an array reference).
492              
493             # $gene is a Bio::Palantir::Parser::Gene
494             my @orphan_motifs = $gene->all_orphan_motifs;
495              
496             This method does not accept any arguments.
497              
498             =head2 get_orphan_motif
499              
500             Returns one Motif of the Gene by its index. You can also use
501             negative index numbers, just as with Perl's core array handling. If the
502             specified Motif does not exist, this method will return C<undef>.
503              
504             # $gene is a Bio::Palantir::Parser::Gene
505             my $orphan_motif = $gene->get_orphan_motif($index);
506             croak "Motif $index not found!" unless defined $orphan_motif;
507              
508             This method accepts just one argument (and not an array slice).
509              
510             =head2 next_orphan_motif
511              
512             Shifts the first Motif of the array off and returns it, shortening the
513             array by 1 and moving everything down. If there are no more Motifs in
514             the array, returns C<undef>.
515              
516             # $gene is a Bio::Palantir::Parser::Gene
517             while (my $orphan_motif = $gene->next_orphan_motif) {
518             # process $orphan_motif
519             # ...
520             }
521              
522             This method does not accept any arguments.
523              
524             =head2 count_qualifiers
525              
526             Returns the number of Qualifiers of the Gene.
527              
528             # $gene is a Bio::Palantir::Parser::Gene
529             my $count = $gene->count_qualifiers;
530              
531             This method does not accept any arguments.
532              
533             =head2 all_qualifiers
534              
535             Returns all the Qualifiers of the Gene (not an array reference).
536              
537             # $gene is a Bio::Palantir::Parser::Gene
538             my @qualifiers = $gene->all_qualifiers;
539              
540             This method does not accept any arguments.
541              
542             =head2 get_qualifier
543              
544             Returns one Qualifier of the Gene by its index. You can also use
545             negative index numbers, just as with Perl's core array handling. If the
546             specified Qualifier does not exist, this method will return C<undef>.
547              
548             # $gene is a Bio::Palantir::Parser::Gene
549             my $qualifier = $gene->get_qualifier($index);
550             croak "Qualifier $index not found!" unless defined $qualifier;
551              
552             This method accepts just one argument (and not an array slice).
553              
554             =head2 next_qualifier
555              
556             Shifts the first Qualifier of the array off and returns it, shortening the
557             array by 1 and moving everything down. If there are no more Qualifiers in
558             the array, returns C<undef>.
559              
560             # $gene is a Bio::Palantir::Parser::Gene
561             while (my $qualifier = $gene->next_qualifier) {
562             # process $qualifier
563             # ...
564             }
565              
566             This method does not accept any arguments.
567              
568             =head2 name
569              
570             Returns the value of the element C<<gene_name>>.
571              
572             # $gene is a Bio::Palantir::Parser::Gene
573             my $name = $gene->name;
574              
575             This method does not accept any arguments.
576              
577             =head2 sequence
578              
579             Returns the value of the element C<<sequence>>.
580              
581             # $gene is a Bio::Palantir::Parser::Gene
582             my $sequence = $gene->sequence;
583              
584             This method does not accept any arguments.
585              
586             =head2 operon
587              
588             Returns the value of the element C<<operon>>.
589              
590             # $gene is a Bio::Palantir::Parser::Gene
591             my $operon = $gene->operon;
592              
593             This method does not accept any arguments.
594              
595             =head2 transcript_id
596              
597             Returns the value of the element C<<transcript_id>>.
598              
599             # $gene is a Bio::FastParsers::Biosynml::Gene
600             my $transcript_id = $gene->transcript_id;
601              
602             This method does not accept any arguments.
603              
604             =head2 protein_sequence
605              
606             Returns the value of the element C<<protein_sequence>>.
607              
608             # $gene is a Bio::FastParsers::Biosynml::Gene
609             my $protein_sequence = $gene->protein_sequence;
610              
611             This method does not accept any arguments.
612              
613             =head2 gene_id
614              
615             Returns the value of the element C<<gene_id>>.
616              
617             # $gene is a Bio::FastParsers::Biosynml::Gene
618             my $gene_id = $gene->gene_id;
619              
620             This method does not accept any arguments.
621              
622             =head2 protein_id
623              
624             Returns the value of the element C<<protein_id>>.
625              
626             # $gene is a Bio::FastParsers::Biosynml::Gene
627             my $protein_id = $gene->protein_id;
628              
629             This method does not accept any arguments.
630              
631             =head2 product_id
632              
633             Returns the value of the element C<<product_id>>.
634              
635             # $gene is a Bio::FastParsers::Biosynml::Gene
636             my $product_id = $gene->product_id;
637              
638             This method does not accept any arguments.
639              
640             =head2 locus_tag
641              
642             Returns the value of the element C<<locus_tag>>.
643              
644             # $gene is a Bio::FastParsers::Biosynml::Gene
645             my $locus_tag = $gene->locus_tag;
646              
647             This method does not accept any arguments.
648              
649             =head2 smcog
650              
651             Returns the value of the element C<<smcog>>.
652              
653             # $gene is a Bio::FastParsers::Biosynml::Gene
654             my $smcog = $gene->smcog;
655              
656             This method does not accept any arguments.
657              
658             =head2 uniprot_id
659              
660             Returns the value of the element C<<uniprot_id>>.
661              
662             # $gene is a Bio::FastParsers::Biosynml::Gene
663             my $uniprot_id = $gene->uniprot_id;
664              
665             This method does not accept any arguments.
666              
667             =head2 go_ids
668              
669             Returns the values of the elements C<<go_ids>>.
670              
671             # $gene is a Bio::FastParsers::Biosynml::Gene
672             my @go_ids = $gene->go_ids;
673              
674             This method does not accept any arguments.
675              
676             =head2 uniparc_id
677              
678             Returns the value of the element C<<uniparc_id>>.
679              
680             # $gene is a Bio::FastParsers::Biosynml::Gene
681             my $uniparc_id = $gene->uniparc_id;
682              
683             This method does not accept any arguments.
684              
685             =head2 type
686              
687             Returns the value of the element C<<type>>.
688              
689             # $gene is a Bio::FastParsers::Biosynml::Gene
690             my $type = $gene->type;
691              
692             This method does not accept any arguments.
693              
694             =head2 domains_detail
695              
696             Returns the value of the element C<<domains_detail>>.
697              
698             # $gene is a Bio::FastParsers::Biosynml::Gene
699             my $domains_detail = $gene->domains_detail;
700              
701             This method does not accept any arguments.
702              
703             =head2 kind
704              
705             Returns the value of the element C<<kind>>.
706              
707             # $gene is a Bio::FastParsers::Biosynml::Gene
708             my $kind = $gene->kind;
709              
710             This method does not accept any arguments.
711              
712             =head2 subtype
713              
714             Returns the value of the element C<<subtype>>.
715              
716             # $gene is a Bio::FastParsers::Biosynml::Gene
717             my $subtype = $gene->subtype;
718              
719             This method does not accept any arguments.
720              
721             =head2 bgc_domains
722              
723             Returns the values of the elements C<<bgc_domains>>.
724              
725             # $gene is a Bio::FastParsers::Biosynml::Gene
726             my @bgc_domains = $gene->bgc_domains;
727              
728             This method does not accept any arguments.
729              
730             =head2 monomers
731              
732             Returns the values of the elements C<<monomers>>.
733              
734             # $gene is a Bio::FastParsers::Biosynml::Gene
735             my @monomers = $gene->monomers;
736              
737             This method does not accept any arguments.
738              
739             =head2 nrpspredictor_monomers
740              
741             Returns the values of the elements C<<nrpspredictor_monomers>>.
742              
743             # $gene is a Bio::FastParsers::Biosynml::Gene
744             my @nrpspredictor_monomers = $gene->nrpspredictor_monomers;
745              
746             This method does not accept any arguments.
747              
748             =head2 stachelhaus_monomers
749              
750             Returns the values of the elements C<<stachelhaus_monomers>>.
751              
752             # $gene is a Bio::FastParsers::Biosynml::Gene
753             my @stachelhaus_monomers = $gene->stachelhaus_monomers;
754              
755             This method does not accept any arguments.
756              
757             =head2 minowa_monomers
758              
759             Returns the values of the elements C<<minowa_monomers>>.
760              
761             # $gene is a Bio::FastParsers::Biosynml::Gene
762             my @minowa_monomers = $gene->minowa_monomers;
763              
764             This method does not accept any arguments.
765              
766             =head1 AUTHOR
767              
768             Loic MEUNIER <lmeunier@uliege.be>
769              
770             =head1 COPYRIGHT AND LICENSE
771              
772             This software is copyright (c) 2019 by University of Liege / Unit of Eukaryotic Phylogenomics / Loic MEUNIER and Denis BAURAIN.
773              
774             This is free software; you can redistribute it and/or modify it under
775             the same terms as the Perl 5 programming language system itself.
776              
777             =cut