This file is indexed.

/usr/share/perl5/Bio/Matrix/PhylipDist.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# BioPerl module for Bio::Matrix::PhylipDist
#
#
# Please direct questions and support issues to <bioperl-l@bioperl.org> 
#
# Cared for by Shawn Hoon <shawnh@fugu-sg.org>
#
# Copyright Shawn Hoon
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

Bio::Matrix::PhylipDist - A Phylip Distance Matrix object 

=head1 SYNOPSIS

  use Bio::Tools::Phylo::Phylip::ProtDist;
  my $dist = Bio::Tools::Phylo::Phylip::ProtDist->new(
    -file=>"protdist.out",
    -program=>"ProtDist");
  #or
   my $dist = Bio::Tools::Phylo::Phylip::ProtDist->new(
    -fh=>"protdist.out",
    -program=>"ProtDist");


  #get specific entries
  my $distance_value = $dist->get_entry('ALPHA','BETA');
  my @columns        = $dist->get_column('ALPHA');
  my @rows           = $dist->get_row('BETA');
  my @diagonal       = $dist->get_diagonal();

  #print the matrix in phylip numerical format
  print $dist->print_matrix;

=head1 DESCRIPTION

Simple object for holding Distance Matrices generated by the following Phylip programs:

1) dnadist
2) protdist
3) restdist

It currently handles parsing of the matrix without the data output option.

    5
Alpha          0.00000  4.23419  3.63330  6.20865  3.45431
Beta           4.23419  0.00000  3.49289  3.36540  4.29179
Gamma          3.63330  3.49289  0.00000  3.68733  5.84929
Delta          6.20865  3.36540  3.68733  0.00000  4.43345
Epsilon        3.45431  4.29179  5.84929  4.43345  0.00000

=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://github.com/bioperl/bioperl-live/issues

=head1 AUTHOR - Shawn Hoon

Email shawnh@fugu-sg.org

=head1 CONTRIBUTORS

Jason Stajich, jason-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

# Let the code begin...

package Bio::Matrix::PhylipDist;
use strict;


use base qw(Bio::Root::Root Bio::Matrix::MatrixI);

=head2 new

 Title   : new
 Usage   : my $family = Bio::Matrix::PhylipDist->new(-file=>"protdist.out",
                                                     -program=>"protdist");
 Function: Constructor for PhylipDist Object
 Returns : L<Bio::Matrix::PhylipDist>

=cut

sub new {
    my ($class,@args) = @_;
    my $self = $class->SUPER::new(@args);
    my ($matrix,$values, $names,
	$program,$matname,
	$matid) = $self->_rearrange([qw(MATRIX 
					VALUES 
					NAMES 
					PROGRAM
					MATRIX_NAME
					MATRIX_ID
					)],@args);
    
    ($matrix && $values && $names) || 
	$self->throw("Need matrix, values, and names fields all provided!");

    $program && $self->matrix_name($program) if defined $program;
    
    $self->_matrix($matrix) if ref($matrix) =~ /HASH/i;
    $self->_values($values) if ref($values) =~ /ARRAY/i;
    $self->names($names) if ref($names) =~ /ARRAY/i;

    $self->matrix_name($matname) if defined $matname;
    $self->matrix_id  ($matid)   if defined $matid;

    return $self;
}

=head2 get_entry

 Title   : get_entry
 Usage   : $matrix->get_entry();
 Function: returns a particular entry 
 Returns : a float
 Arguments:  string id1, string id2

=cut

sub get_entry {
  my ($self,$row,$column) = @_;
  $row && $column || $self->throw("Need at least 2 ids");
  my %matrix = %{$self->_matrix};
  my @values = @{$self->_values};
  if(ref $matrix{$row}{$column}){
      my ($i,$j) = @{$matrix{$row}{$column}};
      return $values[$i][$j];
  }
  return;

}

=head2 get_row

 Title   : get_row
 Usage   : $matrix->get_row('ALPHA');
 Function: returns a particular row 
 Returns : an array of float
 Arguments:  string id1

=cut

sub get_row {
    my ($self,$row) = @_;
    $row || $self->throw("Need at least a row id");

    my %matrix = %{$self->_matrix};
    my @values = @{$self->_values};
    my @names = @{$self->names};
    $matrix{$row} || return;
    my ($val) = values %{$matrix{$row}};
    my $row_pointer = $val->[0];
    my $index = scalar(@names)-1;
    return @{$values[$row_pointer]}[0..$index];
}

=head2 get_column

 Title   : get_column
 Usage   : $matrix->get_column('ALPHA');
 Function: returns a particular column 
 Returns : an array of floats 
 Arguments:  string id1

=cut

sub get_column {
    my ($self,$column) = @_;
    $column || $self->throw("Need at least a column id");

    my %matrix = %{$self->_matrix};
    my @values = @{$self->_values};
    my @names = @{$self->names}; 
    $matrix{$column} || return ();
    my ($val) = values %{$matrix{$column}};
    my $row_pointer = $val->[0];
    my @ret;
    for(my $i=0; $i < scalar(@names); $i++) {
	push @ret, $values[$i][$row_pointer];
    }
    return @ret;
} 

=head2 get_diagonal

 Title   : get_diagonal
 Usage   : $matrix->get_diagonal();
 Function: returns the diagonal of the matrix
 Returns : an array of float
 Arguments:  string id1

=cut

sub get_diagonal {
  my ($self) = @_;
  my %matrix = %{$self->_matrix};
  my @values = @{$self->_values};
  my @return;
  foreach my $name (@{$self->names}){
    my ($i,$j) = @{$matrix{$name}{$name}};
    push @return,$values[$i][$j];
  }
  return @return;
}

=head2 print_matrix

 Title   : print_matrix
 Usage   : $matrix->print_matrix();
 Function: returns a string of the matrix in phylip format 
 Returns : a string
 Arguments:  

=cut

sub print_matrix {
  my ($self) = @_;
  my @names = @{$self->names};
  my @values = @{$self->_values};
  my %matrix = %{$self->_matrix};
  my $str;
  $str.= (" "x 4). scalar(@names)."\n";
  foreach my $name (@names){
    my $newname = $name. (" " x (15-length($name)));
    if( length($name) >= 15 ) { $newname .= " " }
    $str.=$newname;
    my $count = 0;
    foreach my $n (@names) {
      my ($i,$j) = @{$matrix{$name}{$n}};
      if($count < $#names){
        $str .= $values[$i][$j]. "  ";
      }
      else {
	  if( ! defined $values[$i][$j] ) { 
	      $self->debug("no value for $i,$j cell\n");
	  } else { 
	      $str .= $values[$i][$j];
	  }
      }
      $count++;
    }
    $str.="\n";
  }
  return $str;
}

=head2 _matrix

 Title   : _matrix
 Usage   : $matrix->_matrix();
 Function: get/set for hash reference of the pointers
           to the value matrix 
 Returns : hash reference 
 Arguments: hash reference

=cut

sub _matrix {
  my ($self,$val) = @_;
  if($val){
    $self->{'_matrix'} = $val;
  }
  return $self->{'_matrix'};
}


=head2 names

 Title   : names
 Usage   : $matrix->names();
 Function: get/set for array ref of names of sequences
 Returns : an array reference 
 Arguments: an array reference

=cut

sub names {
  my ($self,$val) = @_;
  if($val){
    $self->{'_names'} = $val;
  }
  return $self->{'_names'};
}

=head2 program

 Title   : program
 Usage   : $matrix->program();
 Function: get/set for the program name generating this 
           matrix
 Returns : string
 Arguments: string

=cut

sub program {
  my ($self) = shift;
  return $self->matrix_name(@_);
}

=head2 _values

 Title   : _values
 Usage   : $matrix->_values();
 Function: get/set for array ref of the matrix containing
           distance values 
 Returns : an array reference 
 Arguments: an array reference

=cut

sub _values {
  my ($self,$val) = @_;
  if($val){
    $self->{'_values'} = $val;
  }
  return $self->{'_values'};
}


=head1 L<Bio::Matrix::MatrixI> implementation


=head2 matrix_id

 Title   : matrix_id
 Usage   : my $id = $matrix->matrix_id
 Function: Get/Set the matrix ID
 Returns : scalar value
 Args    : [optional] new id value to store


=cut

sub matrix_id{
   my $self = shift;
   return $self->{'_matid'} = shift if @_;
   return $self->{'_matid'};

   
}

=head2 matrix_name

 Title   : matrix_name
 Usage   : my $name = $matrix->matrix_name();
 Function: Get/Set the matrix name
 Returns : scalar value
 Args    : [optional] new matrix name value


=cut

sub matrix_name{
   my $self = shift;
   return $self->{'_matname'} = shift if @_;
   return $self->{'_matname'};
}

=head2 column_header

 Title   : column_header
 Usage   : my $name = $matrix->column_header(0)
 Function: Gets the column header for a particular column number
 Returns : string
 Args    : integer


=cut

sub column_header{
    my ($self,$num) = @_;
    my @coln = $self->column_names;
    return $coln[$num];
}


=head2 row_header

 Title   : row_header
 Usage   : my $name = $matrix->row_header(0)
 Function: Gets the row header for a particular row number
 Returns : string
 Args    : integer


=cut

sub row_header{
    my ($self,$num) = @_;
    my @rown = $self->row_names;
   return $rown[$num];
}
=head2 column_num_for_name

 Title   : column_num_for_name
 Usage   : my $num = $matrix->column_num_for_name($name)
 Function: Gets the column number for a particular column name
 Returns : integer
 Args    : string


=cut

sub column_num_for_name{
   my ($self,$name) = @_;
   my $ct = 0;
   foreach my $n ( $self->column_names ) {
       return $ct if $n eq $name;
       $ct++;
   }
   return;
}

=head2 row_num_for_name

 Title   : row_num_for_name
 Usage   : my $num = $matrix->row_num_for_name($name)
 Function: Gets the row number for a particular row name
 Returns : integer
 Args    : string


=cut

sub row_num_for_name{
   my ($self,$name) = @_;
   my $ct = 0;
   foreach my $n ( $self->row_names ) {
       return $ct if $n eq $name;
       $ct++;
   }
}

=head2 num_rows

 Title   : num_rows
 Usage   : my $rowcount = $matrix->num_rows;
 Function: Get the number of rows
 Returns : integer
 Args    : none


=cut

sub num_rows{ return scalar @{shift->names} }

=head2 num_columns

 Title   : num_columns
 Usage   : my $colcount = $matrix->num_columns
 Function: Get the number of columns
 Returns : integer
 Args    : none


=cut

sub num_columns{
   return scalar @{shift->names};
}

=head2 row_names

 Title   : row_names
 Usage   : my @rows = $matrix->row_names
 Function: The names of all the rows
 Returns : array in array context, arrayref in scalar context
 Args    : none


=cut

sub row_names{ return @{shift->names} }

=head2 column_names

 Title   : column_names
 Usage   : my @columns = $matrix->column_names
 Function: The names of all the columns
 Returns : array in array context, arrayref in scalar context
 Args    : none


=cut

sub column_names{ return @{shift->names} }  
1;