line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::DOOP::Util::Sort; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
247
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Bio::DOOP::Util::Sort - Sort an array of arrays |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.3 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.3'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
@result = $mofext->get_results; |
21
|
|
|
|
|
|
|
$sorting = Bio::DOOP::Util::Sort->new($db,\results); |
22
|
|
|
|
|
|
|
@sorted_result = $sorting->sort_by_column(1,"asc"); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This class can sort any type of array of arrays. It can be used to sort the |
27
|
|
|
|
|
|
|
mofext or fuzznuc results, but can sort other data. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 AUTHORS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Tibor Nagy, Godollo, Hungary and Endre Sebestyen, Martonvasar, Hungary |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Creates a Sort class from an array of arrays type data structure. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$mofext_sort = Bio::DOOP::Util::Sort->new($db,\@mofext_result); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
0
|
|
|
0
|
1
|
|
my $self = {}; |
45
|
0
|
|
|
|
|
|
my $dummy = shift; |
46
|
0
|
|
|
|
|
|
my $db = shift; |
47
|
0
|
|
|
|
|
|
my $array = shift; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$self->{ARRAY} = $array; |
50
|
0
|
|
|
|
|
|
$self->{DB} = $db; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
bless $self; |
53
|
0
|
|
|
|
|
|
return($self); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 sort_by_column |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Sort a given array by column. (Warning, the first column is zero!) |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Return type: sorted array of arrays |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
@ret = $mofext_sort->sort_by_column(0,"asc"); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub sort_by_column { |
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
my $column = shift; |
69
|
0
|
|
|
|
|
|
my $orient = shift; |
70
|
0
|
|
|
|
|
|
my @ret; |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
0
|
|
|
|
if( ($orient eq "1") || ($orient eq "asc") || ($orient eq "ascending")){ |
|
|
|
0
|
|
|
|
|
73
|
0
|
|
|
|
|
|
@ret = sort { $$a[$column] <=> $$b[$column] } @{$self->{ARRAY}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else{ |
76
|
0
|
|
|
|
|
|
@ret = sort { $$b[$column] <=> $$a[$column] } @{$self->{ARRAY}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
1; |