| 1 | package Bio::DOOP::Util::Sort; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | 2 | 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 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | 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 | 0 | ▶ | sub sort_by_column { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_by_column: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $column = shift; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $orient = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if( ($orient eq "1") || ($orient eq "asc") || ($orient eq "ascending")){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$orient eq 1 or $orient eq "asc" or $orient eq "ascending"
$orient eq 1 or $orient eq "asc"
MC/DC0%0/3
$orient eq 1 or $orient eq "asc" or $orient eq "ascending"
$orient eq 1
$orient eq "asc"
$orient eq "ascending"
Truth table0%0/4
A or B or C
A= $orient eq 1B= $orient eq "asc"C= $orient eq "ascending"
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | @ret = sort { $$a[$column] <=> $$b[$column] } @{$self->{ARRAY}}; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | @ret = sort { $$b[$column] <=> $$a[$column] } @{$self->{ARRAY}}; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||