blib/lib/Bio/AutomatedAnnotation.pm untested

filter: Statementstmt 0.0% 0 / 61 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 83 CC 4 SCAR 15.5
CC
4
Cov
0%
annotate
12.0
_contig_uniq_id
6.0
_build__temp_directory_obj
2.0
CRAP 4.7
1 package Bio::AutomatedAnnotation;
2  
3 # ABSTRACT: Automated annotation of assemblies
4  
5  
6 use Moose;
7 use File::Basename;
8 use Cwd;
9 use File::Temp;
10 use Bio::AutomatedAnnotation::Prokka;
11  
12 has 'sample_name' => ( is => 'ro', isa => 'Str', required => 1 );
13 has 'dbdir' => ( is => 'ro', isa => 'Str', required => 1 );
14 has 'assembly_file' => ( is => 'ro', isa => 'Str', required => 1 );
15 has 'annotation_tool' => ( is => 'ro', isa => 'Str', default => 'Prokka' );
16 has 'outdir' => ( is => 'ro', isa => 'Str', default => 'annotation' );
17 has 'tmp_directory' => ( is => 'ro', isa => 'Str', default => '/tmp' );
18 has 'sequencing_centre' => ( is => 'ro', isa => 'Str', default => 'SC' );
19 has 'genus' => ( is => 'ro', isa => 'Maybe[Str]' );
20 has 'accession_number' => ( is => 'ro', isa => 'Maybe[Str]' );
21 has 'kingdom' => ( is => 'ro', isa => 'Maybe[Str]' );
22 has 'cpus' => ( is => 'ro', isa => 'Int', default => 1 );
23 has 'gcode' => ( is => 'ro', isa => 'Int', default => 11 );
24 has 'keep_original_order_and_names' => ( is => 'ro', isa => 'Bool', default => 0 );
25  
26 has '_annotation_pipeline_class' =>
27 ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build__annotation_pipeline_class' );
28 has '_temp_directory_obj' => ( is => 'ro', isa => 'File::Temp::Dir', lazy => 1, builder => '_build__temp_directory_obj' );
29 has '_temp_directory_name' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build__temp_directory_name' );
30  
31 sub _build__temp_directory_obj {
32 my ($self) = @_;
33 return File::Temp->newdir( DIR => $self->tmp_directory, CLEANUP => 1 );
34 }
35  
36 sub _build__temp_directory_name {
37 my ($self) = @_;
38 return $self->_temp_directory_obj->dirname();
39 }
40  
41 sub _contig_uniq_id {
42 my ($self) = @_;
43 if ( defined( $self->accession_number ) ) {
44 return $self->accession_number;
45 }
46 else {
47 return $self->sample_name;
48 }
49 }
50  
51 sub _build__annotation_pipeline_class {
52 my ($self) = @_;
53 my $annotation_pipeline_class = "Bio::AutomatedAnnotation::" . $self->annotation_tool;
54 eval "require $annotation_pipeline_class";
55 return $annotation_pipeline_class;
56 }
57  
58 sub annotate {
59 my ($self) = @_;
60  
61 # Run the annotation in the directory containing the assembly
62 my $original_cwd = getcwd();
63 my ( $filename, $directories, $suffix ) = fileparse( $self->assembly_file );
64 chdir($directories);
65  
66 my $annotation_pipeline = $self->_annotation_pipeline_class->new(
67 assembly_file => $self->assembly_file,
68 tempdir => $self->_temp_directory_name,
69 centre => $self->sequencing_centre,
70 dbdir => $self->dbdir,
71 prefix => $self->sample_name,
72 locustag => $self->sample_name,
73 outdir => $self->outdir,
74 force => 1,
75 contig_uniq_id => $self->_contig_uniq_id,
76 cleanup_prod => 0,
77 cpus => $self->cpus,
78 rfam => 1,
79 gcode => $self->gcode,
80 keep_original_order_and_names => $self->keep_original_order_and_names,
81 );
82  
83 if ( defined( $self->genus ) ) {
84 $annotation_pipeline->genus( $self->genus );
85 $annotation_pipeline->usegenus(1);
86 }
87
88 if(defined($self->kingdom))
89 {
90 $annotation_pipeline->kingdom( $self->kingdom );
91 }
92  
93 $annotation_pipeline->annotate;
94  
95 chdir($original_cwd);
96 return $self;
97 }
98  
99 no Moose;
100 __PACKAGE__->meta->make_immutable;
101  
102 1;
103  
104 __END__
105  
106 =pod
107  
108 =encoding UTF-8
109  
110 =head1 NAME
111  
112 Bio::AutomatedAnnotation - Automated annotation of assemblies
113  
114 =head1 VERSION
115  
116 version 1.182680
117  
118 =head1 SYNOPSIS
119  
120 Automated annotation of assemblies.
121 use Bio::AutomatedAnnotation;
122  
123 my $obj = Bio::AutomatedAnnotation->new(
124 assembly_file => $assembly_file,
125 annotation_tool => $annotation_tool,
126 sample_name => $lane_name,
127 accession_number => $accession,
128 dbdir => $dbdir,
129 tmp_directory => $tmp_directory
130 );
131 $obj->annotate;
132  
133 =head1 AUTHOR
134  
135 Andrew J. Page <ap13@sanger.ac.uk>
136  
137 =head1 COPYRIGHT AND LICENSE
138  
139 This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
140  
141 This is free software, licensed under:
142  
143 The GNU General Public License, Version 3, June 2007
144  
145 =cut