BioPerl

 view release on metacpan or  search on metacpan

Bio/SearchIO/Writer/TextResultWriter.pm  view on Meta::CPAN

#
# BioPerl module for Bio::SearchIO::Writer::TextResultWriter
#
# Please direct questions and support issues to <bioperl-l@bioperl.org> 
#
# Cared for by Jason Stajich <jason@bioperl.org>
#
# Copyright Jason Stajich
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

Bio::SearchIO::Writer::TextResultWriter - Object to implement writing
a Bio::Search::ResultI in Text.

=head1 SYNOPSIS

  use Bio::SearchIO;
  use Bio::SearchIO::Writer::TextResultWriter;

  my $in = Bio::SearchIO->new(-format => 'blast',
			     -file   => shift @ARGV);

  my $writer = Bio::SearchIO::Writer::TextResultWriter->new();
  my $out = Bio::SearchIO->new(-writer => $writer);
  $out->write_result($in->next_result);

=head1 DESCRIPTION

This object implements the SearchWriterI interface which will produce
a set of Text for a specific Bio::Search::Report::ReportI interface.

You can also provide the argument -filters =E<gt> \%hash to filter the at
the hsp, hit, or result level.  %hash is an associative array which
contains any or all of the keys (HSP, HIT, RESULT).  The values
pointed to by these keys would be references to a subroutine which
expects to be passed an object - one of Bio::Search::HSP::HSPI,
Bio::Search::Hit::HitI, and Bio::Search::Result::ResultI respectively.
Each function needs to return a boolean value as to whether or not the
passed element should be included in the output report - true if it is
to be included, false if it to be omitted.

For example to filter on sequences in the database which are too short
for your criteria you would do the following.

Define a hit filter method 

  sub hit_filter { 
      my $hit = shift;
      return $hit->length E<gt> 100; # test if length of the hit sequence
                                     # long enough    
  }
  my $writer = Bio::SearchIO::Writer::TextResultWriter->new(
       -filters => { 'HIT' =E<gt> \&hit_filter }  
      );

Another example would be to filter HSPs on percent identity, let's
only include HSPs which are 75% identical or better.

   sub hsp_filter {
       my $hsp = shift;
       return $hsp->percent_identity E<gt> 75;
   }
   my $writer = Bio::SearchIO::Writer::TextResultWriter->new(
       -filters => { 'HSP' =E<gt> \&hsp_filter }  
      );

See L<Bio::SearchIO::SearchWriterI> for more info on the filter method.


This module will use the module Text::Wrap if it is installed to wrap
the Query description line.  If you do not have Text::Wrap installed
this module will work fine but you won't have the Query line wrapped.
You will see a warning about this when you first instantiate a
TextResultWriter - to avoid these warnings from showing up, simply set
the verbosity upon initialization to -1 like this: my $writer = new
Bio::SearchIO::Writer::TextResultWriter(-verbose =E<gt> -1);

=head1 FEEDBACK

=head2 Mailing Lists

User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list.  Your participation is much appreciated.

  bioperl-l@bioperl.org                  - General discussion
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

=head2 Support 

Please direct usage questions or support issues to the mailing list:

I<bioperl-l@bioperl.org>

rather than to the module maintainer directly. Many experienced and 
reponsive experts will be able look at the problem and quickly 
address it. Please include a thorough description of the problem 
with code and data examples if at all possible.

=head2 Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via the
web:

  https://github.com/bioperl/bioperl-live/issues

=head1 AUTHOR - Jason Stajich

Email jason@bioperl.org

=head1 APPENDIX

The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _

=cut


# Let the code begin...



( run in 1.041 second using v1.01-cache-2.11-cpan-39bf76dae61 )