| 1 | # BioPerl module for Bio::Community::Role::Weighted | ||
| 2 | # | ||
| 3 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||
| 4 | # | ||
| 5 | # Copyright 2011-2014 Florent Angly <florent.angly@gmail.com> | ||
| 6 | # | ||
| 7 | # You may distribute this module under the same terms as perl itself | ||
| 8 | |||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Bio::Community::Role::Weighted - Role for objects that have a weight | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | package My::Package; | ||
| 17 | |||
| 18 | use Moose; | ||
| 19 | with 'Bio::Community::Role::Weighted'; | ||
| 20 | |||
| 21 | # Use the weights() method as needed | ||
| 22 | # ... | ||
| 23 | |||
| 24 | 1; | ||
| 25 | |||
| 26 | =head1 DESCRIPTION | ||
| 27 | |||
| 28 | This role provides the capability to add an arrayref of weights (strictly positive | ||
| 29 | numbers) to objects of the class that consumes this role. | ||
| 30 | |||
| 31 | =head1 AUTHOR | ||
| 32 | |||
| 33 | Florent Angly L<florent.angly@gmail.com> | ||
| 34 | |||
| 35 | =head1 SUPPORT AND BUGS | ||
| 36 | |||
| 37 | User feedback is an integral part of the evolution of this and other Bioperl | ||
| 38 | modules. Please direct usage questions or support issues to the mailing list, | ||
| 39 | L<bioperl-l@bioperl.org>, rather than to the module maintainer directly. Many | ||
| 40 | experienced and reponsive experts will be able look at the problem and quickly | ||
| 41 | address it. Please include a thorough description of the problem with code and | ||
| 42 | data examples if at all possible. | ||
| 43 | |||
| 44 | If you have found a bug, please report it on the BioPerl bug tracking system | ||
| 45 | to help us keep track the bugs and their resolution: | ||
| 46 | L<https://redmine.open-bio.org/projects/bioperl/> | ||
| 47 | |||
| 48 | =head1 COPYRIGHT | ||
| 49 | |||
| 50 | Copyright 2011-2014 by Florent Angly <florent.angly@gmail.com> | ||
| 51 | |||
| 52 | This library is free software; you can redistribute it and/or modify | ||
| 53 | it under the same terms as Perl itself, either Perl version 5.10.1 or, | ||
| 54 | at your option, any later version of Perl 5 you may have available. | ||
| 55 | |||
| 56 | =head1 APPENDIX | ||
| 57 | |||
| 58 | The rest of the documentation details each of the object | ||
| 59 | methods. Internal methods are usually preceded with a _ | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | |||
| 64 | package Bio::Community::Role::Weighted; | ||
| 65 | |||
| 66 | 22 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 67 | 22 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 68 | |||
| 69 | =head2 weights | ||
| 70 | |||
| 71 | Usage : my $weights = $member->weights(); | ||
| 72 | Function: Get or set some weights for this object. Weights represent how biased | ||
| 73 | the sampling of this organism is. For example, when random shotgun | ||
| 74 | sequencing microorganisms in the environment, the relative abundance | ||
| 75 | of reads in the sequence library is not proportional to the relative | ||
| 76 | abundance of the genomes because larger genomes contribute | ||
| 77 | disproportionalely more reads than small genomes. In such a case, you | ||
| 78 | could set the weight to the length of the genome. Do not attempt to | ||
| 79 | change weights after a member has been added to a community! | ||
| 80 | Note: Do not use a weight value of zero, except temporarily, and make | ||
| 81 | sure to give a proper weight (>0) before adding a member to a community. | ||
| 82 | Args : An arrayref of positive integers | ||
| 83 | Returns : An arrayref of positive integers | ||
| 84 | |||
| 85 | =cut | ||
| 86 | |||
| 87 | has weights => ( | ||
| 88 | is => 'rw', | ||
| 89 | ###isa => 'Maybe[ArrayRef[StrictlyPositiveNum]]', | ||
| 90 | isa => 'Maybe[ArrayRef[PositiveNum]]', | ||
| 91 | required => 0, | ||
| 92 | 285 | ▶ | default => sub{[ 1 ]}, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 93 | 22 | init_arg => '-weights', | |
| 94 | lazy => 1, | ||
| 95 | ); | ||
| 96 | |||
| 97 | |||
| 98 | 22 | 1; | |