This file is indexed.

/usr/share/perl5/Bio/Map/GeneRelative.pm is in libbio-perl-perl 1.6.924-1.

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
# $Id: GeneRelative.pm,v 1.6 2006/09/20 11:53:29 sendu Exp $
#
# BioPerl module for Bio::Map::GeneRelative
#
# Please direct questions and support issues to <bioperl-l@bioperl.org> 
#
# Cared for by Sendu Bala <bix@sendu.me.uk>
#
# Copyright Sendu Bala
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

Bio::Map::GeneRelative - Represents being relative to named sub-regions of a
                         gene.

=head1 SYNOPSIS

    use Bio::Map::GeneRelative;

    # say that a somthing will have a position relative to the start of the
    # gene on map
    my $rel = Bio::Map::GeneRelative->new(-gene => 0);

    # or that something will be relative to the third transcript of a gene
    # on a map
    $rel = Bio::Map::GeneRelative->new(-transcript => 3);

    # or to the 5th intron of the default transcript
    $rel = Bio::Map::GeneRelative->new(-intron => [0, 5]);

    # use the $rel as normal; see L<Bio::Map::Relative>

=head1 DESCRIPTION

Be able to say that a given position is relative to some standard part of a
gene.

=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
the Bioperl mailing list.  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
of the bugs and their resolution. Bug reports can be submitted via the
web:

  https://github.com/bioperl/bioperl-live/issues

=head1 AUTHOR - Sendu Bala

Email bix@sendu.me.uk

=head1 APPENDIX

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

=cut

# Let the code begin...

package Bio::Map::GeneRelative;
use strict;

use Scalar::Util qw(looks_like_number);

use base qw(Bio::Map::Relative);

=head2 new

 Title   : new
 Usage   : my $relative = Bio::Map::Relative->new();
 Function: Build a new Bio::Map::Relative object.
 Returns : Bio::Map::Relative object
 Args    : -gene => int       : coordinates are relative to the int'th base
                                downstream of the Position's map's gene
                                [default is gene => 0, ie. relative to the
                                start of the gene],
           -transcript => int : or relative to the start of the int'th
                                transcript of the Position's map's gene,
           -exon => [i, n]    : or relative to the start of the n'th
                                transcript's i'th exon,
           -intron => [i, n]  : or intron,
           -coding => int     : or the start of the int'th transcript's coding
                                region.

           -description => string : Free text description of what this relative
                                    describes

           (To say a Position is relative to something and upstream of it,
            the Position's start() co-ordinate should be set negative)
           In all cases, a transcript number of 0 means the active transcript.

=cut

sub new {
    my ($class, @args) = @_;
    my $self = $class->SUPER::new(@args);
    
    my ($gene, $transcript, $exon, $intron, $coding) =
        $self->_rearrange([qw( GENE TRANSCRIPT EXON INTRON CODING )], @args);
    
    my $set = (defined $gene) + (defined $transcript) + (defined $exon) + (defined $intron) + (defined $coding);
    if ($set > 1) {
        $self->throw("-gene, -transcript, -exon, -intron and -coding are mutually exclusive");
    }
    if ($exon && (! ref($exon) || ref($exon) ne 'ARRAY')) {
        $self->throw("-exon takes an array ref");
    }
    if ($intron && (! ref($intron) || ref($intron) ne 'ARRAY')) {
        $self->throw("-intron takes an array ref");
    }
    if ($set == 0) {
        # type could have been set already in the call to SUPER::new
        if ($self->type) {
            $self->warn("You set a type of relative not supported by GeneRelative; resetting to type 'gene'");
        }
        $gene = 0;
    }
    
    $self->gene($gene) if defined $gene;
    $self->transcript($transcript) if defined $transcript;
    $self->exon(@{$exon}) if defined $exon;
    $self->intron(@{$intron}) if defined $intron;
    $self->coding($coding) if defined $coding;
    
    return $self;
}

=head2 absolute_conversion

 Title   : absolute_conversion
 Usage   : my $absolute_coord = $relative->absolute_conversion($pos);
 Function: Convert the start co-ordinate of the supplied position into a number
           relative to the start of its map.
 Returns : scalar number
 Args    : Bio::Map::PositionI object

=cut

sub absolute_conversion {
    my ($self, $pos) = @_;
    $self->throw("Must supply an object") unless ref($pos);
    $self->throw("This is [$pos], not a Bio::Map::PositionI") unless $pos->isa('Bio::Map::PositionI');
    
    # get the raw start position of our position
    my $raw = $pos->start($pos->relative);
    $self->throw("Can't convert co-ordinates when start isn't set") unless defined($raw); #*** needed? return undef?
    
    # what are we relative to?
    my $type = $self->type;
    my $value = $self->$type;
    $self->throw("Details not yet set for this Relative, cannot convert") unless defined($value);
    
    # get the absolute start of the thing we're relative to
    if ($type =~ /gene|transcript|exon|intron|coding/) {
        my $map = $pos->map;
        my $throw_desc = $type eq 'gene' ? 'gene' : "gene's transcript";
        $self->throw("Relative to a map's $throw_desc, but the Position has no map") unless $map;
        $self->throw("Relative to a map's $throw_desc, but the Position's map isn't a Bio::Map::GeneMap") unless $map->isa('Bio::Map::GeneMap');
        my $gene = $map->gene;
        
        if ($type eq 'gene') {
            my $gene_pos = $gene->position($map);
            my $rel = $gene_pos->relative;
            my $start = $rel->absolute_conversion($gene_pos);
            $value += $start;
        }
        else {
            my @values = ref($value) ? @{$value} : ($value);
            my $trans = ref($value) ? $values[1] : $value;
            my $throw_txt = $trans == 0 ? 'default/active transcript' : "transcript $trans";
            my $throw_txt2 = ref($value) ? ", or no $type $values[0]" : '';
            my $method = $type eq 'coding' ? 'coding_position' : "get_${type}_position";
            $value = $gene->$method($map, @values) || $self->throw("Relative to $throw_txt of the map's gene, but there is no such transcript$throw_txt2");
        }
    }
    else {
        return $self->SUPER::absolute_conversion($pos);
    }
    if (ref($value)) {
        # psuedo-recurse
        my $rel = $value->relative;
        $value = $rel->absolute_conversion($value);
    }
    
    if (defined($value)) {
        return $value + $raw;
    }
    return;
}

=head2 type

 Title   : type
 Usage   : my $type = $relative->type();
 Function: Get the type of thing we are relative to. The types correspond
           to a method name, so the value of what we are relative to can
           subsequently be found by $value = $relative->$type;

           Note that type is set by the last method that was set, or during
           new().

 Returns : 'gene', 'transcript', 'exon', 'intron' or 'coding'
 Args    : none

=cut

=head2 gene

 Title   : gene
 Usage   : my $int = $relative->gene();
           $relative->gene($int);
 Function: Get/set the distance from the start of the gene that the Position's
           co-ordiantes are relative to.
 Returns : int
 Args    : none to get, OR
           int to set; a value of 0 means relative to the start of the gene.

=cut

sub gene {
    my ($self, $num) = @_;
    if (defined($num)) {
        $self->throw("This is [$num], not a number") unless looks_like_number($num);
        $self->{_use} = 'gene';
        $self->{_gene} = $num;
    }
    return defined($self->{_gene}) ? $self->{_gene} : return;
}

=head2 transcript

 Title   : transcript
 Usage   : my $int = $relative->transcript();
           $relative->transcript($int);
 Function: Get/set which transcript of the Position's map's gene the Position's
           co-ordinates are relative to.
 Returns : int
 Args    : none to get, OR
           int to set; a value of 0 means the active (default) transcript.

=cut

sub transcript {
    my ($self, $num) = @_;
    if (defined($num)) {
        $self->throw("This is [$num], not a number") unless looks_like_number($num);
        $self->{_use} = 'transcript';
        $self->{_transcript} = $num;
    }
    return defined($self->{_transcript}) ? $self->{_transcript} : return;
}

=head2 exon

 Title   : exon
 Usage   : my ($exon_number, $transcript_number) = @{$relative->exon()};
           $relative->exon($exon_number, $transcript_number);
 Function: Get/set which exon of which transcript of the Position's map's gene
           the Position's co-ordinates are relative to.
 Returns : reference to list with two ints, exon number and transcript number
 Args    : none to get, OR
           int (exon number) AND int (transcript number) to set. The second int
           is optional and defaults to 0 (meaning default/active transcript).

=cut

sub exon {
    my ($self, $num, $t_num) = @_;
    if (defined($num)) {
        if (defined($t_num)) {
            $self->throw("This is [$t_num], not a number") unless looks_like_number($t_num);
        }
        $t_num ||= 0;
        $self->throw("This is [$num], not a number") unless looks_like_number($num);
        $self->{_use} = 'exon';
        $self->{_exon} = [$num, $t_num];
    }
    return $self->{_exon} || return;
}

=head2 intron

 Title   : intron
 Usage   : my ($intron_number, $transcript_number) = @{$relative->intron()};
           $relative->intron($intron_number, $transcript_number);
 Function: Get/set which intron of which transcript of the Position's map's gene
           the Position's co-ordinates are relative to.
 Returns : reference to list with two ints, intron number and transcript number
 Args    : none to get, OR
           int (intron number) AND int (transcript number) to set. The second
           int is optional and defaults to 0 (meaning default/active
           transcript).

=cut

sub intron {
    my ($self, $num, $t_num) = @_;
    if (defined($num)) {
        if (defined($t_num)) {
            $self->throw("This is [$t_num], not a number") unless looks_like_number($t_num);
        }
        $t_num ||= 0;
        $self->throw("This is [$num], not a number") unless looks_like_number($num);
        $self->{_use} = 'intron';
        $self->{_intron} = [$num, $t_num];
    }
    return $self->{_intron} || return;
}

=head2 coding

 Title   : coding
 Usage   : my $transcript_number = $relative->coding;
           $relative->coding($transcript_number);
 Function: Get/set which transcript's coding region of the Position's map's gene
           the Position's co-ordinates are relative to.
 Returns : int
 Args    : none to get, OR
           int to set (the transcript number, see transcript())

=cut

sub coding {
    my ($self, $num) = @_;
    if (defined($num)) {
        $self->throw("This is [$num], not a number") unless looks_like_number($num);
        $self->{_use} = 'coding';
        $self->{_coding} = $num;
    }
    return defined($self->{_coding}) ? $self->{_coding} : return;
}

1;