This file is indexed.

/usr/share/perl5/GO/Model/Root.pm is in libgo-perl 0.15-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
# $Id: Root.pm,v 1.6 2007/08/07 21:43:37 cmungall Exp $
#
# This GO module is maintained by Chris Mungall <cjm@fruitfly.org>
#
# see also - http://www.geneontology.org
#          - http://www.godatabase.org/dev
#
# You may distribute this module under the same terms as perl itself

package GO::Model::Root;

=head1 NAME

  GO::Model::Root - base class for all GO::Model objects

=head1 DESCRIPTION

base class for all GO::Model objects

=cut

use strict;
use Carp;
use Exporter;
use Data::Dumper;
use vars qw(@ISA $AUTOLOAD);

my @ISA = qw(Exporter);


# - - - - - - - - - - Public functions - - - - - - - - - - - - 

=head1 Constructors

=head2 new

Constructor: Basically just calls L<_initialize>().  Most subclasses
should not need to override new, but instead should override
L<_initialize>().

If L<_initialize>() fails , the procedure will die

WARNING: This procedure will die if initialization is unsuccessful.  
Use an eval statement to catch such exceptions.

=cut

sub new 
{
    my $proto = shift; my $class = ref($proto) || $proto;;
    my $self = {};
    bless $self, $class;

    $self->_initialize(@_);

    if ($ENV{PERL_MEMORY_TRACE}) {
	print STDERR "NEW: ".$self->sprint_self."\n";
    }
    return $self;
}

sub throw {
    my $self = shift;
    my @msg = @_;
    confess("@msg");
}
sub warn {
    my $self = shift;
    my @msg = @_;
    warn("@msg");
}

=head2 obj_factory

  Usage   - $obj->obj_factory->create_new_term_object($h);
  Alias   - apph
  Returns - L<GO::ObjFactory>
  Args    - none

=cut

sub apph {
    my $self = shift;
    $self->{apph} = shift if @_;
    return $self->{apph};
}
*obj_factory = \&apph;


=head2 sprint_self

Prints out a description of the object to a string.

=cut

sub sprint_self
  {
    my $self = shift;
    my $str = $self;
    if ($self->can("name") && $self->name) {
	$str.= " ".$self->name;
    }
    return $str;
  }


=head2 dump

dumps the object (can be read back in with eval)

=cut

sub dump {
    my $self = shift;
    my $ob = shift || $self;
    my $d = Data::Dumper->new(["obj", $ob]);
    return $d->Dump;
}

sub _initialize 
{

    my $self = shift;
    $self->init if $self->can("init");
    my @valid_params = $self->_valid_params;
    my ($paramh) = @_; # first arg

    # arguments passed as hash?
    if (ref($paramh)) {
        map {
            if (defined($paramh->{$_})) {
                $self->$_($paramh->{$_});
            }
        } @valid_params;
    }
    else {
        # arguments passed as array
        for (my $i=0; $i<@_; $i++) {
            my $m = $valid_params[$i];
            $self->$m($_[$i]);
        }
    }
}

sub _valid_params {
    ();
}

sub is_valid_param {
    my $self = shift;
    my $param = shift;
    return scalar(grep {$_ eq $param} $self->_valid_params);
}

sub id {
    my $self = shift;
    $self->{id} = shift if @_;
    return $self->{id};
}


=head2 namespace

  Usage   - print $term->namespace();     # getting the type
  Usage   - $term->namespace("molecular_function"); # setting the type
  Alias   - type
  Alias   - term_type
  Alias   - category
  Alias   - ontology
  Returns - string representing type
  Args    - string represnting type [optional]

The OBO namespace for the L<GO::Model::Term> or
L<GO::Model::Relationship>

=cut

sub namespace {
    my $self = shift;
    $self->{namespace} = shift if @_;
    return $self->{namespace};
}
# synonyms
sub term_type { shift->namespace(@_) }
sub category { shift->namespace(@_) }
sub ontology { shift->namespace(@_) }
sub type { shift->namespace(@_) }



=head2 _cleanup

Called at object destruction time.  Should be overridden to perform
cleanup tasks.

=cut

#sub _cleanup
#{
#  my $self = shift;

#  # The best we can do here is clean up references left 
#  # in our hash table.  We'll also drop debugging alerts.
#  my $attribute;
#  foreach $attribute (keys %$self)
#    {
#      if(ref($self->{$attribute})) 
#	{
#	  undef $self->{$attribute};
#	}
#    }
#}


sub _initialize_attributes {

    my $self = shift;
    my @att_name_arr = @{shift || []};
    my $param_ref = shift;
    my @param = @{$param_ref};


    if (defined($param[0]) && $param[0]=~/^-/) {
	
	# attributes specified as '-key=>val' list

	my $i;
	for ($i=0;$i<@param;$i+=2) {
	    $param[$i]=~tr/A-Z/a-z/;
	}
	
	# Now we'll convert the @params variable into an associative array.
	my(%param) = @param;

	my(@return_array);
	my $key;
	foreach $key (@att_name_arr) {
	    my $orig_key = $key;
	    $key=~tr/A-Z/a-z/;
	    if (defined($param{"-".$key})) {
		my($value) = $param{"-".$key};
		delete $param{"-".$key};
		$self->{"_$orig_key"} = $value;
	    }
	}
  
	# catch user misspellings resulting in unrecognized names
	my(@restkeys) = keys %param;

	@{$param_ref} = %param;
	if (scalar(@restkeys) > 0) {
######	    carp("@restkeys not processed in _rearrange(), did you use a non-recognized parameter name ? ");
	}
	
    }
    else {
	# attributes specified as basic array
	my $i;
	for ($i=0; $i<@param; $i++) {
	    if ($i >= @att_name_arr) {
		confess("Too many params");
	    }
	    my $att_name = $att_name_arr[$i];
	    $self->{"_$att_name"} = $param[$i];
	}
    }
	
}

sub from_idl {
    my $class = shift;
    my $h = shift;
    foreach my $k (%$h) {
	if (ref($h->{$k}) eq "HASH") {
	    confess("must be dealth with in subclass of this");
	}
    }
    return $class->new($h);
}

sub to_prolog {
    my $self = shift;
    my @t = $self->to_ptuples(@_);
    my @s =
    map {
        sprintf("%s(%s).\n",
                shift @$_,
                join(", ",
                     map {$self->prolog_quote($_)} @$_
                    ));
    } @t;
    my %h=();
    # uniquify
    @s = grep {(!$h{$_}) and ($h{$_} = 1)} @s;
    return join("", @s);
}

sub prolog_quote {
    my $self = shift;
    my $s = shift;
    $s = '' unless defined $s;
    $s =~ s/\'/\\\'/g;
    "'$s'";
}



# auto-declare accessors

sub AUTOLOAD {
    
    my $self = shift;
 
    my $name = $AUTOLOAD;
    $name =~ s/.*://;   # strip fully-qualified portion

    if ($name eq "DESTROY") {
	# we dont want to propagate this!!
	return;
    }

    confess("$self") unless ref($self);
    
    my $add;
    if ($name =~ /add_(.+)/) {
        $add = $1."_list";
    }

    if ($self->can($name)) {
	confess("assertion error!");
    }
    if ($self->is_valid_param($name)) {
	
	$self->{$name} = shift if @_;
	return $self->{$name};
    }
    if ($add && $self->is_valid_param($add)) {
	push(@{$self->{$add}}, @_);
	return $self->{$add};
    }
    else {
	confess("can't do $name on $self");
    }
    
}




1;