line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::Output::DifferenceBetweenSets; |
2
|
|
|
|
|
|
|
$Bio::Roary::Output::DifferenceBetweenSets::VERSION = '3.11.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Given two sets of isolates and a group file, output whats unique in each and whats in common |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
447244
|
use Moose; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
13
|
|
7
|
2
|
|
|
2
|
|
12277
|
use Bio::SeqIO; |
|
2
|
|
|
|
|
50507
|
|
|
2
|
|
|
|
|
50
|
|
8
|
2
|
|
|
2
|
|
239
|
use Bio::Roary::Exceptions; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
39
|
|
9
|
2
|
|
|
2
|
|
214
|
use Bio::Roary::AnalyseGroups; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
10
|
2
|
|
|
2
|
|
421
|
use Bio::Roary::Output::QueryGroups; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
910
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'analyse_groups' => ( is => 'ro', isa => 'Bio::Roary::AnalyseGroups', required => 1 ); |
13
|
|
|
|
|
|
|
has 'input_filenames_sets' => ( is => 'ro', isa => 'ArrayRef[ArrayRef]', required => 1 ); |
14
|
|
|
|
|
|
|
has 'output_filename_base' => ( is => 'ro', isa => 'Str', default => 'set_difference' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has '_query_groups_objs' => ( is => 'ro', isa => 'ArrayRef', lazy => 1, builder => '_build__query_groups_objs' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# TODO: update to handle more than 2 input sets |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _build__query_groups_objs { |
21
|
8
|
|
|
8
|
|
32
|
my ($self) = @_; |
22
|
8
|
|
|
|
|
20
|
my @query_groups_objs; |
23
|
8
|
|
|
|
|
25
|
for my $file_name_set ( @{ $self->input_filenames_sets } ) { |
|
8
|
|
|
|
|
255
|
|
24
|
16
|
|
|
|
|
537
|
push( |
25
|
|
|
|
|
|
|
@query_groups_objs, |
26
|
|
|
|
|
|
|
Bio::Roary::Output::QueryGroups->new( |
27
|
|
|
|
|
|
|
analyse_groups => $self->analyse_groups, |
28
|
|
|
|
|
|
|
input_filenames => $file_name_set |
29
|
|
|
|
|
|
|
) |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
8
|
|
|
|
|
23
|
my @all_input_files = (@{ $self->input_filenames_sets->[0] },@{ $self->input_filenames_sets->[1] }); |
|
8
|
|
|
|
|
285
|
|
|
8
|
|
|
|
|
227
|
|
34
|
8
|
|
|
|
|
204
|
push( |
35
|
|
|
|
|
|
|
@query_groups_objs, |
36
|
|
|
|
|
|
|
Bio::Roary::Output::QueryGroups->new( |
37
|
|
|
|
|
|
|
analyse_groups => $self->analyse_groups, |
38
|
|
|
|
|
|
|
input_filenames => \@all_input_files |
39
|
|
|
|
|
|
|
) |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
8
|
|
|
|
|
261
|
return \@query_groups_objs; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _subtract_arrays { |
47
|
48
|
|
|
48
|
|
116
|
my ( $self, $array_1, $array_2 ) = @_; |
48
|
48
|
|
|
|
|
70
|
my %array_1 = map { $_ => 1 } @{$array_1}; |
|
168
|
|
|
|
|
357
|
|
|
48
|
|
|
|
|
119
|
|
49
|
48
|
|
|
|
|
85
|
my @difference = grep { not $array_1{$_} } @{$array_2}; |
|
217
|
|
|
|
|
435
|
|
|
48
|
|
|
|
|
86
|
|
50
|
48
|
|
|
|
|
151
|
return \@difference; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _groups_unique { |
54
|
16
|
|
|
16
|
|
55
|
my ( $self, $output_filename, $query_group1, $query_group2 ) = @_; |
55
|
16
|
|
|
|
|
424
|
my $unique_groups = $self->_subtract_arrays( $query_group2->_groups, $query_group1->_groups ); |
56
|
16
|
|
|
|
|
95
|
$query_group1->groups_with_external_inputs( $output_filename, $unique_groups ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub groups_set_one_unique_filename |
60
|
|
|
|
|
|
|
{ |
61
|
15
|
|
|
15
|
0
|
47
|
my ($self) = @_; |
62
|
15
|
|
|
|
|
537
|
return $self->output_filename_base . '_unique_set_one'; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub groups_set_two_unique_filename |
66
|
|
|
|
|
|
|
{ |
67
|
15
|
|
|
15
|
0
|
32
|
my ($self) = @_; |
68
|
15
|
|
|
|
|
477
|
return $self->output_filename_base . '_unique_set_two'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub groups_in_common_filename |
72
|
|
|
|
|
|
|
{ |
73
|
15
|
|
|
15
|
0
|
38
|
my ($self) = @_; |
74
|
15
|
|
|
|
|
391
|
return $self->output_filename_base . '_common_set'; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub groups_set_one_unique { |
79
|
8
|
|
|
8
|
0
|
25
|
my ($self) = @_; |
80
|
8
|
|
|
|
|
62
|
$self->_groups_unique( |
81
|
|
|
|
|
|
|
$self->groups_set_one_unique_filename, |
82
|
|
|
|
|
|
|
$self->_query_groups_objs->[0], |
83
|
|
|
|
|
|
|
$self->_query_groups_objs->[1] |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub groups_set_two_unique { |
88
|
8
|
|
|
8
|
0
|
27
|
my ($self) = @_; |
89
|
8
|
|
|
|
|
38
|
$self->_groups_unique( |
90
|
|
|
|
|
|
|
$self->groups_set_two_unique_filename, |
91
|
|
|
|
|
|
|
$self->_query_groups_objs->[1], |
92
|
|
|
|
|
|
|
$self->_query_groups_objs->[0] |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub groups_in_common { |
97
|
8
|
|
|
8
|
0
|
39
|
my ($self) = @_; |
98
|
8
|
|
|
|
|
271
|
my $unique_group_1 = $self->_subtract_arrays( $self->_query_groups_objs->[0]->_groups, $self->_query_groups_objs->[1]->_groups ); |
99
|
8
|
|
|
|
|
238
|
my $unique_group_2 = $self->_subtract_arrays( $self->_query_groups_objs->[1]->_groups, $self->_query_groups_objs->[0]->_groups ); |
100
|
8
|
|
|
|
|
205
|
my $common_groups_1 = $self->_subtract_arrays( $unique_group_1,$self->_query_groups_objs->[2]->_groups); |
101
|
8
|
|
|
|
|
34
|
my $common_groups_2 = $self->_subtract_arrays( $unique_group_2,$common_groups_1); |
102
|
8
|
|
|
|
|
269
|
$self->_query_groups_objs->[2]->groups_with_external_inputs( $self->groups_in_common_filename, $common_groups_2 ); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
2
|
|
|
2
|
|
13
|
no Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
12
|
|
106
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=pod |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=encoding UTF-8 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 NAME |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Bio::Roary::Output::DifferenceBetweenSets - Given two sets of isolates and a group file, output whats unique in each and whats in common |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 VERSION |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
version 3.11.0 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SYNOPSIS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Given two sets of isolates and a group file, output whats unique in each and whats in common |
127
|
|
|
|
|
|
|
use Bio::Roary::Output::DifferenceBetweenSets; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $obj = Bio::Roary::Output::DifferenceBetweenSets->new( |
130
|
|
|
|
|
|
|
analyse_groups => $analyse_groups, |
131
|
|
|
|
|
|
|
input_filenames_sets => |
132
|
|
|
|
|
|
|
[ |
133
|
|
|
|
|
|
|
['aaa.faa','bbb.faa'], |
134
|
|
|
|
|
|
|
['ccc.faa','ddd.faa'] |
135
|
|
|
|
|
|
|
], |
136
|
|
|
|
|
|
|
); |
137
|
|
|
|
|
|
|
$obj->groups_set_one_unique(); |
138
|
|
|
|
|
|
|
$obj->groups_set_two_unique(); |
139
|
|
|
|
|
|
|
$obj->groups_in_common(); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This is free software, licensed under: |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |