blib/lib/Bio/Roary/CommandLine/AssemblyStatistics.pm untested

filter: Statementstmt 0.0% 0 / 63 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 102 CC 13 SCAR 45.5
CC
13
Cov
0%
BUILD
156.0
_version
6.0
run
2.0
CRAP 94.8
1 undef $VERSION;
2 package Bio::Roary::CommandLine::AssemblyStatistics;
3 $Bio::Roary::CommandLine::AssemblyStatistics::VERSION = '3.13.0';
4 # ABSTRACT: Given a spreadsheet of gene presence and absence calculate some statistics
5  
6  
7 use Moose;
8 use Getopt::Long qw(GetOptionsFromArray);
9 use Bio::Roary::AssemblyStatistics;
10 extends 'Bio::Roary::CommandLine::Common';
11  
12 has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
13 has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 );
14 has 'help' => ( is => 'rw', isa => 'Bool', default => 0 );
15 has 'spreadsheet' => ( is => 'rw', isa => 'Str', default => 'gene_presence_absence.csv' );
16 has 'job_runner' => ( is => 'rw', isa => 'Str', default => 'Local' );
17 has 'cpus' => ( is => 'rw', isa => 'Int', default => 1 );
18 has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'assembly_statistics.csv' );
19 has 'version' => ( is => 'rw', isa => 'Bool', default => 0 );
20 has 'core_definition' => ( is => 'rw', isa => 'Num', default => 0.99 );
21 has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
22  
23  
24 sub BUILD {
25 my ($self) = @_;
26  
27 my (
28 $spreadsheet,
29 $job_runner,
30 $cpus,
31 $output_filename,
32 $version,
33 $core_definition,
34 $verbose,
35 $help
36 );
37  
38 GetOptionsFromArray(
39 $self->args,
40 'o|output_filename=s' => \$output_filename,
41 'j|job_runner=s' => \$job_runner,
42 'p|processors=i' => \$cpus,
43 'cd|core_definition=f' => \$core_definition,
44 'v|verbose' => \$verbose,
45 'w|version' => \$version,
46 'h|help' => \$help,
47 );
48  
49 $self->version($version) if ( defined($version) );
50 if ( $self->version ) {
51 die($self->_version());
52 }
53  
54 if ( defined($verbose) ) {
55 $self->verbose($verbose);
56 $self->logger->level(10000);
57 }
58  
59 $self->help($help) if ( defined($help) );
60 ( !$self->help ) or die $self->usage_text;
61 if(@{$self->args} == 0)
62 {
63 $self->logger->error("Error: You need to provide a gene_presence_absence.csv spreadsheet");
64 die $self->usage_text;
65 }
66 $self->output_filename($output_filename) if ( defined($output_filename) );
67 $self->job_runner($job_runner) if ( defined($job_runner) );
68 $self->cpus($cpus) if ( defined($cpus) );
69  
70 if ( $self->cpus > 1 ) {
71 $self->job_runner('Parallel');
72 }
73  
74 $self->core_definition( $core_definition / 100 ) if ( defined($core_definition) );
75  
76 for my $filename ( @{ $self->args } ) {
77 if ( !-e $filename ) {
78 $self->logger->error("Error: Cant access file $filename");
79 die $self->usage_text;
80 }
81 }
82 $self->spreadsheet( $self->args->[0] );
83  
84 }
85  
86 sub _version
87 {
88 my ($self) = @_;
89 if(defined($Bio::Roary::CommandLine::AssemblyStatistics::VERSION))
90 {
91 return $Bio::Roary::CommandLine::AssemblyStatistics::VERSION ."\n";
92 }
93 else
94 {
95 return "x.y.z\n";
96 }
97 }
98  
99 sub run {
100 my ($self) = @_;
101  
102 my $obj = Bio::Roary::AssemblyStatistics->new( spreadsheet => $self->spreadsheet, logger => $self->logger );
103 $obj->create_summary_output;
104 }
105  
106 sub usage_text {
107 my ($self) = @_;
108  
109 return <<USAGE;
110 Usage: pan_genome_assembly_statistics [options] gene_presence_absence.csv
111 Take in a gene presence and absence spreadsheet and output some statistics
112
113 Options: -p INT number of threads [1]
114 -o STR output filename [assembly_statistics.csv]
115 -cd FLOAT percentage of isolates a gene must be in to be core [99]
116 -v verbose output to STDOUT
117 -w print version and exit
118 -h this help message
119
120 Example: Run with defaults
121 pan_genome_assembly_statistics gene_presence_absence.csv
122  
123 For further information see: http://sanger-pathogens.github.io/Roary/
124 USAGE
125 }
126  
127 __PACKAGE__->meta->make_immutable;
128 no Moose;
129 1;
130  
131 __END__