Skip to content
Snippets Groups Projects
Commit a619d6f8 authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

In list_pairs(): Correct documentation and an error messgae. From

Michael S.

Also, reformat method.
parent 34503b4c
No related branches found
No related tags found
No related merge requests found
...@@ -772,7 +772,7 @@ sub add_Mapper{ ...@@ -772,7 +772,7 @@ sub add_Mapper{
start coordinate of 'source' sequence start coordinate of 'source' sequence
Arg 3 int $end Arg 3 int $end
end coordinate of 'source' sequence end coordinate of 'source' sequence
Arg 4 int $type Arg 4 string $type
nature of transform - gives the type of nature of transform - gives the type of
coordinates to be transformed *from* coordinates to be transformed *from*
Function list all pairs of mappings in a region Function list all pairs of mappings in a region
...@@ -782,62 +782,62 @@ sub add_Mapper{ ...@@ -782,62 +782,62 @@ sub add_Mapper{
=cut =cut
sub list_pairs{ sub list_pairs {
my ($self, $id, $start, $end, $type) = @_; my ( $self, $id, $start, $end, $type ) = @_;
if ( !$self->{'_is_sorted'} ) { $self->_sort() }
if( ! $self->{'_is_sorted'} ) { $self->_sort() } if ( !defined $type ) {
throw("Expected 4 arguments");
}
if( !defined $type ) { if ( $start > $end ) {
throw("Must start,end,id,type as coordinates"); throw( "Start is greater than end "
} . "for id $id, start $start, end $end\n" );
}
if( $start > $end ) { my $hash = $self->{"_pair_$type"};
throw("Start is greater than end for id $id, start $start, end $end\n");
}
my $hash = $self->{"_pair_$type"}; my ( $from, $to );
my ($from, $to); if ( $type eq $self->{'to'} ) {
$from = 'to';
$to = 'from';
} else {
$from = 'from';
$to = 'to';
}
if($type eq $self->{'to'}) { unless ( defined $hash ) {
$from = 'to'; throw("Type $type is neither to or from coordinate systems");
$to = 'from'; }
} else {
$from = 'from';
$to = 'to';
}
unless(defined $hash) {
throw("Type $type is neither to or from coordinate systems");
}
my @list; my @list;
unless(exists $hash->{uc($id)}) { unless ( exists $hash->{ uc($id) } ) {
return (); return ();
} }
@list = @{$hash->{uc($id)}}; @list = @{ $hash->{ uc($id) } };
my @output; my @output;
if( $start == -1 && $end == -1 ) { if ( $start == -1 && $end == -1 ) {
return @list; return @list;
} else { } else {
foreach my $p ( @list ) { foreach my $p (@list) {
if( $p->{$from}->{'end'} < $start ) { if ( $p->{$from}->{'end'} < $start ) {
next; next;
} }
if( $p->{$from}->{'start'} > $end ) { if ( $p->{$from}->{'start'} > $end ) {
last; last;
} }
push(@output,$p); push( @output, $p );
} }
return @output; return @output;
} }
} } ## end sub list_pairs
=head2 from, to =head2 from, to
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment