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

Sam Al-Droubi saldroubi at yahoo.com
Fri Mar 3 15:15:59 EST 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 why 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",
   \n           \n      -matrix_name\u003d> "my_matrix_name",
\n   \n           \n      -rownames   \u003d> [qw(A C T\nG)],
\n   \n           \n      -colnames   \u003d> [qw(1 2 3 4\n5 6 7 )]);
\n
\n
\n
\nmy $fh \u003d Bio::Matrix::IO->newFh(-file\u003d>\'>my_file.txt\',-format\u003d>\'scoring\');
\n
\nprint $fh $matrix; # write a matrix object
\n

-- 
Sincerely, 
Sam Al-Droubi, M.S. \n\n
",0]  );  D(["ce"]);    //-->                          -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.
saldroubi at yahoo.com


More information about the Bioperl-l mailing list