blib/lib/Bio/AutomatedAnnotation/CommandLine/GeneNameOccurances.pm untested

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 72 CC 6 SCAR 22.9
CC
6
Cov
0%
BUILD
20.0
run
12.0
usage_text
2.0
CRAP 9.8
1 package Bio::AutomatedAnnotation::CommandLine::GeneNameOccurances;
2  
3 # ABSTRACT: Create a spreadsheet with gene name occurances
4  
5  
6 use Moose;
7 use Getopt::Long qw(GetOptionsFromArray);
8 use Bio::AutomatedAnnotation::SpreadsheetOfGeneOccurances;
9 use Bio::AutomatedAnnotation::GeneNameOccurances;
10  
11 has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
12 has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 );
13 has 'help' => ( is => 'rw', isa => 'Bool', default => 0 );
14  
15 has 'gff_files' => ( is => 'rw', isa => 'ArrayRef' );
16 has 'output_filename' => ( is => 'rw', isa => 'Str' );
17  
18 has '_error_message' => ( is => 'rw', isa => 'Str' );
19  
20 sub BUILD {
21 my ($self) = @_;
22  
23 my ( $gff_files, $output_filename, $help );
24  
25 GetOptionsFromArray(
26 $self->args,
27 'o|output=s' => \$output_filename,
28 'h|help' => \$help,
29 );
30  
31 $self->output_filename($output_filename) if ( defined($output_filename) );
32  
33 if ( @{ $self->args } == 0 ) {
34 $self->_error_message("Error: You need to provide at least 1 GFF file");
35 }
36  
37 for my $filename ( @{ $self->args } ) {
38 if ( !-e $filename ) {
39 $self->_error_message("Error: Cant access file $filename");
40 last;
41 }
42 }
43 $self->gff_files( $self->args );
44  
45 }
46  
47 sub run {
48 my ($self) = @_;
49  
50 ( !$self->help ) or die $self->usage_text;
51 if ( defined( $self->_error_message ) ) {
52 print $self->_error_message . "\n";
53 die $self->usage_text;
54 }
55  
56 my $gene_name_occurances_obj = Bio::AutomatedAnnotation::GeneNameOccurances->new(gff_files => $self->gff_files);
57
58 my %input_params = (
59 gene_occurances => $gene_name_occurances_obj
60 );
61  
62 if ( defined( $self->output_filename ) ) {
63 $input_params{output_filename} = $self->output_filename;
64 }
65  
66 my $spreadsheet_obj = Bio::AutomatedAnnotation::SpreadsheetOfGeneOccurances->new(\%input_params);
67 $spreadsheet_obj->create_spreadsheet;
68
69 }
70  
71 sub usage_text {
72 my ($self) = @_;
73  
74 return <<USAGE;
75 Usage: gene_name_occurances [options]
76 Create a spreadsheet with gene name occurances
77  
78 # Create a spreadsheet with gene name occurances
79 gene_name_occurances *.gff
80
81 # Provide an output filename
82 gene_name_occurances -o outputfile.fa *.gff
83  
84 # This help message
85 gene_name_occurances -h
86  
87 USAGE
88 }
89  
90 __PACKAGE__->meta->make_immutable;
91 no Moose;
92 1;
93  
94 __END__
95  
96 =pod
97  
98 =encoding UTF-8
99  
100 =head1 NAME
101  
102 Bio::AutomatedAnnotation::CommandLine::GeneNameOccurances - Create a spreadsheet with gene name occurances
103  
104 =head1 VERSION
105  
106 version 1.182685
107  
108 =head1 SYNOPSIS
109  
110 Create a spreadsheet with gene name occurances
111  
112 =head1 AUTHOR
113  
114 Andrew J. Page <ap13@sanger.ac.uk>
115  
116 =head1 COPYRIGHT AND LICENSE
117  
118 This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
119  
120 This is free software, licensed under:
121  
122 The GNU General Public License, Version 3, June 2007
123  
124 =cut