File Coverage

blib/lib/Bio/Phylo/Set.pm
Criterion Covered Total %
statement 17 19 89.4
branch 1 2 50.0
condition n/a
subroutine 6 8 75.0
pod 1 1 100.0
total 25 30 83.3


line stmt bran cond sub pod time code
1             package Bio::Phylo::Set;
2 1     1   6 use strict;
  1         2  
  1         25  
3 1     1   4 use warnings;
  1         2  
  1         25  
4 1     1   5 use base 'Bio::Phylo::Listable';
  1         2  
  1         84  
5 1     1   5 use Bio::Phylo::Util::CONSTANT qw'_NONE_ _SET_';
  1         2  
  1         153  
6              
7             =head1 NAME
8              
9             Bio::Phylo::Set - Subset of the parts inside a container
10              
11             =head1 SYNOPSIS
12              
13             use Bio::Phylo::Factory;
14             my $fac = Bio::Phylo::Factory->new;
15            
16             my $forest = $fac->create_forest;
17             my $tree = $fac->create_tree;
18             $forest->insert($tree);
19            
20             my $set = $fac->create_set( -name => 'TreeSet1' );
21             $forest->add_set($set);
22             $forest->add_to_set($tree,$set); # $tree is now part of TreeSet1
23              
24             =head1 DESCRIPTION
25              
26             Many Bio::Phylo objects are segmented: they contain one or more subparts
27             of the same type. For example, a matrix contains multiple rows; each row
28             contains multiple cells; a tree contains nodes, and so on. Segmented objects
29             all inherit from L<Bio::Phylo::Listable>. In many cases it is useful to be
30             able to define subsets of the contents of segmented objects, for example
31             sets of taxon objects inside a taxa block. The Bio::Phylo::Listable object
32             allows this through a number of methods (add_set, remove_set, add_to_set,
33             remove_from_set and so on). Those methods delegate the actual management of the set
34             contents to the Bio::Phylo::Set object, the class whose documentation you're
35             reading now. Consult the documentation for L<Bio::Phylo::Listable/SETS MANAGEMENT>
36             for more information on how to use this feature.
37              
38             =head1 METHODS
39              
40             =head2 CONSTRUCTOR
41              
42             =over
43              
44             =item new()
45              
46             Type : Constructor
47             Title : new
48             Usage : my $anno = Bio::Phylo::Set->new;
49             Function: Initializes a Bio::Phylo::Set object.
50             Returns : A Bio::Phylo::Set object.
51             Args : optional constructor arguments are key/value
52             pairs where the key corresponds with any of
53             the methods that starts with set_ (i.e. mutators)
54             and the value is the permitted argument for such
55             a method. The method name is changed such that,
56             in order to access the set_value($val) method
57             in the constructor, you would pass -value => $val
58              
59             =cut
60              
61             {
62             my $NONE = _NONE_;
63             my $TYPE = _SET_;
64              
65             # sub new {
66             # return shift->SUPER::new( '-tag' => 'class', @_ );
67             # }
68              
69             =back
70              
71             =head2 TESTS
72              
73             =over
74              
75             =item can_contain()
76              
77             Tests if argument can be inserted in invocant.
78              
79             Type : Test
80             Title : can_contain
81             Usage : &do_something if $listable->can_contain( $obj );
82             Function: Tests if $obj can be inserted in $listable
83             Returns : BOOL
84             Args : An $obj to test
85              
86             =cut
87              
88             sub can_contain {
89 14     14 1 29 my ( $self, @obj ) = @_;
90 14         17 for my $obj (@obj) {
91 14 50       27 return 0 if ref $obj;
92             }
93 14         36 return 1;
94             }
95 0     0   0 sub _container { $NONE }
96 26     26   41 sub _type { $TYPE }
97 0     0     sub _tag { 'set' }
98             }
99              
100             =back
101              
102             =cut
103              
104             # podinherit_insert_token
105              
106             =head1 SEE ALSO
107              
108             There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo>
109             for any user or developer questions and discussions.
110              
111             Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>.
112              
113             Consult the documentation for L<Bio::Phylo::Listable/SETS MANAGEMENT> for more info
114             on how to define subsets of the contents of segmented objects.
115              
116             =head2 Superclasses
117              
118             =over
119              
120             =item L<Bio::Phylo::Listable>
121              
122             This object inherits from L<Bio::Phylo::Listable>, so methods
123             defined there are also applicable here.
124              
125             =back
126              
127             =head1 CITATION
128              
129             If you use Bio::Phylo in published research, please cite it:
130              
131             B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen>
132             and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl.
133             I<BMC Bioinformatics> B<12>:63.
134             L<http://dx.doi.org/10.1186/1471-2105-12-63>
135              
136             =cut
137              
138             1;