line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::SpreadsheetRole; |
2
|
|
|
|
|
|
|
$Bio::Roary::SpreadsheetRole::VERSION = '3.11.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Read and write a spreadsheet |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
2008
|
use Moose::Role; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
34
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'spreadsheet' => ( is => 'ro', isa => 'Str', required => 1 ); |
8
|
|
|
|
|
|
|
has '_fixed_headers' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__fixed_headers' ); |
9
|
|
|
|
|
|
|
has '_input_spreadsheet_fh' => ( is => 'ro', lazy => 1, builder => '_build__input_spreadsheet_fh' ); |
10
|
|
|
|
|
|
|
has '_output_spreadsheet_fh' => ( is => 'ro', lazy => 1, builder => '_build__output_spreadsheet_fh' ); |
11
|
|
|
|
|
|
|
has '_fixed_headers' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__fixed_headers' ); |
12
|
|
|
|
|
|
|
has '_num_fixed_headers' => ( is => 'ro', isa => 'Int', lazy => 1, builder => '_build__num_fixed_headers' ); |
13
|
|
|
|
|
|
|
has '_csv_parser' => ( is => 'ro', isa => 'Text::CSV',lazy => 1, builder => '_build__csv_parser' ); |
14
|
|
|
|
|
|
|
has '_csv_output' => ( is => 'ro', isa => 'Text::CSV',lazy => 1, builder => '_build__csv_output' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub BUILD |
17
|
|
|
|
|
|
|
{ |
18
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
19
|
0
|
|
|
|
|
0
|
$self->_input_spreadsheet_fh; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _build__fixed_headers |
23
|
|
|
|
|
|
|
{ |
24
|
18
|
|
|
18
|
|
40
|
my ($self) = @_; |
25
|
18
|
|
|
|
|
24
|
my @fixed_headers = @{Bio::Roary::GroupStatistics->fixed_headers()}; |
|
18
|
|
|
|
|
159
|
|
26
|
18
|
|
|
|
|
379
|
return \@fixed_headers; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _build__csv_parser |
30
|
|
|
|
|
|
|
{ |
31
|
18
|
|
|
18
|
|
37
|
my ($self) = @_; |
32
|
18
|
|
|
|
|
183
|
return Text::CSV->new( { binary => 1, always_quote => 1} ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _build__csv_output |
36
|
|
|
|
|
|
|
{ |
37
|
14
|
|
|
14
|
|
34
|
my ($self) = @_; |
38
|
14
|
|
|
|
|
157
|
return Text::CSV->new( { binary => 1, always_quote => 1, eol => "\r\n"} ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _build__input_spreadsheet_fh { |
42
|
18
|
|
|
18
|
|
34
|
my ($self) = @_; |
43
|
18
|
50
|
|
|
|
441
|
open( my $fh, $self->spreadsheet ) or die "Couldnt open input spreadsheet: ".$self->spreadsheet ; |
44
|
18
|
|
|
|
|
423
|
return $fh; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _build__output_spreadsheet_fh { |
48
|
14
|
|
|
14
|
|
25
|
my ($self) = @_; |
49
|
14
|
|
|
|
|
367
|
open( my $fh, '>', $self->output_filename ); |
50
|
14
|
|
|
|
|
384
|
return $fh; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _build__num_fixed_headers |
54
|
|
|
|
|
|
|
{ |
55
|
18
|
|
|
18
|
|
37
|
my ($self) = @_; |
56
|
18
|
|
|
|
|
23
|
return @{$self->_fixed_headers}; |
|
18
|
|
|
|
|
372
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Bio::Roary::SpreadsheetRole - Read and write a spreadsheet |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 3.11.0 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
with 'Bio::Roary::SpreadsheetRole'; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This is free software, licensed under: |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |