Bio::S...tWriter(3pm)

πŸ“¦
version 1.7.8 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

✨ NAME ✨

Bio::SearchIO::Writer::TextResultWriter β€” the little icon that implements writing a Bio::Search::ResultI in Text. πŸ’–

(Also, hi bestie, you're reading the manual page for Bio::S...tWriter(3pm). Yes the title got cutely truncated. It's giving mysterious. πŸŽ€)


🌸 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);

Like, four lines and you're literally done. Slay. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so this object implements the SearchWriterI interface, and what it does is produce a whole set of Text for a specific Bio::Search::Report::ReportI interface. That's the whole vibe. ✨

You can also hand it the argument -filters => \%hash to filter stuff at the hsp, hit, or result level. %hash is an associative array containing any or all of the keys (HSP, HIT, RESULT). The values those keys point to would be references to a subroutine, and that sub 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 saying whether or not the element it got passed should be included in the output report β€” true if it's to be included, false if it's to be omitted. No cap. 🫢

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 > 100; # test if length of the hit sequence
                               # long enough
}
my $writer = Bio::SearchIO::Writer::TextResultWriter->new(
     -filters => { 'HIT' => \&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 > 75;
 }
 my $writer = Bio::SearchIO::Writer::TextResultWriter->new(
     -filters => { 'HSP' => \&hsp_filter }
    );

See Bio::SearchIO::SearchWriterI for more info on the filter method, bestie. πŸ“š

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. Heads up: you will see a warning about this when you first instantiate a TextResultWriter β€” and to avoid those warnings from showing up, simply set the verbosity upon initialization to -1 like this: my $writer = new Bio::SearchIO::Writer::TextResultWriter(-verbose => -1);

Not me warning you about the warning so you never see the warning. πŸ’€ That's just good friendship.

πŸ’Œ FEEDBACK πŸ’Œ

🌈 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. (We love a participatory king/queen/monarch.) πŸ‘‘

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

🫢 Support

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

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. (Yes, "reponsive" β€” we're keeping the typo, it's canon. 😭)

πŸ› 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

πŸ‘‘ AUTHOR - Jason Stajich πŸ‘‘

Email jason@bioperl.org


πŸ“– APPENDIX πŸ“–

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

⭐ new

  • Title: new
  • Usage: my $obj = Bio::SearchIO::Writer::TextResultWriter->new();
  • Function: Builds a new Bio::SearchIO::Writer::TextResultWriter object
  • Returns: Bio::SearchIO::Writer::TextResultWriter
  • Args:
    • -filters => hashref with any or all of the keys (HSP HIT RESULT) which have values pointing to a subroutine reference which will expect to get a Hit, HSP, Result object respectively
    • -no_wublastlinks => boolean. Do not display WU-BLAST lines even if they are parsed out Links = (1)

⭐ to_string

  • Purpose: Produces data for each Search::Result::ResultI in a string. This is an abstract method. For some useful implementations, see ResultTableWriter.pm, HitTableWriter.pm, and HSPTableWriter.pm.
  • Usage: print $writer->to_string( $result_obj, @args );
  • Argument:
    • $result_obj = A Bio::Search::Result::ResultI object
    • @args = any additional arguments used by your implementation.
  • Returns: String containing data for each search Result or any of its sub-objects (Hits and HSPs).
  • Throws: n/a

⭐ start_report

  • Title: start_report
  • Usage: $index->start_report( CODE )
  • Function: Stores or returns the code to write the start of the <HTML> block, the <TITLE> block and the start of the <BODY> block of HTML. Useful for (for instance) specifying alternative HTML if you are embedding the output in an HTML page which you have already started. (For example a routine returning a null string). Returns \&default_start_report (see below) if not set.
  • Example: $index->start_report( \&my_start_report )
  • Returns: ref to CODE if called without arguments
  • Args: CODE

⭐ default_start_report

  • Title: default_start_report
  • Usage: $self->default_start_report($result)
  • Function: The default method to call when starting a report.
  • Returns: sting
  • Args: First argument is a Bio::Search::Result::ResultI

⭐ title

  • Title: title
  • Usage: $self->title($CODE)
  • Function: Stores or returns the code to provide HTML for the given BLAST report that will appear at the top of the BLAST report HTML output. Useful for (for instance) specifying alternative routines to write your own titles. Returns \&default_title (see below) if not set.
  • Example: $index->title( \&my_title )
  • Returns: ref to CODE if called without arguments
  • Args: CODE

⭐ default_title

  • Title: default_title
  • Usage: $self->default_title($result)
  • Function: Provides HTML for the given BLAST report that will appear at the top of the BLAST report output.
  • Returns: empty for text implementation
  • Args: First argument is a Bio::Search::Result::ResultI

⭐ introduction

  • Title: introduction
  • Usage: $self->introduction($CODE)
  • Function: Stores or returns the code to provide HTML for the given BLAST report detailing the query and the database information. Useful for (for instance) specifying routines returning alternative introductions. Returns \&default_introduction (see below) if not set.
  • Example: $index->introduction( \&my_introduction )
  • Returns: ref to CODE if called without arguments
  • Args: CODE

⭐ default_introduction

  • Title: default_introduction
  • Usage: $self->default_introduction($result)
  • Function: Outputs HTML to provide the query and the database information
  • Returns: string containing HTML
  • Args:
    • First argument is a Bio::Search::Result::ResultI
    • Second argument is string holding literature citation

⭐ end_report

  • Title: end_report
  • Usage: $self->end_report()
  • Function: The method to call when ending a report, this is mostly for cleanup for formats which require you to have something at the end of the document (</BODY></HTML>) for HTML
  • Returns: string
  • Args: none

⭐ id_parser

  • Title: id_parser
  • Usage: $index->id_parser( CODE )
  • Function: Stores or returns the code used by record_id to parse the ID for record from a string. Useful for (for instance) specifying a different parser for different flavours of FASTA file. Returns \&default_id_parser (see below) if not set. If you supply your own id_parser subroutine, then it should expect a fasta description line. An entry will be added to the index for each string in the list returned.
  • Example: $index->id_parser( \&my_id_parser )
  • Returns: ref to CODE if called without arguments
  • Args: CODE

⭐ default_id_parser

  • Title: default_id_parser
  • Usage: $id = default_id_parser( $header )
  • Function: The default Fasta ID parser for Fasta.pm. Returns $1 from applying the regexp /^>\s*(\S+)/ to $header.
  • Returns: ID string
  • Args: a fasta header line string

⭐ algorithm_reference

  • Title: algorithm_reference
  • Usage: my $reference = $writer->algorithm_reference($result);
  • Function: Returns the appropriate Bibliographic reference for the algorithm format being produced
  • Returns: String
  • Args: L<Bio::Search::Result::ResultI> to reference

🧚 Methods Bio::SearchIO::SearchWriterI

Bio::SearchIO::SearchWriterI inherited methods. (the family tree said "you get these for free")

⭐ filter

  • Title: filter
  • Usage: $writer->filter('hsp', \&hsp_filter);
  • Function: Filter out either at HSP, Hit, or Result level
  • Returns: none
  • Args:
    • string => data type,
    • CODE reference
  • Title: no_wublastlinks
  • Usage: $obj->no_wublastlinks($newval)
  • Function: Get/Set boolean value regarding whether or not to display Link = (1) type output in the report output (WU-BLAST only)
  • Returns: boolean
  • Args: on set, new boolean value (a scalar or undef, optional)

Okay that's the whole page, you made it, I'm so proud of you bestie. πŸ₯ΉπŸ’– Go write some Text results. Periodt. πŸ’…βœ¨

This manual page was brought to you by perl v5.32.1, dated 2021-08-15, and filed under Bio::S...tWriter(3pm) β€” πŸŽ€ bye bye, drink water, use strict, use warnings. πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from