[Bioperl-l] How to print a generic matrix?

Sam Al-Droubi saldroubi at gmail.com
Fri Mar 3 16:11:04 UTC 2006


Hi Everyone,

I am using the using Bio::Matrix::Generic module to create my own matrices
(not reading from a file) but I am having troubles printing them with
Bio::Matrix::IO module.  I tried using both write_matrix and print function
without success.  I get the following error when I use print.

saldroubi at ude:~/Documents/p2020> perl matrix_print.pl
Can't locate object method "write_tree" via package
"Bio::Matrix::IO::scoring" at
/usr/lib/perl5/site_perl/5.8.6/Bio/Matrix/IO.pm line 262.

The sample code is below.  Ideally I want to print to STDOUT not to a file
but I was trying to follow the example in the documentation.
Any idea what I am doing wrong.   I using bioperl 1.5.1.

Of course, I could write my own print function but should I reinvent the
wheel.

Thank you.

-------------------------------

use strict;
use Bio::Matrix::Generic;
use Bio::Matrix::IO;


my $raw = [ [ 0, 0, 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0, 0, 0 ]
      ];

my $matrix = new Bio::Matrix::Generic(-values     => $raw,
                      -matrix_id  => "my_matrix_id",
                      -matrix_name=> "my_matrix_name",
                      -rownames   => [qw(A C T G)],
                      -colnames   => [qw(1 2 3 4 5 6 7 )]);



my $fh = Bio::Matrix::IO->newFh(-file=>'>my_file.txt',-format=>'scoring');

print $fh $matrix; # write a matrix object


--
Sincerely,
Sam Al-Droubi, M.S.




More information about the Bioperl-l mailing list