This file is indexed.

/usr/share/perl5/Bio/Range.pm is in libbio-perl-perl 1.6.901-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#
# BioPerl module for Bio::Range
#
# Please direct questions and support issues to <bioperl-l@bioperl.org> 
#
# Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
#
# Copywright Matthew Pocock
#
# You may distribute this module under the same terms as perl itself
#
# POD documentation - main docs before the code
#

=head1 NAME

Bio::Range - Pure perl RangeI implementation

=head1 SYNOPSIS

  $range = Bio::Range->new(-start=>10, -end=>30, -strand=>+1);
  $r2 = Bio::Range->new(-start=>15, -end=>200, -strand=>+1);

  print join(', ', $range->union($r2)), "\n";
  print join(', ', $range->intersection($r2)), "\n";

  print $range->overlaps($r2), "\n";
  print $range->contains($r2), "\n";

=head1 DESCRIPTION

This provides a pure perl implementation of the BioPerl range
interface.

Ranges are modeled as having (start, end, length, strand). They use
Bio-coordinates - all points E<gt>= start and E<lt>= end are within the
range. End is always greater-than or equal-to start, and length is
greather than or equal to 1. The behaviour of a range is undefined if
ranges with negative numbers or zero are used.

So, in summary:

  length = end - start + 1
  end >= start
  strand = (-1 | 0 | +1)

=head1 FEEDBACK

=head2 Mailing Lists

User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists.  Your participation is much appreciated.

  bioperl-l@bioperl.org                  - General discussion
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

=head2 Support 

Please direct usage questions or support issues to the mailing list:

I<bioperl-l@bioperl.org>

rather than to the module maintainer directly. Many experienced and 
reponsive experts will be able look at the problem and quickly 
address it. Please include a thorough description of the problem 
with code and data examples if at all possible.

=head2 Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution.  Bug reports can be submitted via  the web:

  https://redmine.open-bio.org/projects/bioperl/

=head1 AUTHOR - Heikki Lehvaslaiho

Email heikki-at-bioperl-dot-org

=head1 APPENDIX

The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _

=cut

package Bio::Range;

use strict;
use Carp;
use integer;


use base qw(Bio::Root::Root Bio::RangeI);

=head1 Constructors

=head2 new

  Title   : new
  Usage   : $range = Bio::Range->new(-start => 100, -end=> 200, -strand = +1);
  Function: generates a new Bio::Range
  Returns : a new range
  Args    : -strand (defaults to 0) and any two of (-start, -end, -length),
            the third will be calculated

=cut

sub new {
  my ($caller, @args) = @_;
  my $self = $caller->SUPER::new(@args);
  my ($strand, $start, $end, $length) = 
      $self->_rearrange([qw(STRAND 
			    START
			    END 
			    LENGTH
			    )],@args);
  $self->strand($strand || 0);

  if(defined $start ) {
      $self->start($start);
      if(defined $end) {
	  $self->end($end);
      } elsif(defined $length) {
	  $self->end($self->start()+ $length - 1);
      }
  } elsif(defined $end && defined $length ) {
      $self->end($end);
      $self->start($self->end() - $length + 1);
  }
  return $self;
}

=head2 unions

 Title   : unions
 Usage   : @unions = Bio::Range->unions(@ranges);
 Function: generate a list of non-intersecting Bio::Range objects
           from a list of Bio::Range objects which may intersect
 Returns : a list of Bio::Range objects
 Args    : a list of Bio::Range objects


=cut

sub unions {
  my ($class,@i) = @_;

  my $i = 0;
  my %i = map { $i++ => $_ } @i;

  my $lastsize = scalar(keys %i);

  do {

    foreach my $j (sort { $i{$a}->start <=> $i{$b}->start } keys %i){
      foreach my $k (sort { $i{$a}->start <=> $i{$b}->start } keys %i){

        #it may have been replaced by a union under the key of
        #the overlapping range, we are altering the hash in-place
        next unless $i{$j};

        next if $i{$k}->end   < $i{$j}->start;
        last if $i{$k}->start > $i{$j}->end;

        if($i{$j}->overlaps($i{$k})){
          my($start,$end,$strand) = $i{$j}->union($i{$k});
          delete($i{$k});
          $i{$j} = Bio::Range->new( -start => $start , -end => $end , -strand => $strand );
        }
      }
    }

    goto DONE if scalar(keys %i) == $lastsize;
    $lastsize = scalar(keys %i);

    #warn $lastsize;

  } while(1);

  DONE:

  return values %i;
}


=head1 Member variable access

These methods let you get at and set the member variables

=head2 start

  Title    : start
  Function : return or set the start co-ordinate
  Example  : $s = $range->start(); $range->start(7);
  Returns  : the value of the start co-ordinate
  Args     : optionally, the new start co-ordinate
  Overrides: Bio::RangeI::start

=cut

sub start {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->throw("'$value' is not an integer.\n") 
	    unless $value =~ /^[-+]?\d+$/;
        $self->{'start'} = $value;
    }
    return $self->{'start'};
}

=head2 end

  Title    : end
  Function : return or set the end co-ordinate
  Example  : $e = $range->end(); $range->end(2000);
  Returns  : the value of the end co-ordinate
  Args     : optionally, the new end co-ordinate
  Overrides: Bio::RangeI::end

=cut

sub end {

    my ($self,$value) = @_;
    if( defined $value) {
	$self->throw("'$value' is not an integer.\n") 
	    unless $value =~ /^[-+]?\d+$/;
        $self->{'end'} = $value;
    }
    return $self->{'end'};
}

=head2 strand

  Title    : strand
  Function : return or set the strandedness
  Example  : $st = $range->strand(); $range->strand(-1);
  Returns  : the value of the strandedness (-1, 0 or 1)
  Args     : optionally, the new strand - (-1, 0, 1) or (-, ., +).
  Overrides: Bio::RangeI::strand

=cut

{

my %VALID_STRAND = (
    -1      => -1,
    0       => 0,
    1       => 1,
    '+'     => 1,
    '-'     => -1,
    '.'     => 0
);

sub strand {
  my $self = shift;
  if(@_) {
    my $val = shift;
    if (exists $VALID_STRAND{$val}) {
        $self->{'strand'} = $VALID_STRAND{$val};
    } else {
        $self->throw("Invalid strand: $val");
    }
  }
  return $self->{'strand'};
}

}

=head2 length

  Title    : length
  Function : returns the length of this range
  Example  : $length = $range->length();
  Returns  : the length of this range, equal to end - start + 1
  Args     : if you attempt to set the length an exception will be thrown
  Overrides: Bio::RangeI::Length

=cut

sub length {
  my $self = shift;
  if(@_) {
    confess ref($self), "->length() is read-only";
  }
  return $self->end() - $self->start() + 1;
}

=head2 toString

  Title   : toString
  Function: stringifies this range
  Example : print $range->toString(), "\n";
  Returns : a string representation of this range

=cut

sub toString {
  my $self = shift;
  return  "(${\$self->start}, ${\$self->end}) strand=${\$self->strand}";
}

=head1 Boolean Methods

These methods return true or false.

 $range->overlaps($otherRange) && print "Ranges overlap\n";

=head2 overlaps

  Title    : overlaps
  Usage    : if($r1->overlaps($r2)) { do stuff }
  Function : tests if $r2 overlaps $r1
  Args     : a range to test for overlap with
  Returns  : true if the ranges overlap, false otherwise
  Inherited: Bio::RangeI

=head2 contains

  Title    : contains
  Usage    : if($r1->contains($r2) { do stuff }
  Function : tests whether $r1 totally contains $r2
  Args     : a range to test for being contained
  Returns  : true if the argument is totally contained within this range
  Inherited: Bio::RangeI

=head2 equals

  Title    : equals
  Usage    : if($r1->equals($r2))
  Function : test whether $r1 has the same start, end, length as $r2
  Args     : a range to test for equality
  Returns  : true if they are describing the same range
  Inherited: Bio::RangeI

=head1 Geometrical methods

These methods do things to the geometry of ranges, and return
triplets (start, end, strand) from which new ranges could be built.

=head2 intersection

  Title    : intersection
  Usage    : ($start, $stop, $strand) = $r1->intersection($r2)
  Function : gives the range that is contained by both ranges
  Args     : a range to compare this one to
  Returns  : nothing if they do not overlap, or the range that they do overlap
  Inherited: Bio::RangeI::intersection

=cut

=head2 union

  Title    : union
  Usage    : ($start, $stop, $strand) = $r1->union($r2);
           : ($start, $stop, $strand) = Bio::Range->union(@ranges);
  Function : finds the minimal range that contains all of the ranges
  Args     : a range or list of ranges
  Returns  : the range containing all of the ranges
  Inherited: Bio::RangeI::union

=cut

1;