1 #---------------------------------------------------------
6 Bio::Matrix::PSM::IO::psiblast - PSM psiblast parser
10 See Bio::Matrix::PSM::IO for documentation
14 Parser for ASCII matrices from PSI-BLAST (blastpgp program in
21 User feedback is an integral part of the evolution of this and other
22 Bioperl modules. Send your comments and suggestions preferably to one
23 of the Bioperl mailing lists. Your participation is much appreciated.
25 bioperl-l@bioperl.org - General discussion
26 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
30 Please direct usage questions or support issues to the mailing list:
32 I<bioperl-l@bioperl.org>
34 rather than to the module maintainer directly. Many experienced and
35 reponsive experts will be able look at the problem and quickly
36 address it. Please include a thorough description of the problem
37 with code and data examples if at all possible.
41 Report bugs to the Bioperl bug tracking system to help us keep track
42 the bugs and their resolution. Bug reports can be submitted via the
45 http://bugzilla.open-bio.org/
47 =head1 AUTHOR - James Thompson
49 Email tex@biosysadmin.com
56 # Let the code begin...
57 package Bio
::Matrix
::PSM
::IO
::psiblast
;
58 use Bio
::Matrix
::PSM
::Psm
;
59 use Bio
::Matrix
::PSM
::ProtMatrix
;
62 use base
qw(Bio::Matrix::PSM::PsmHeader Bio::Matrix::PSM::IO);
64 # define the order in which amino acids are listed in the psiblast matrix file
65 our @ordered_alphabet = qw
/A R N D C Q E G H I L K M F P S T W Y V/;
70 Usage : my $psmIO = Bio::Matrix::PSM::IO->new(-format=>'psiblast',
72 Function: Associates a file with the appropriate parser
76 Returns : Bio::Matrix::PSM::ProtMatrix->new(@args);
84 my $self = $class->SUPER::new
(@args);
85 my ($file) = $self->_rearrange(['FILE'], @args);
86 $self->_initialize_io(@args) || warn "Did you intend to use STDIN?"; # Read only for now
89 $self->{_ordered_alphabet
} = \
@ordered_alphabet;
96 Usage : my $psm = $psmIO->next_psm();
97 Function: Reads the next PSM from the input file, associated with this object
99 Returns : Bio::Matrix::PSM::ProtPsm object
108 return if ($self->{_end
});
111 my @ordered_alphabet = @
{$self->{_ordered_alphabet
}};
113 while ( defined( $line = $self->_readline) ) {
114 # remove leading and trailing whitespace
119 if ( $line =~ /^(\d+)\s+(\w{1})/ ) { # match reference aa and position number
120 my @elements = split /\s+/, $line;
122 my $position = shift @elements;
123 my $letter = shift @elements;
125 my $ratio = pop @elements;
126 my $ic = pop @elements;
128 # put the next 20 elements into the correct array in %args
129 for ( 0 .. 19 ) { push @
{$args{'l'.$ordered_alphabet[$_]}}, shift @elements; }
130 for ( 0 .. 19 ) { push @
{$args{'p'.$ordered_alphabet[$_]}}, shift @elements; }
132 push @
{$args{'ic'}}, $ic;
136 $self->{_end
} = 1; # psiblast matrix files currently only hold one PSM per file
138 my $psm = Bio
::Matrix
::PSM
::ProtMatrix
->new( %args );