blib/lib/Bio/AutomatedAnnotation/ParseGenesFromGFFs.pm untested

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 68 CC 4 SCAR 22.2
CC
4
Cov
0%
create_fasta_file
20.0
_build_output_file
2.0
_build__parser_objects
2.0
CRAP 9.2
1 package Bio::AutomatedAnnotation::ParseGenesFromGFFs;
2  
3 # ABSTRACT: Parse GFF files and efficiency extract the gene sequence.
4  
5  
6 use Moose;
7 use Bio::AutomatedAnnotation::ParseGenesFromGFF;
8 use Bio::SeqIO;
9  
10 has 'gff_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
11 has 'search_query' => ( is => 'ro', isa => 'Str', required => 1 );
12 has 'search_qualifiers' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
13 has 'codontable_id' => ( is => 'ro', isa => 'Int', default => 11 );
14 has 'amino_acids' => ( is => 'ro', isa => 'Bool', default => 0 );
15 has 'output_file' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_output_file' );
16 has 'output_base' => ( is => 'rw', isa => 'Str', default => 'output' );
17 has '_parser_objects' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__parser_objects' );
18  
19 has 'files_with_hits' => ( is => 'rw', isa => 'Int', default => 0 );
20 has 'files_without_hits' => ( is => 'rw', isa => 'Int', default => 0 );
21  
22 sub _build_output_file {
23 my ($self) = @_;
24 my $file_suffix = $self->search_query;
25 $file_suffix =~ s!\W!!gi;
26 return join( '.', ( $self->output_base, $file_suffix, 'fa' ) );
27 }
28  
29 sub _build__parser_objects {
30 my ($self) = @_;
31 my @parser_objects;
32 for my $gff_file ( @{ $self->gff_files } ) {
33 push(
34 @parser_objects,
35 Bio::AutomatedAnnotation::ParseGenesFromGFF->new(
36 gff_file => $gff_file,
37 search_query => $self->search_query,
38 search_qualifiers => $self->search_qualifiers
39 )
40 );
41 }
42 return \@parser_objects;
43 }
44  
45 sub create_fasta_file {
46 my ($self) = @_;
47  
48 my $output_fh = Bio::SeqIO->new(
49 -format => 'Fasta',
50 -file => ">" . $self->output_file
51 );
52 for my $parser_obj ( @{ $self->_parser_objects } ) {
53 if ( !defined( $parser_obj->_bio_seq_objects ) || @{ $parser_obj->_bio_seq_objects } == 0 )
54 {
55 $self->files_without_hits($self->files_without_hits() +1 );
56 next;
57 }
58 else
59 {
60 $self->files_with_hits($self->files_with_hits() +1);
61 }
62
63 for my $seq_obj ( @{ $parser_obj->_bio_seq_objects } ) {
64 next if ( !defined($seq_obj) );
65  
66 if ( $self->amino_acids ) {
67 $output_fh->write_seq( $seq_obj->translate( -codontable_id => $self->codontable_id ) );
68 }
69 else {
70 $output_fh->write_seq($seq_obj);
71 }
72 }
73 }
74 1;
75 }
76  
77 no Moose;
78 __PACKAGE__->meta->make_immutable;
79  
80 1;
81  
82 __END__
83  
84 =pod
85  
86 =encoding UTF-8
87  
88 =head1 NAME
89  
90 Bio::AutomatedAnnotation::ParseGenesFromGFFs - Parse GFF files and efficiency extract the gene sequence.
91  
92 =head1 VERSION
93  
94 version 1.182685
95  
96 =head1 SYNOPSIS
97  
98 Automated annotation of assemblies.
99 use Bio::AutomatedAnnotation::ParseGenesFromGFF;
100  
101 my $obj = Bio::AutomatedAnnotation::ParseGenesFromGFF->new(
102 gff_files => ['abc.gff','efg.gff'],
103 search_query => 'mecA'
104 );
105 $obj->annotate;
106  
107 =head1 AUTHOR
108  
109 Andrew J. Page <ap13@sanger.ac.uk>
110  
111 =head1 COPYRIGHT AND LICENSE
112  
113 This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
114  
115 This is free software, licensed under:
116  
117 The GNU General Public License, Version 3, June 2007
118  
119 =cut