line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::Output::CoreGeneAlignmentCoordinatesEMBL; |
2
|
|
|
|
|
|
|
$Bio::Roary::Output::CoreGeneAlignmentCoordinatesEMBL::VERSION = '3.10.1'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Create an embl file for the header with locations of where genes are in the multifasta alignment of core genes |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
150253
|
use Moose; |
|
2
|
|
|
|
|
462913
|
|
|
2
|
|
|
|
|
17
|
|
7
|
2
|
|
|
2
|
|
12363
|
use Bio::Roary::Exceptions; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
41
|
|
8
|
2
|
|
|
2
|
|
10
|
use File::Basename; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
956
|
|
9
|
|
|
|
|
|
|
with 'Bio::Roary::Output::EMBLHeaderCommon'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'output_filename' => ( is => 'ro', isa => 'Str', default => 'core_alignment_header.embl' ); |
12
|
|
|
|
|
|
|
has 'multifasta_files' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); |
13
|
|
|
|
|
|
|
has 'gene_lengths' => ( is => 'ro', isa => 'HashRef', required => 1 ); |
14
|
|
|
|
|
|
|
has '_current_coordinate' => ( is => 'rw', isa => 'Int', default => 1 ); |
15
|
|
|
|
|
|
|
has '_output_fh' => ( is => 'ro', lazy => 1, builder => '_build__output_fh' ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build__output_fh { |
18
|
3
|
|
|
3
|
|
7
|
my ($self) = @_; |
19
|
3
|
50
|
|
|
|
92
|
open( my $fh, '>', $self->output_filename ) |
20
|
|
|
|
|
|
|
or Bio::Roary::Exceptions::CouldntWriteToFile->throw( error => "Couldnt write output file:" . $self->output_filename ); |
21
|
3
|
|
|
|
|
90
|
return $fh; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _gene_name_from_filename { |
25
|
12
|
|
|
12
|
|
21
|
my ( $self, $filename ) = @_; |
26
|
12
|
|
|
|
|
341
|
my $gene_name = basename($filename); |
27
|
12
|
|
|
|
|
38
|
$gene_name =~ s!\.aln!!; |
28
|
12
|
|
|
|
|
28
|
$gene_name =~ s!\.fa!!; |
29
|
12
|
|
|
|
|
34
|
return $gene_name; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _header_block { |
33
|
8
|
|
|
8
|
|
17
|
my ( $self, $gene_filename ) = @_; |
34
|
8
|
|
|
|
|
14
|
my $gene_name = $self->_gene_name_from_filename($gene_filename); |
35
|
8
|
|
|
|
|
206
|
my $gene_length = $self->gene_lengths->{$gene_filename}; |
36
|
8
|
|
|
|
|
197
|
my $end_coordinate = $self->_current_coordinate + $gene_length - 1; |
37
|
8
|
|
|
|
|
23
|
my $annotation_type = $self->_annotation_type($gene_name); |
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
192
|
my $tab_file_entry = join( '', ( 'FT', $annotation_type, $self->_current_coordinate, '..', $end_coordinate, "\n" ) ); |
40
|
8
|
|
|
|
|
22
|
$tab_file_entry .= "FT /label=$gene_name\n"; |
41
|
8
|
|
|
|
|
14
|
$tab_file_entry .= "FT /locus_tag=$gene_name\n"; |
42
|
|
|
|
|
|
|
|
43
|
8
|
|
|
|
|
194
|
$self->_current_coordinate( $end_coordinate + 1 ); |
44
|
8
|
|
|
|
|
21
|
return $tab_file_entry; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub create_file { |
48
|
3
|
|
|
3
|
0
|
7
|
my ($self) = @_; |
49
|
3
|
|
|
|
|
6
|
print { $self->_output_fh } $self->_header_top; |
|
3
|
|
|
|
|
91
|
|
50
|
3
|
|
|
|
|
6
|
for my $filename ( @{ $self->multifasta_files } ) { |
|
3
|
|
|
|
|
84
|
|
51
|
8
|
|
|
|
|
12
|
print { $self->_output_fh } $self->_header_block($filename); |
|
8
|
|
|
|
|
189
|
|
52
|
|
|
|
|
|
|
} |
53
|
3
|
|
|
|
|
5
|
print { $self->_output_fh } $self->_header_bottom; |
|
3
|
|
|
|
|
71
|
|
54
|
3
|
|
|
|
|
71
|
close( $self->_output_fh ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
2
|
|
13
|
no Moose; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
21
|
|
58
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding UTF-8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Bio::Roary::Output::CoreGeneAlignmentCoordinatesEMBL - Create an embl file for the header with locations of where genes are in the multifasta alignment of core genes |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 3.10.1 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Create an embl file for the header with locations of where genes are in the multifasta alignment of core genes |
79
|
|
|
|
|
|
|
use Bio::Roary::Output::CoreGeneAlignmentCoordinatesEMBL; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $obj = Bio::Roary::Output::CoreGeneAlignmentCoordinatesEMBL->new( |
82
|
|
|
|
|
|
|
output_filename => 'core_alignment_header.embl', |
83
|
|
|
|
|
|
|
multifasta_files => [ |
84
|
|
|
|
|
|
|
't/data/multifasta_files/1.aln', 't/data/multifasta_files/outof_order.aln', |
85
|
|
|
|
|
|
|
't/data/multifasta_files/2.aln', 't/data/multifasta_files/3.aln' |
86
|
|
|
|
|
|
|
], |
87
|
|
|
|
|
|
|
gene_lengths => { |
88
|
|
|
|
|
|
|
't/data/multifasta_files/1.aln' => 1, |
89
|
|
|
|
|
|
|
't/data/multifasta_files/outof_order.aln' => 10, |
90
|
|
|
|
|
|
|
't/data/multifasta_files/2.aln' => 100, |
91
|
|
|
|
|
|
|
't/data/multifasta_files/3.aln' => 1000 |
92
|
|
|
|
|
|
|
}, |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
$obj->create_file; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This is free software, licensed under: |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |