| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::Roary::Output::DifferenceBetweenSets; |
|
2
|
|
|
|
|
|
|
$Bio::Roary::Output::DifferenceBetweenSets::VERSION = '3.10.1'; |
|
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
|
|
536242
|
use Moose; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
15
|
|
|
7
|
2
|
|
|
2
|
|
12415
|
use Bio::SeqIO; |
|
|
2
|
|
|
|
|
55414
|
|
|
|
2
|
|
|
|
|
51
|
|
|
8
|
2
|
|
|
2
|
|
270
|
use Bio::Roary::Exceptions; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
41
|
|
|
9
|
2
|
|
|
2
|
|
256
|
use Bio::Roary::AnalyseGroups; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
97
|
|
|
10
|
2
|
|
|
2
|
|
496
|
use Bio::Roary::Output::QueryGroups; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
912
|
|
|
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
|
|
27
|
my ($self) = @_; |
|
22
|
8
|
|
|
|
|
67
|
my @query_groups_objs; |
|
23
|
8
|
|
|
|
|
31
|
for my $file_name_set ( @{ $self->input_filenames_sets } ) { |
|
|
8
|
|
|
|
|
331
|
|
|
24
|
16
|
|
|
|
|
665
|
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
|
|
|
|
|
26
|
my @all_input_files = (@{ $self->input_filenames_sets->[0] },@{ $self->input_filenames_sets->[1] }); |
|
|
8
|
|
|
|
|
343
|
|
|
|
8
|
|
|
|
|
306
|
|
|
34
|
8
|
|
|
|
|
313
|
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
|
|
|
|
|
326
|
return \@query_groups_objs; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _subtract_arrays { |
|
47
|
48
|
|
|
48
|
|
123
|
my ( $self, $array_1, $array_2 ) = @_; |
|
48
|
48
|
|
|
|
|
104
|
my %array_1 = map { $_ => 1 } @{$array_1}; |
|
|
168
|
|
|
|
|
469
|
|
|
|
48
|
|
|
|
|
135
|
|
|
49
|
48
|
|
|
|
|
210
|
my @difference = grep { not $array_1{$_} } @{$array_2}; |
|
|
217
|
|
|
|
|
694
|
|
|
|
48
|
|
|
|
|
122
|
|
|
50
|
48
|
|
|
|
|
187
|
return \@difference; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _groups_unique { |
|
54
|
16
|
|
|
16
|
|
74
|
my ( $self, $output_filename, $query_group1, $query_group2 ) = @_; |
|
55
|
16
|
|
|
|
|
606
|
my $unique_groups = $self->_subtract_arrays( $query_group2->_groups, $query_group1->_groups ); |
|
56
|
16
|
|
|
|
|
76
|
$query_group1->groups_with_external_inputs( $output_filename, $unique_groups ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub groups_set_one_unique_filename |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
15
|
|
|
15
|
0
|
59
|
my ($self) = @_; |
|
62
|
15
|
|
|
|
|
713
|
return $self->output_filename_base . '_unique_set_one'; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub groups_set_two_unique_filename |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
15
|
|
|
15
|
0
|
41
|
my ($self) = @_; |
|
68
|
15
|
|
|
|
|
609
|
return $self->output_filename_base . '_unique_set_two'; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub groups_in_common_filename |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
15
|
|
|
15
|
0
|
51
|
my ($self) = @_; |
|
74
|
15
|
|
|
|
|
518
|
return $self->output_filename_base . '_common_set'; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub groups_set_one_unique { |
|
79
|
8
|
|
|
8
|
0
|
30
|
my ($self) = @_; |
|
80
|
8
|
|
|
|
|
78
|
$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
|
32
|
my ($self) = @_; |
|
89
|
8
|
|
|
|
|
41
|
$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
|
31
|
my ($self) = @_; |
|
98
|
8
|
|
|
|
|
344
|
my $unique_group_1 = $self->_subtract_arrays( $self->_query_groups_objs->[0]->_groups, $self->_query_groups_objs->[1]->_groups ); |
|
99
|
8
|
|
|
|
|
331
|
my $unique_group_2 = $self->_subtract_arrays( $self->_query_groups_objs->[1]->_groups, $self->_query_groups_objs->[0]->_groups ); |
|
100
|
8
|
|
|
|
|
329
|
my $common_groups_1 = $self->_subtract_arrays( $unique_group_1,$self->_query_groups_objs->[2]->_groups); |
|
101
|
8
|
|
|
|
|
60
|
my $common_groups_2 = $self->_subtract_arrays( $unique_group_2,$common_groups_1); |
|
102
|
8
|
|
|
|
|
322
|
$self->_query_groups_objs->[2]->groups_with_external_inputs( $self->groups_in_common_filename, $common_groups_2 ); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
2
|
|
|
2
|
|
16
|
no Moose; |
|
|
2
|
|
|
|
|
4
|
|
|
|
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.10.1 |
|
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 |