2 # BioPerl module for Bio::Matrix::IO::mlagan
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Sendu Bala <bix@sendu.me.uk>
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Matrix::IO::mlagan - A parser for the mlagan substitution matrix
21 my $parser = Bio::Matrix::IO->new(-format => 'mlagan',
22 -file => 'nucmatrix.txt');
23 my $matrix = $parser->next_matrix;
24 my $gap_open = $parser->gap_open;
25 my $gap_continue = $parser->gap_continue;
29 Use to read in and write out substitution matrix files suitable for use by
36 User feedback is an integral part of the evolution of this and other
37 Bioperl modules. Send your comments and suggestions preferably to
38 the Bioperl mailing list. Your participation is much appreciated.
40 bioperl-l@bioperl.org - General discussion
41 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
45 Please direct usage questions or support issues to the mailing list:
47 I<bioperl-l@bioperl.org>
49 rather than to the module maintainer directly. Many experienced and
50 reponsive experts will be able look at the problem and quickly
51 address it. Please include a thorough description of the problem
52 with code and data examples if at all possible.
56 Report bugs to the Bioperl bug tracking system to help us keep track
57 of the bugs and their resolution. Bug reports can be submitted via
60 https://github.com/bioperl/bioperl-live/issues
62 =head1 AUTHOR - Sendu Bala
68 The rest of the documentation details each of the object methods.
69 Internal methods are usually preceded with a _
73 # Let the code begin...
75 package Bio
::Matrix
::IO
::mlagan
;
79 use Bio
::Matrix
::Mlagan
;
80 use base
qw(Bio::Matrix::IO);
85 Usage : my $obj = Bio::Matrix::IO::mlagan->new();
86 Function: Builds a new Bio::Matrix::IO::mlagan object
87 Returns : an instance of Bio::Matrix::IO::mlagan
95 Usage : my $matrix = $obj->next_matrix();
96 Function: parses a matrix file
97 Returns : L<Bio::Matrix::Mlagan>
105 my (@matrix, $gap_open, $gap_cont);
106 while (defined ($_ = $self->_readline)) {
108 my (undef, @values) = split;
109 push(@matrix, \
@values);
112 ($gap_open, $gap_cont) = split;
117 @matrix == 6 || $self->throw("Something wrong with file, was it the correct format?");
119 my $matrix = Bio
::Matrix
::Mlagan
->new(-values => \
@matrix,
120 -gap_open
=> $gap_open,
121 -gap_continue
=> $gap_cont);
129 Usage : $obj->write_matrix($matrix)
130 Function: Write out a matrix in mlagan format
132 Args : L<Bio::Matrix::Generic>
137 my ($self, $matrix) = @_;
138 $matrix || $self->throw("Matrix required as input");
139 my $gap_open = $matrix->gap_open;
140 my $gap_continue = $matrix->gap_continue;
142 unless (defined $gap_open && defined $gap_continue) {
143 $self->throw("gap_open() and gap_continue() in the supplied matrix object must both be set");
146 $self->_print(" A C G T . N\n");
148 foreach my $char (qw(A C G T . N)) {
149 my @row = $matrix->get_row($char);
151 foreach my $val (@row) {
152 $row .= " " x
(5 - length($val)) . $val;
155 $self->_print($row."\n");
158 $self->_print("\n$gap_open $gap_continue");