File Coverage

lib/Bio/Roary/Output/BlastIdentityFrequency.pm
Criterion Covered Total %
statement 12 26 46.1
branch 0 4 0.0
condition n/a
subroutine 4 7 57.1
pod 0 1 0.0
total 16 38 42.1


line stmt bran cond sub pod time code
1             package Bio::Roary::Output::BlastIdentityFrequency;
2             $Bio::Roary::Output::BlastIdentityFrequency::VERSION = '3.10.2';
3             # ABSTRACT: Take in blast results and find the percentage identity graph
4              
5              
6 1     1   7 use Moose;
  1         2  
  1         8  
7 1     1   6007 use Bio::SeqIO;
  1         2  
  1         21  
8 1     1   4 use Bio::Roary::Exceptions;
  1         1  
  1         236  
9              
10             has 'input_filename' => ( is => 'ro', isa => 'Str', default => '_blast_results' );
11             has 'output_filename' => ( is => 'ro', isa => 'Str', default => 'blast_identity_frequency.Rtab' );
12              
13             has '_output_fh' => ( is => 'ro', lazy => 1, builder => '_build__output_fh' );
14             has '_input_fh' => ( is => 'ro', lazy => 1, builder => '_build__input_fh' );
15              
16             sub _build__output_fh
17             {
18 0     0     my ($self) = @_;
19 0 0         open( my $fh, '>', $self->output_filename )
20             or Bio::Roary::Exceptions::CouldntWriteToFile->throw(
21             error => "Couldnt write output file:" . $self->output_filename );
22 0           return $fh;
23             }
24              
25             sub _build__input_fh
26             {
27 0     0     my ($self) = @_;
28 0           my $input_string = 'awk \'{print $3}\' '.$self->input_filename.' | awk \'BEGIN {FS="."}; {print $1}\'| sort | uniq -c | awk \'{print $2"\t"$1}\'';
29            
30 0 0         open( my $fh, '-|', $input_string ) or die "Couldnt open results file";
31 0           return $fh;
32             }
33              
34             sub create_file
35             {
36 0     0 0   my ($self) = @_;
37            
38 0           my $input_fh = $self->_input_fh;
39 0           while(<$input_fh>)
40             {
41 0           print {$self->_output_fh} $_;
  0            
42             }
43 0           close($self->_input_fh);
44 0           close($self->_output_fh);
45             }
46              
47 1     1   6 no Moose;
  1         2  
  1         5  
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::Output::BlastIdentityFrequency - Take in blast results and find the percentage identity graph
61              
62             =head1 VERSION
63              
64             version 3.10.2
65              
66             =head1 SYNOPSIS
67              
68             Take in blast results and find the percentage identity graph
69             use Bio::Roary::Output::BlastIdentityFrequency;
70              
71             my $obj = Bio::Roary::Output::BlastIdentityFrequency->new(
72             input_filename => '_blast_results',
73             output_filename => 'blast_identity_frequency.Rtab',
74             );
75             $obj->create_file();
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