Skip to content

Commit

Permalink
add sort cov:pid and pid:cov modes
Browse files Browse the repository at this point in the history
  • Loading branch information
desmid committed Sep 1, 2019
1 parent d30f3b1 commit b6db940
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
22 changes: 22 additions & 0 deletions lib/Bio/MView/Align/Alignment.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ sub sort_alignment {
}
@unsorted;
}
elsif ($mode eq "cov:pid") {
@sorted = sort {
#descending
return -1 if $a->get_coverage() > $b->get_coverage();
return 1 if $a->get_coverage() < $b->get_coverage();
return -1 if $a->get_identity() > $b->get_identity();
return 1 if $a->get_identity() < $b->get_identity();
return $a->uid cmp $b->uid;
}
@unsorted;
}
elsif ($mode eq "pid:cov") {
@sorted = sort {
#descending
return -1 if $a->get_identity() > $b->get_identity();
return 1 if $a->get_identity() < $b->get_identity();
return -1 if $a->get_coverage() > $b->get_coverage();
return 1 if $a->get_coverage() < $b->get_coverage();
return $a->uid cmp $b->uid;
}
@unsorted;
}
else {
die "${self}::sort: unknown mode '$mode'\n";
}
Expand Down
10 changes: 7 additions & 3 deletions lib/Bio/MView/Option/Arguments.pm
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ sub check_identity_mode {
my @Known_Sort_Modes = (
'cov',
'pid',
'cov:pid',
'pid:cov',
'none',
);

Expand All @@ -300,9 +302,11 @@ sub check_sort_mode {
my $val = shift;
local $_;
foreach ($val) { #switch
return "cov" if $_ =~ /^c/i;
return "pid" if $_ =~ /^p/i;
return "none" if $_ =~ /^n/i;
return "cov" if $_ =~ /^cov$/i;
return "pid" if $_ =~ /^pid$/i;
return "cov:pid" if $_ =~ /^cov:pid/i;
return "pid:cov" if $_ =~ /^pid:cov/i;
return "none" if $_ =~ /^n/i;
}
return undef;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Bio/MView/Option/Types.pm
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ $Types = [
{
'type' => "sort::mode",
'label' => "mode",
'values' => "cov,pid,none",
'values' => list_sort_modes,
'default' => "none",
'test' => sub {
my ($self, $on, $ov, $e) = @_;
Expand Down

0 comments on commit b6db940

Please sign in to comment.