| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::Roary::Output::GroupMultifasta; |
|
2
|
|
|
|
|
|
|
$Bio::Roary::Output::GroupMultifasta::VERSION = '3.10.2'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Take in a group and create a multifasta file |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use Moose; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
13
|
|
|
7
|
2
|
|
|
2
|
|
12962
|
use Bio::SeqIO; |
|
|
2
|
|
|
|
|
105543
|
|
|
|
2
|
|
|
|
|
85
|
|
|
8
|
2
|
|
|
2
|
|
22
|
use Bio::Roary::Exceptions; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
55
|
|
|
9
|
2
|
|
|
2
|
|
15
|
use Bio::Roary::AnalyseGroups; |
|
|
2
|
|
|
|
|
27
|
|
|
|
2
|
|
|
|
|
784
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'group_name' => ( is => 'ro', isa => 'Str', required => 1 ); |
|
12
|
|
|
|
|
|
|
has 'analyse_groups' => ( is => 'ro', isa => 'Bio::Roary::AnalyseGroups', required => 1 ); |
|
13
|
|
|
|
|
|
|
has 'output_filename_base' => ( is => 'ro', isa => 'Str', default => 'output_groups' ); |
|
14
|
|
|
|
|
|
|
has '_genes' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__genes' ); |
|
15
|
|
|
|
|
|
|
has '_output_seq_io' => ( is => 'ro', lazy => 1, builder => '_build__output_seq_io' ); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build__output_seq_io { |
|
18
|
12
|
|
|
12
|
|
33
|
my ($self) = @_; |
|
19
|
12
|
|
|
|
|
362
|
my $output_name = $self->output_filename_base . '_' . $self->group_name; |
|
20
|
12
|
|
|
|
|
46
|
$output_name =~ s!\W!_!g; |
|
21
|
12
|
|
|
|
|
27
|
$output_name .= '.fa'; |
|
22
|
12
|
|
|
|
|
89
|
return Bio::SeqIO->new( -file => ">" . $output_name, -format => 'Fasta' ); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build__genes { |
|
26
|
12
|
|
|
12
|
|
27
|
my ($self) = @_; |
|
27
|
12
|
|
|
|
|
363
|
return $self->analyse_groups->_groups_to_genes->{ $self->group_name }; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _lookup_sequence { |
|
31
|
24
|
|
|
24
|
|
93
|
my ( $self, $gene, $filename ) = @_; |
|
32
|
24
|
50
|
|
|
|
59
|
return undef if(! defined($filename)); |
|
33
|
24
|
|
|
|
|
180
|
my $fasta_obj = Bio::SeqIO->new( -file => $filename, -format => 'Fasta' ); |
|
34
|
24
|
|
|
|
|
56020
|
while ( my $seq = $fasta_obj->next_seq() ) { |
|
35
|
66
|
100
|
|
|
|
14405
|
next unless ( $seq->display_id eq $gene ); |
|
36
|
24
|
|
|
|
|
488
|
return $seq; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
0
|
|
|
|
|
0
|
return undef; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub create_file { |
|
42
|
12
|
|
|
12
|
0
|
32
|
my ($self) = @_; |
|
43
|
12
|
|
|
|
|
29
|
for my $gene ( @{ $self->_genes } ) { |
|
|
12
|
|
|
|
|
404
|
|
|
44
|
24
|
|
|
|
|
4001
|
my $seq = $self->_lookup_sequence( $gene, $self->analyse_groups->_genes_to_file->{$gene} ); |
|
45
|
24
|
50
|
|
|
|
2245
|
next unless ( defined($seq) ); |
|
46
|
24
|
|
|
|
|
920
|
$self->_output_seq_io->write_seq($seq); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
12
|
|
|
|
|
3739
|
1; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
2
|
|
|
2
|
|
22
|
no Moose; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
26
|
|
|
53
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=encoding UTF-8 |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Bio::Roary::Output::GroupMultifasta - Take in a group and create a multifasta file |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 VERSION |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
version 3.10.2 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Take in a group and create a multifasta file |
|
74
|
|
|
|
|
|
|
use Bio::Roary::Output::GroupMultifasta; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $obj = Bio::Roary::Output::GroupMultifasta->new( |
|
77
|
|
|
|
|
|
|
group_name => 'aaa', |
|
78
|
|
|
|
|
|
|
analyse_groups => $analyse_groups, |
|
79
|
|
|
|
|
|
|
output_filename_base => 'abc' |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
$obj->create_file(); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This is free software, licensed under: |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |