File Coverage

lib/Bio/Roary/CommandLine/TransferAnnotationToGroups.pm
Criterion Covered Total %
statement 33 41 80.4
branch 10 16 62.5
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 3 0.0
total 51 70 72.8


line stmt bran cond sub pod time code
1             undef $VERSION;
2             package Bio::Roary::CommandLine::TransferAnnotationToGroups;
3             $Bio::Roary::CommandLine::TransferAnnotationToGroups::VERSION = '3.11.0';
4             # ABSTRACT: Take in a groups file and a set of GFF files and transfer the consensus annotation
5              
6              
7 1     1   507603 use Moose;
  1         8  
  1         7  
8 1     1   6611 use Getopt::Long qw(GetOptionsFromArray);
  1         7807  
  1         4  
9 1     1   545 use Bio::Roary::AnnotateGroups;
  1         6  
  1         407  
10             extends 'Bio::Roary::CommandLine::Common';
11              
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 'groups_filename' => ( is => 'rw', isa => 'Str' );
19             has 'output_filename' => ( is => 'rw', isa => 'Str', default => 'reannotated_groups' );
20             has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
21             has '_error_message' => ( is => 'rw', isa => 'Str' );
22              
23             sub BUILD {
24 2     2 0 7 my ($self) = @_;
25              
26 2         4 my ( $gff_files, $output_filename, $groups_filename, @group_names, $action,$verbose, $help );
27              
28 2         92 GetOptionsFromArray(
29             $self->args,
30             'o|output=s' => \$output_filename,
31             'g|groups_filename=s' => \$groups_filename,
32             'v|verbose' => \$verbose,
33             'h|help' => \$help,
34             );
35            
36 2 50       1455 if ( defined($verbose) ) {
37 0         0 $self->verbose($verbose);
38 0         0 $self->logger->level(10000);
39             }
40            
41 2 100       51 $self->help($help) if(defined($help));
42 2 100       92 ( !$self->help ) or die $self->usage_text;
43            
44 1 50       5 if ( @{ $self->args } == 0 ) {
  1         33  
45 0         0 $self->_error_message("Error: You need to provide a FASTA file");
46             }
47              
48 1 50       8 $self->output_filename($output_filename) if ( defined($output_filename) );
49 1 50 33     39 if ( defined($groups_filename) && ( -e $groups_filename ) ) {
50 1         60 $self->groups_filename($groups_filename);
51             }
52             else {
53 0         0 $self->_error_message("Error: Cant access the groups file");
54             }
55              
56 1         4 for my $filename ( @{ $self->args } ) {
  1         48  
57 3 50       29 if ( !-e $filename ) {
58 0         0 $self->_error_message("Error: Cant access file $filename");
59 0         0 last;
60             }
61             }
62 1         30 $self->gff_files( $self->args );
63              
64             }
65              
66             sub run {
67 1     1 0 3 my ($self) = @_;
68              
69            
70 1 50       30 if ( defined( $self->_error_message ) ) {
71 0         0 print $self->_error_message . "\n";
72 0         0 die $self->usage_text;
73             }
74              
75            
76 1         30 my $obj = Bio::Roary::AnnotateGroups->new(
77             gff_files => $self->gff_files,
78             output_filename => $self->output_filename,
79             groups_filename => $self->groups_filename,
80             );
81 1         7 $obj->reannotate;
82              
83             }
84              
85             sub usage_text {
86 1     1 0 8 my ($self) = @_;
87              
88 1         57 return <<USAGE;
89             Usage: transfer_annotation_to_groups [options] *.gff
90             Take in a groups file and the protein fasta files and output selected data
91              
92             Options: -o STR output filename [reannotated_groups]
93             -g STR clusters filename [clustered_proteins]
94             -v verbose output to STDOUT
95             -h this help message
96              
97             For further info see: http://sanger-pathogens.github.io/Roary/
98             USAGE
99             }
100              
101             __PACKAGE__->meta->make_immutable;
102 1     1   9 no Moose;
  1         2  
  1         7  
103             1;
104              
105             __END__
106              
107             =pod
108              
109             =encoding UTF-8
110              
111             =head1 NAME
112              
113             Bio::Roary::CommandLine::TransferAnnotationToGroups - Take in a groups file and a set of GFF files and transfer the consensus annotation
114              
115             =head1 VERSION
116              
117             version 3.11.0
118              
119             =head1 SYNOPSIS
120              
121             Take in a groups file and a set of GFF files and transfer the consensus annotation
122              
123             =head1 AUTHOR
124              
125             Andrew J. Page <ap13@sanger.ac.uk>
126              
127             =head1 COPYRIGHT AND LICENSE
128              
129             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
130              
131             This is free software, licensed under:
132              
133             The GNU General Public License, Version 3, June 2007
134              
135             =cut