line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::GroupLabels; |
2
|
|
|
|
|
|
|
$Bio::Roary::GroupLabels::VERSION = '3.11.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Add labels to the groups |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
83435
|
use Moose; |
|
3
|
|
|
|
|
393000
|
|
|
3
|
|
|
|
|
18
|
|
7
|
3
|
|
|
3
|
|
17688
|
use Bio::Roary::Exceptions; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
800
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'groups_filename' => ( is => 'ro', isa => 'Str', required => 1 ); |
10
|
|
|
|
|
|
|
has 'output_filename' => ( is => 'ro', isa => 'Str', default => 'labelled_groups_file' ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has '_input_fh' => ( is => 'ro', lazy => 1, builder => '_build__input_fh' ); |
13
|
|
|
|
|
|
|
has '_output_fh' => ( is => 'ro', lazy => 1, builder => '_build__output_fh' ); |
14
|
|
|
|
|
|
|
has '_group_default_prefix' => ( is => 'ro', isa => 'Str', default => 'group_' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _build__input_fh { |
17
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
18
|
1
|
50
|
|
|
|
22
|
open( my $fh, $self->groups_filename ) |
19
|
|
|
|
|
|
|
or Bio::Roary::Exceptions::FileNotFound->throw( error => "Group file not found:" . $self->groups_filename ); |
20
|
1
|
|
|
|
|
21
|
return $fh; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _build__output_fh { |
24
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
25
|
1
|
50
|
|
|
|
21
|
open( my $fh, '>', $self->output_filename ) |
26
|
|
|
|
|
|
|
or Bio::Roary::Exceptions::CouldntWriteToFile->throw( |
27
|
|
|
|
|
|
|
error => "Couldnt write output file:" . $self->output_filename ); |
28
|
1
|
|
|
|
|
22
|
return $fh; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add_labels { |
32
|
1
|
|
|
1
|
0
|
2
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
2
|
my $counter = 1; |
35
|
1
|
|
|
|
|
26
|
my $in_fh = $self->_input_fh; |
36
|
1
|
|
|
|
|
12
|
while (<$in_fh>) { |
37
|
6
|
|
|
|
|
9
|
my $line = $_; |
38
|
6
|
50
|
|
|
|
9
|
next if ( $line eq "" ); |
39
|
6
|
|
|
|
|
6
|
print { $self->_output_fh } $self->_group_default_prefix . $counter . ": " . $line; |
|
6
|
|
|
|
|
99
|
|
40
|
6
|
|
|
|
|
19
|
$counter++; |
41
|
|
|
|
|
|
|
} |
42
|
1
|
|
|
|
|
17
|
close( $self->_input_fh ); |
43
|
1
|
|
|
|
|
18
|
close( $self->_output_fh ); |
44
|
1
|
|
|
|
|
8
|
return 1; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
3
|
|
18
|
no Moose; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
14
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding UTF-8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Bio::Roary::GroupLabels - Add labels to the groups |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
version 3.11.0 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Add labels to the groups |
69
|
|
|
|
|
|
|
use Bio::Roary::GroupLabels; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $obj = Bio::Roary::GroupLabels->new( |
72
|
|
|
|
|
|
|
groups_filename => 'abc.groups', |
73
|
|
|
|
|
|
|
output_filename => 'output.groups' |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
$obj->add_labels; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software, licensed under: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |