3 # BioPerl module for Bio::AlignIO::bl2seq
5 # based on the Bio::SeqIO modules
6 # by Ewan Birney <birney@ebi.ac.uk>
7 # and Lincoln Stein <lstein@cshl.org>
9 # the Bio::Tools::BPlite modules by
10 # Ian Korf (ikorf@sapiens.wustl.edu, http://sapiens.wustl.edu/~ikorf),
11 # Lorenz Pollak (lorenz@ist.org, bioperl port)
13 # and the SimpleAlign.pm module of Ewan Birney
15 # Copyright Peter Schattner
17 # You may distribute this module under the same terms as perl itself
20 # POD documentation - main docs before the code
24 Bio::AlignIO::bl2seq - bl2seq sequence input/output stream
28 Do not use this module directly. Use it via the L<Bio::AlignIO> class, as in:
32 $in = Bio::AlignIO->new(-file => "inputfilename" ,
34 -report_type => "blastn");
35 $aln = $in->next_aln();
40 This object can create L<Bio::SimpleAlign> sequence alignment objects (of
41 two sequences) from C<bl2seq> BLAST reports.
43 A nice feature of this module is that - in combination with
44 L<Bio::Tools::Run::StandAloneBlast.pm> or a remote BLAST - it can be used to
45 align two sequences and make a L<Bio::SimpleAlign> object from them which
46 can then be manipulated using any L<Bio::SimpleAlign> methods, eg:
49 $str = Bio::SeqIO->new(-file=>'t/amino.fa' , '-format' => 'Fasta', );
50 my $seq3 = $str->next_seq();
51 my $seq4 = $str->next_seq();
54 $factory = Bio::Tools::StandAloneBlast->new('program' => 'blastp',
55 'outfile' => 'bl2seq.out');
56 my $bl2seq_report = $factory->bl2seq($seq3, $seq4);
57 # Note that report is a Bio::SearchIO object
59 # Use AlignIO.pm to create a SimpleAlign object from the bl2seq report
60 $str = Bio::AlignIO->new(-file=> 'bl2seq.out','-format' => 'bl2seq');
61 $aln = $str->next_aln();
67 User feedback is an integral part of the evolution of this and other
68 Bioperl modules. Send your comments and suggestions preferably to one
69 of the Bioperl mailing lists. Your participation is much appreciated.
71 bioperl-l@bioperl.org - General discussion
72 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
76 Please direct usage questions or support issues to the mailing list:
78 L<bioperl-l@bioperl.org>
80 rather than to the module maintainer directly. Many experienced and
81 reponsive experts will be able look at the problem and quickly
82 address it. Please include a thorough description of the problem
83 with code and data examples if at all possible.
87 Report bugs to the Bioperl bug tracking system to help us keep track
88 the bugs and their resolution. Bug reports can be submitted via the
91 http://bugzilla.open-bio.org/
93 =head1 AUTHOR - Peter Schattner
95 Email: schattner@alum.mit.edu
99 The rest of the documentation details each of the object
100 methods. Internal methods are usually preceded with a _
104 # Let the code begin...
106 package Bio
::AlignIO
::bl2seq
;
111 use base
qw(Bio::AlignIO);
116 Usage : my $alignio = Bio::SimpleAlign->new(-format => 'bl2seq',
118 -report_type => 'blastx');
119 Function: Get a L<Bio::SimpleAlign>
120 Returns : L<Bio::SimpleAlign> object
121 Args : -report_type => report type (blastn,blastx,tblastx,tblastn,blastp)
126 my ($self, @args) = @_;
127 $self->SUPER::_initialize
(@args);
128 my ($rt) = $self->_rearrange([qw(REPORT_TYPE)],@args);
129 defined $rt && $self->report_type($rt);
135 Usage : $aln = $stream->next_aln()
136 Function: returns the next alignment in the stream.
137 Returns : L<Bio::Align::AlignI> object on success,
138 undef on error or end of file
145 unless (exists $self->{'_searchio'}) {
146 $self->{'_searchio'} = Bio
::SearchIO
->new(-fh
=> $self->_fh,
148 -report_type
=> $self->report_type);
151 if (!exists $self->{'_result'}) {
152 $self->{'_result'} = $self->{'_searchio'}->next_result;
154 return if !defined $self->{'_result'};
155 if (!exists $self->{'_hit'}) {
156 $self->{'_hit'} = $self->{'_result'}->next_hit;
158 # out of hits for this result?
159 if (!defined $self->{'_hit'}) {
160 delete $self->{'_result'};
163 my $hsp = $self->{'_hit'}->next_hsp;
164 # out of hsps for this hit?
166 delete $self->{'_hit'};
169 $hsp ?
return $hsp->get_aln: return;
174 =head2 write_aln (NOT IMPLEMENTED)
177 Usage : $stream->write_aln(@aln)
178 Function: writes the $aln object into the stream in bl2seq format
179 Returns : 1 for success and 0 for error
180 Args : L<Bio::Align::AlignI> object
186 my ($self,@aln) = @_;
187 $self->throw_not_implemented();
193 Usage : $obj->report_type($newval)
194 Function: Sets the report type (blastn, blastp...)
195 Returns : value of report_type (a scalar)
196 Args : on set, new value (a scalar or undef, optional)
203 return $self->{'report_type'} = shift if @_;
204 return $self->{'report_type'};