| 1 | package Bio::Roary::SampleOrder; | ||||||||||
| 2 | 3 | $Bio::Roary::SampleOrder::VERSION = '3.13.0'; | |||||||||
| 3 | # ABSTRACT: Take in a tree file and return an ordering of the samples | ||||||||||
| 4 | |||||||||||
| 5 | |||||||||||
| 6 | 3 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use Bio::TreeIO; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 3 | has 'tree_file' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 10 | 3 | has 'tree_format' => ( is => 'ro', isa => 'Str', default => 'newick' ); | |||||||||
| 11 | 3 | 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 | 3 | has 'search_strategy' => ( is => 'ro', isa => 'Str', default => 'depth' ); | |||||||||
| 15 | 3 | has 'sortby' => (is => 'ro', isa => 'Maybe[Str]'); | |||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | 16 | ▶ | sub _build_ordered_samples { | ||||||||
|
Subroutine
_build_ordered_samples: called CC=3 SCAR=11.0
| |||||||||||
| 19 | 16 | my ($self) = @_; | |||||||||
| 20 | 16 | my $input = Bio::TreeIO->new( | |||||||||
| 21 | -file => $self->tree_file, | ||||||||||
| 22 | -format => $self->tree_format | ||||||||||
| 23 | ); | ||||||||||
| 24 | 16 | my $tree = $input->next_tree; | |||||||||
| 25 | 16 | my @taxa; | |||||||||
| 26 | 16 | for my $leaf_node ( $tree->get_nodes($self->search_strategy,$self->sortby) ) { | |||||||||
| 27 | 360 | ▶ | if($leaf_node->is_Leaf) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | { | ||||||||||
| 29 | 196 | push( @taxa, $leaf_node->id ); | |||||||||
| 30 | } | ||||||||||
| 31 | } | ||||||||||
| 32 | 16 | return \@taxa; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 3 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 36 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||
| 37 | |||||||||||
| 38 | 3 | 1; | |||||||||
| 39 | |||||||||||
| 40 | __END__ | ||||||||||