File Coverage

blib/lib/Bio/Phylo/Set.pm
Criterion Covered Total %
statement 14 16 87.5
branch 1 2 50.0
condition n/a
subroutine 5 7 71.4
pod 1 1 100.0
total 21 26 80.7


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