line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::SampleOrder; |
2
|
|
|
|
|
|
|
$Bio::Roary::SampleOrder::VERSION = '3.11.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Take in a tree file and return an ordering of the samples |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
86303
|
use Moose; |
|
3
|
|
|
|
|
402739
|
|
|
3
|
|
|
|
|
19
|
|
7
|
3
|
|
|
3
|
|
19378
|
use Bio::TreeIO; |
|
3
|
|
|
|
|
122320
|
|
|
3
|
|
|
|
|
442
|
|
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
|
|
32
|
my ($self) = @_; |
20
|
16
|
|
|
|
|
331
|
my $input = Bio::TreeIO->new( |
21
|
|
|
|
|
|
|
-file => $self->tree_file, |
22
|
|
|
|
|
|
|
-format => $self->tree_format |
23
|
|
|
|
|
|
|
); |
24
|
16
|
|
|
|
|
22293
|
my $tree = $input->next_tree; |
25
|
16
|
|
|
|
|
300475
|
my @taxa; |
26
|
16
|
|
|
|
|
657
|
for my $leaf_node ( $tree->get_nodes($self->search_strategy,$self->sortby) ) { |
27
|
360
|
100
|
|
|
|
12984
|
if($leaf_node->is_Leaf) |
28
|
|
|
|
|
|
|
{ |
29
|
196
|
|
|
|
|
1329
|
push( @taxa, $leaf_node->id ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
16
|
|
|
|
|
147
|
return \@taxa; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
3
|
|
22
|
no Moose; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
23
|
|
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.11.0 |
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 |