line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Roary::Output::DifferenceBetweenSets; |
2
|
|
|
|
|
|
|
$Bio::Roary::Output::DifferenceBetweenSets::VERSION = '3.10.2'; |
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
|
|
438975
|
use Moose; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
12247
|
use Bio::SeqIO; |
|
2
|
|
|
|
|
49735
|
|
|
2
|
|
|
|
|
52
|
|
8
|
2
|
|
|
2
|
|
242
|
use Bio::Roary::Exceptions; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
44
|
|
9
|
2
|
|
|
2
|
|
229
|
use Bio::Roary::AnalyseGroups; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
57
|
|
10
|
2
|
|
|
2
|
|
431
|
use Bio::Roary::Output::QueryGroups; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
998
|
|
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
|
|
26
|
my ($self) = @_; |
22
|
8
|
|
|
|
|
17
|
my @query_groups_objs; |
23
|
8
|
|
|
|
|
20
|
for my $file_name_set ( @{ $self->input_filenames_sets } ) { |
|
8
|
|
|
|
|
275
|
|
24
|
16
|
|
|
|
|
526
|
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
|
|
|
|
|
19
|
my @all_input_files = (@{ $self->input_filenames_sets->[0] },@{ $self->input_filenames_sets->[1] }); |
|
8
|
|
|
|
|
263
|
|
|
8
|
|
|
|
|
228
|
|
34
|
8
|
|
|
|
|
242
|
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
|
|
|
|
|
300
|
return \@query_groups_objs; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _subtract_arrays { |
47
|
48
|
|
|
48
|
|
122
|
my ( $self, $array_1, $array_2 ) = @_; |
48
|
48
|
|
|
|
|
83
|
my %array_1 = map { $_ => 1 } @{$array_1}; |
|
168
|
|
|
|
|
385
|
|
|
48
|
|
|
|
|
119
|
|
49
|
48
|
|
|
|
|
98
|
my @difference = grep { not $array_1{$_} } @{$array_2}; |
|
217
|
|
|
|
|
468
|
|
|
48
|
|
|
|
|
87
|
|
50
|
48
|
|
|
|
|
172
|
return \@difference; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _groups_unique { |
54
|
16
|
|
|
16
|
|
68
|
my ( $self, $output_filename, $query_group1, $query_group2 ) = @_; |
55
|
16
|
|
|
|
|
453
|
my $unique_groups = $self->_subtract_arrays( $query_group2->_groups, $query_group1->_groups ); |
56
|
16
|
|
|
|
|
86
|
$query_group1->groups_with_external_inputs( $output_filename, $unique_groups ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub groups_set_one_unique_filename |
60
|
|
|
|
|
|
|
{ |
61
|
15
|
|
|
15
|
0
|
48
|
my ($self) = @_; |
62
|
15
|
|
|
|
|
682
|
return $self->output_filename_base . '_unique_set_one'; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub groups_set_two_unique_filename |
66
|
|
|
|
|
|
|
{ |
67
|
15
|
|
|
15
|
0
|
40
|
my ($self) = @_; |
68
|
15
|
|
|
|
|
492
|
return $self->output_filename_base . '_unique_set_two'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub groups_in_common_filename |
72
|
|
|
|
|
|
|
{ |
73
|
15
|
|
|
15
|
0
|
37
|
my ($self) = @_; |
74
|
15
|
|
|
|
|
460
|
return $self->output_filename_base . '_common_set'; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub groups_set_one_unique { |
79
|
8
|
|
|
8
|
0
|
32
|
my ($self) = @_; |
80
|
8
|
|
|
|
|
56
|
$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
|
26
|
my ($self) = @_; |
89
|
8
|
|
|
|
|
39
|
$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
|
24
|
my ($self) = @_; |
98
|
8
|
|
|
|
|
278
|
my $unique_group_1 = $self->_subtract_arrays( $self->_query_groups_objs->[0]->_groups, $self->_query_groups_objs->[1]->_groups ); |
99
|
8
|
|
|
|
|
245
|
my $unique_group_2 = $self->_subtract_arrays( $self->_query_groups_objs->[1]->_groups, $self->_query_groups_objs->[0]->_groups ); |
100
|
8
|
|
|
|
|
224
|
my $common_groups_1 = $self->_subtract_arrays( $unique_group_1,$self->_query_groups_objs->[2]->_groups); |
101
|
8
|
|
|
|
|
36
|
my $common_groups_2 = $self->_subtract_arrays( $unique_group_2,$common_groups_1); |
102
|
8
|
|
|
|
|
346
|
$self->_query_groups_objs->[2]->groups_with_external_inputs( $self->groups_in_common_filename, $common_groups_2 ); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
2
|
|
|
2
|
|
14
|
no Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
9
|
|
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.10.2 |
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 |