File Coverage

lib/Bio/Roary/CommandLine/ExtractProteomeFromGff.pm
Criterion Covered Total %
statement 42 50 84.0
branch 15 24 62.5
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 65 85 76.4


line stmt bran cond sub pod time code
1             undef $VERSION;
2             package Bio::Roary::CommandLine::ExtractProteomeFromGff;
3             $Bio::Roary::CommandLine::ExtractProteomeFromGff::VERSION = '3.11.0';
4             # ABSTRACT: Take in GFF files and output the proteome
5              
6              
7 1     1   523743 use Moose;
  1         9  
  1         8  
8 1     1   7140 use Getopt::Long qw(GetOptionsFromArray);
  1         8481  
  1         5  
9 1     1   596 use Bio::Roary::ExtractProteomeFromGFF;
  1         5  
  1         99  
10 1     1   15 use File::Basename;
  1         2  
  1         604  
11             extends 'Bio::Roary::CommandLine::Common';
12              
13             has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
14             has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 );
15             has 'help' => ( is => 'rw', isa => 'Bool', default => 0 );
16              
17             has 'gff_files' => ( is => 'rw', isa => 'ArrayRef' );
18             has 'output_suffix' => ( is => 'rw', isa => 'Str', default => 'proteome.faa' );
19             has '_error_message' => ( is => 'rw', isa => 'Str' );
20             has 'apply_unknowns_filter' => ( is => 'rw', isa => 'Bool', default => 1 );
21             has 'translation_table' => ( is => 'rw', isa => 'Int', default => 11 );
22             has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
23             has 'output_directory' => ( is => 'rw', isa => 'Str', default => '.' );
24              
25             sub BUILD {
26 3     3 0 14 my ($self) = @_;
27              
28 3         17 my ( $gff_files, $output_suffix, $apply_unknowns_filter, $help, $translation_table, $verbose, $cmd_version, $output_directory );
29              
30 3         131 GetOptionsFromArray(
31             $self->args,
32             'o|output_suffix=s' => \$output_suffix,
33             'f|apply_unknowns_filter=i' => \$apply_unknowns_filter,
34             't|translation_table=i' => \$translation_table,
35             'v|verbose' => \$verbose,
36             'd|output_directory=s' => \$output_directory,
37             'w|version' => \$cmd_version,
38             'h|help' => \$help,
39             );
40            
41 3 50       2416 if ( defined($verbose) ) {
42 0         0 $self->verbose($verbose);
43 0         0 $self->logger->level(10000);
44             }
45            
46 3 100       46 $self->help($help) if(defined($help));
47 3 100       108 ( !$self->help ) or die $self->usage_text;
48            
49 2 50       11 $self->version($cmd_version) if ( defined($cmd_version) );
50 2 50       81 if ( $self->version ) {
51 0         0 die($self->_version());
52             }
53              
54 2 50       8 if ( @{ $self->args } == 0 ) {
  2         64  
55 0         0 $self->_error_message("Error: You need to provide a GFF file");
56             }
57              
58 2 50       10 $self->output_suffix($output_suffix) if ( defined($output_suffix) ) ;
59 2 50       9 $self->apply_unknowns_filter($apply_unknowns_filter) if ( defined($apply_unknowns_filter) );
60 2 100       38 $self->translation_table($translation_table) if ( defined($translation_table) );
61 2 50       7 $self->output_directory($output_directory) if ( defined($output_directory) );
62              
63 2         6 for my $filename ( @{ $self->args } ) {
  2         54  
64 2 50       86 if ( !-e $filename ) {
65 0         0 $self->_error_message("Error: Cant access file $filename");
66 0         0 last;
67             }
68             }
69 2         56 $self->gff_files( $self->args );
70              
71             }
72              
73             sub run {
74 2     2 0 6 my ($self) = @_;
75              
76 2 50       53 if ( defined( $self->_error_message ) ) {
77 0         0 print $self->_error_message . "\n";
78 0         0 die $self->usage_text;
79             }
80              
81 2         6 for my $gff_file ( @{ $self->gff_files } ) {
  2         45  
82 2         84 my ( $filename, $directories, $suffix ) = fileparse($gff_file);
83 2         61 my $obj = Bio::Roary::ExtractProteomeFromGFF->new(
84             gff_file => $gff_file,
85             output_filename => $filename . '.' . $self->output_suffix,
86             apply_unknowns_filter => $self->apply_unknowns_filter,
87             translation_table => $self->translation_table,
88             output_directory => $self->output_directory,
89             );
90 2         61 $obj->fasta_file();
91             }
92              
93             }
94              
95             sub usage_text {
96 1     1 0 4 my ($self) = @_;
97              
98 1         35 return <<USAGE;
99             Usage: extract_proteome_from_gff [options] *.gff
100             Take in GFF files and create FASTA files of the protein sequences
101              
102             Options: -o STR output suffix [proteome.faa]
103             -t INT translation table [11]
104             -f filter sequences with missing data
105             -v verbose output to STDOUT
106             -d STR output directory
107             -w print version and exit
108             -h this help message
109              
110             For further info see: http://sanger-pathogens.github.io/Roary/
111             USAGE
112             }
113              
114             __PACKAGE__->meta->make_immutable;
115 1     1   7 no Moose;
  1         2  
  1         10  
116             1;
117              
118             __END__
119              
120             =pod
121              
122             =encoding UTF-8
123              
124             =head1 NAME
125              
126             Bio::Roary::CommandLine::ExtractProteomeFromGff - Take in GFF files and output the proteome
127              
128             =head1 VERSION
129              
130             version 3.11.0
131              
132             =head1 SYNOPSIS
133              
134             Take in a GFF file and output the proteome
135              
136             =head1 AUTHOR
137              
138             Andrew J. Page <ap13@sanger.ac.uk>
139              
140             =head1 COPYRIGHT AND LICENSE
141              
142             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
143              
144             This is free software, licensed under:
145              
146             The GNU General Public License, Version 3, June 2007
147              
148             =cut