File Coverage

lib/Bio/MLST/Spreadsheet/File.pm
Criterion Covered Total %
statement 12 28 42.8
branch n/a
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 34 50.0


line stmt bran cond sub pod time code
1             package Bio::MLST::Spreadsheet::File;
2             # ABSTRACT: Create a file representation of the ST results for multiple fasta files.
3             $Bio::MLST::Spreadsheet::File::VERSION = '2.1.1630910';
4              
5 10     10   53 use Moose;
  10         17  
  10         86  
6 10     10   64970 use Text::CSV;
  10         22  
  10         114  
7 10     10   252 use Bio::MLST::Spreadsheet::Row;
  10         19  
  10         3647  
8              
9             has 'spreadsheet_allele_numbers_rows' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
10             has 'spreadsheet_genomic_rows' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
11             has 'output_directory' => ( is => 'ro', isa => 'Str', required => 1 );
12             has 'spreadsheet_basename' => ( is => 'ro', isa => 'Str', required => 1 );
13              
14             has 'header' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
15              
16             sub create
17             {
18 0     0 1   my($self) = @_;
19 0           my $base_spreadsheet_name = join('/',($self->output_directory, $self->spreadsheet_basename));
20            
21 0           open(my $allele_fh,'+>', $base_spreadsheet_name.".allele.csv");
22 0           open(my $genomic_fh,'+>', $base_spreadsheet_name.".genomic.csv");
23            
24 0           my $allele_csv = Text::CSV->new({sep_char=>"\t", always_quote=>1, eol=>"\r\n"});
25 0           my $genomic_csv = Text::CSV->new({sep_char=>"\t", always_quote=>1, eol=>"\r\n"});
26            
27 0           $allele_csv->print ($allele_fh, $_) for $self->header;
28 0           $genomic_csv->print ($genomic_fh, $_) for $self->header;
29            
30 0           for my $row (@{$self->spreadsheet_allele_numbers_rows})
  0            
31             {
32 0           $allele_csv->print ($allele_fh, $_) for $row;
33             }
34 0           for my $row (@{$self->spreadsheet_genomic_rows})
  0            
35             {
36 0           $genomic_csv->print ($genomic_fh, $_) for $row;
37             }
38 0           close($allele_fh);
39 0           close($genomic_fh);
40             }
41              
42              
43 10     10   60 no Moose;
  10         18  
  10         60  
44             __PACKAGE__->meta->make_immutable;
45             1;
46              
47             __END__
48              
49             =pod
50              
51             =encoding UTF-8
52              
53             =head1 NAME
54              
55             Bio::MLST::Spreadsheet::File - Create a file representation of the ST results for multiple fasta files.
56              
57             =head1 VERSION
58              
59             version 2.1.1630910
60              
61             =head1 SYNOPSIS
62              
63             Create a file representation of the ST results for multiple fasta files.
64              
65             use Bio::MLST::Spreadsheet::File;
66             my $spreadsheet = Bio::MLST::Spreadsheet::File->new(
67             spreadsheet_rows => [],
68             output_directory => '/path/to/outputdir',
69             spreadsheet_basename => 'abc'
70             );
71            
72             $spreadsheet->create();
73              
74             =head1 METHODS
75              
76             =head2 create
77              
78             Create a spreadsheet file of results.
79              
80             =head1 SEE ALSO
81              
82             =over 4
83              
84             =item *
85              
86             L<Bio::MLST::Spreadsheet::Row>
87              
88             =back
89              
90             =head1 AUTHOR
91              
92             Andrew J. Page <ap13@sanger.ac.uk>
93              
94             =head1 COPYRIGHT AND LICENSE
95              
96             This software is Copyright (c) 2012 by Wellcome Trust Sanger Institute.
97              
98             This is free software, licensed under:
99              
100             The GNU General Public License, Version 3, June 2007
101              
102             =cut