2 # BioPerl module for Bio::AlignIO::bl2seq
4 # based on the Bio::SeqIO modules
5 # by Ewan Birney <birney@ebi.ac.uk>
6 # and Lincoln Stein <lstein@cshl.org>
8 # the Bio::Tools::BPlite modules by
9 # Ian Korf (ifkorf at ucdavis.edu, http://www.bioperl.org/wiki/Ian_Korf),
10 # Lorenz Pollak (lorenz@ist.org, bioperl port)
12 # and the SimpleAlign.pm module of Ewan Birney
14 # Copyright Peter Schattner
16 # You may distribute this module under the same terms as perl itself
19 # POD documentation - main docs before the code
23 Bio::AlignIO::bl2seq - bl2seq sequence input/output stream
27 Do not use this module directly. Use it via the L<Bio::AlignIO> class, as in:
31 $in = Bio::AlignIO->new(-file => "inputfilename" ,
33 -report_type => "blastn");
34 $aln = $in->next_aln();
39 This object can create L<Bio::SimpleAlign> sequence alignment objects (of
40 two sequences) from C<bl2seq> BLAST reports.
42 A nice feature of this module is that - in combination with
43 L<Bio::Tools::Run::StandAloneBlast.pm> or a remote BLAST - it can be used to
44 align two sequences and make a L<Bio::SimpleAlign> object from them which
45 can then be manipulated using any L<Bio::SimpleAlign> methods, eg:
48 $str = Bio::SeqIO->new(-file=>'t/amino.fa' , '-format' => 'Fasta', );
49 my $seq3 = $str->next_seq();
50 my $seq4 = $str->next_seq();
53 $factory = Bio::Tools::StandAloneBlast->new('program' => 'blastp',
54 'outfile' => 'bl2seq.out');
55 my $bl2seq_report = $factory->bl2seq($seq3, $seq4);
56 # Note that report is a Bio::SearchIO object
58 # Use AlignIO.pm to create a SimpleAlign object from the bl2seq report
59 $str = Bio::AlignIO->new(-file=> 'bl2seq.out','-format' => 'bl2seq');
60 $aln = $str->next_aln();
66 User feedback is an integral part of the evolution of this and other
67 Bioperl modules. Send your comments and suggestions preferably to one
68 of the Bioperl mailing lists. Your participation is much appreciated.
70 bioperl-l@bioperl.org - General discussion
71 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
75 Please direct usage questions or support issues to the mailing list:
77 I<bioperl-l@bioperl.org>
79 rather than to the module maintainer directly. Many experienced and
80 reponsive experts will be able look at the problem and quickly
81 address it. Please include a thorough description of the problem
82 with code and data examples if at all possible.
86 Report bugs to the Bioperl bug tracking system to help us keep track
87 the bugs and their resolution. Bug reports can be submitted via the
90 https://github.com/bioperl/bioperl-live/issues
92 =head1 AUTHOR - Peter Schattner
94 Email: schattner@alum.mit.edu
98 The rest of the documentation details each of the object
99 methods. Internal methods are usually preceded with a _
103 # Let the code begin...
105 package Bio
::AlignIO
::bl2seq
;
110 use base
qw(Bio::AlignIO);
115 Usage : my $alignio = Bio::SimpleAlign->new(-format => 'bl2seq',
117 -report_type => 'blastx');
118 Function: Get a L<Bio::SimpleAlign>
119 Returns : L<Bio::SimpleAlign> object
120 Args : -report_type => report type (blastn,blastx,tblastx,tblastn,blastp)
125 my ($self, @args) = @_;
126 $self->SUPER::_initialize
(@args);
127 my ($rt) = $self->_rearrange([qw(REPORT_TYPE)],@args);
128 defined $rt && $self->report_type($rt);
134 Usage : $aln = $stream->next_aln()
135 Function: returns the next alignment in the stream.
136 Returns : L<Bio::Align::AlignI> object on success,
137 undef on error or end of file
144 unless (exists $self->{'_searchio'}) {
145 $self->{'_searchio'} = Bio
::SearchIO
->new(-fh
=> $self->_fh,
147 -report_type
=> $self->report_type);
150 if (!exists $self->{'_result'}) {
151 $self->{'_result'} = $self->{'_searchio'}->next_result;
153 return if !defined $self->{'_result'};
154 if (!exists $self->{'_hit'}) {
155 $self->{'_hit'} = $self->{'_result'}->next_hit;
157 # out of hits for this result?
158 if (!defined $self->{'_hit'}) {
159 delete $self->{'_result'};
162 my $hsp = $self->{'_hit'}->next_hsp;
163 # out of hsps for this hit?
165 delete $self->{'_hit'};
168 $hsp ?
return $hsp->get_aln: return;
173 =head2 write_aln (NOT IMPLEMENTED)
176 Usage : $stream->write_aln(@aln)
177 Function: writes the $aln object into the stream in bl2seq format
178 Returns : 1 for success and 0 for error
179 Args : L<Bio::Align::AlignI> object
185 my ($self,@aln) = @_;
186 $self->throw_not_implemented();
192 Usage : $obj->report_type($newval)
193 Function: Sets the report type (blastn, blastp...)
194 Returns : value of report_type (a scalar)
195 Args : on set, new value (a scalar or undef, optional)
202 return $self->{'report_type'} = shift if @_;
203 return $self->{'report_type'};