line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::SampleOrder; |
2
|
|
|
|
|
|
|
$Bio::Roary::SampleOrder::VERSION = '3.10.1'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Take in a tree file and return an ordering of the samples |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
88572
|
use Moose; |
|
3
|
|
|
|
|
389315
|
|
|
3
|
|
|
|
|
18
|
|
7
|
3
|
|
|
3
|
|
18548
|
use Bio::TreeIO; |
|
3
|
|
|
|
|
129842
|
|
|
3
|
|
|
|
|
452
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'tree_file' => ( is => 'ro', isa => 'Str', required => 1 ); |
10
|
|
|
|
|
|
|
has 'tree_format' => ( is => 'ro', isa => 'Str', default => 'newick' ); |
11
|
|
|
|
|
|
|
has 'ordered_samples' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build_ordered_samples' ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# 'b|breadth' first order or 'd|depth' first order |
14
|
|
|
|
|
|
|
has 'search_strategy' => ( is => 'ro', isa => 'Str', default => 'depth' ); |
15
|
|
|
|
|
|
|
has 'sortby' => (is => 'ro', isa => 'Maybe[Str]'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_ordered_samples { |
19
|
16
|
|
|
16
|
|
33
|
my ($self) = @_; |
20
|
16
|
|
|
|
|
303
|
my $input = Bio::TreeIO->new( |
21
|
|
|
|
|
|
|
-file => $self->tree_file, |
22
|
|
|
|
|
|
|
-format => $self->tree_format |
23
|
|
|
|
|
|
|
); |
24
|
16
|
|
|
|
|
21521
|
my $tree = $input->next_tree; |
25
|
16
|
|
|
|
|
302137
|
my @taxa; |
26
|
16
|
|
|
|
|
539
|
for my $leaf_node ( $tree->get_nodes($self->search_strategy,$self->sortby) ) { |
27
|
360
|
100
|
|
|
|
12348
|
if($leaf_node->is_Leaf) |
28
|
|
|
|
|
|
|
{ |
29
|
196
|
|
|
|
|
1189
|
push( @taxa, $leaf_node->id ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
16
|
|
|
|
|
139
|
return \@taxa; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
3
|
|
31
|
no Moose; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
26
|
|
36
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding UTF-8 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Bio::Roary::SampleOrder - Take in a tree file and return an ordering of the samples |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 VERSION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
version 3.10.1 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Take in a tree file and return an ordering of the samples. Defaults to depth first search |
57
|
|
|
|
|
|
|
use Bio::Roary::SampleOrder; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $obj = Bio::Roary::SampleOrder->new( |
60
|
|
|
|
|
|
|
tree_file => $tree_file, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
$obj->ordered_samples(); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 AUTHOR |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This is free software, licensed under: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |