Bio::I...tTable(3pm)

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

πŸ’– Bio::Index::BlastTable πŸ’–

okay so bestie, welcome to Bio::Index::BlastTable β€” the Perl module (that's the 3pm manual, iykyk) that indexes tabular Blast reports (the -m 8 or -m 9 format girlies) and lets you grab stuff back out based on query accession(s). she's giving librarian energy but make it bioinformatics πŸ’…


✨ NAME ✨

Bio::Index::BlastTable β€” indexes tabular Blast reports (-m 8 or -m 9 format) and supports retrieval based on query accession(s) πŸ¦‹


🌸 SYNOPSIS 🌸

no cap, here's the whole vibe:

use strict;
use Bio::Index::BlastTable;
my ($indexfile,$file1,$file2,$query);
my $index = Bio::Index::BlastTable->new(-filename => $indexfile,
                                                        -write_flag => 1);
$index->make_index($file1,$file2);

my $data = $index->get_stream($query);

my $blast_result = $index->fetch_report($query);
print "query is ", $blast_result->query_name, "\n";
while ( my $hit = $blast_result->next_hit ) {
    print "Name ", $hit->name,"\n";
    while ( my $hsp = $hit->next_hsp ) {
        print "Score ", $hsp->score;
    }
    print "\n";
}

like. look at her go. ✨


πŸ’œ DESCRIPTION πŸ’œ

so this object lets you build an index on a tabular BLAST file (or, like, multiple files, she's flexible 🫢) and then gives you quick access to the blast report for that accession. that's the whole point, periodt.

she also lets you do ID parsing with a callback, which is honestly iconic:

$inx->id_parser(\&get_id);
# make the index
$inx->make_index($file_name);

# here is where the retrieval key is specified
sub get_id {
   my $line = shift;
   $line =~ /^>.+gi\|(\d+)/;
   $1;
}

and here's the tea πŸ“ β€” the indexer can index based on multiple IDs passed back from that callback. this is assuming, of course, that all the IDs are unique. (they gotta be unique bestie, no duplicates allowed, that's the rule πŸ™ˆ)

Note: for best results 'use strict'. fr fr, just do it.

πŸ“¬ FEEDBACK πŸ“¬

πŸ’Œ Mailing Lists

user feedback is, like, 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, genuinely πŸ₯Ή

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

πŸ«‚ Support

okay so please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

rather than to the module maintainer directly. like, no hate to the maintainer, but there are so many experienced and reponsive experts who will be able to 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 β€” the more context the better, bestie πŸ’…

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

go off, tell them everything. it's giving accountability ✨


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

Email jason-at-bioperl-dot-org


πŸŽ€ APPENDIX πŸŽ€

okay bestie, this is the part where we get into the actual lore. Every object method, every internal method (you'll spot them, they all start with _ like they're hiding from the group chat), fully explained. Buckle up πŸ’–


✨ new

  • Usage β€”
$index = Bio::Index::Abstract->new(
            -filename    => $dbm_file,
            -write_flag  => 0,
            -dbm_package => 'DB_File',
            -verbose     => 0);
  • Function β€” hands you a brand-new index object. If you passed a filename, it calls open_dbm() on the spot, no hesitation. Heads up though: you'll usually only call Bio::Index::Abstract->new() directly when you're opening an index that already exists. It's giving "I'm just here to reopen, not to build" πŸ’…
  • Returns β€” a fresh new index object, slay ✨
  • Args β€”
    • -filename β€” the name of the dbm index file.
    • -write_flag β€” TRUE if you need write access to the dbm file.
    • -dbm_package β€” the Perl dbm module to use for the index.
    • -verbose β€” print debugging output to STDERR if TRUE.

πŸ’₯ Bio::Index::Blast implemented methods

fetch_report

  • Title β€” fetch_report
  • Usage β€” my $blastreport = $idx->fetch_report($id);
  • Function β€” returns a Bio::SearchIO report object for one specific blast report. very demure, very mindful, very parsed 🧚
  • Returns β€” Bio::SearchIO
  • Args β€” a valid id

🫢 Require methods from Bio::Index::Abstract

_index_file

  • Title β€” _index_file
  • Usage β€” $index->_index_file( $file_name, $i )
  • Function β€” the specialist function that indexes BLAST report file(s). It gets handed a filename and an integer by make_index over in its SUPER class. teamwork makes the dream work 🫢
  • Example β€” (blank in the original, bestie, nothing to see)
  • Returns β€” (also blank)
  • Args β€” (still blank, it's giving minimalist)

id_parser

  • Title β€” id_parser
  • Usage β€” $index->id_parser( CODE )
  • Function β€” stores or returns the code that record_id uses to parse the ID for a record out of a string. Super useful when you want a different parser for different flavours of blast dbs. If nothing's set, it returns \&default_id_parser (that's the next one down ⬇️). And if you supply your own id_parser subroutine, it should expect a fasta description line β€” and an entry gets added to the index for each string in the list it returns.
  • Example β€” $index->id_parser( \&my_id_parser )
  • Returns β€” a ref to CODE if you call it with no arguments
  • Args β€” CODE

default_id_parser

  • Title β€” default_id_parser
  • Usage β€” $id = default_id_parser( $header )
  • Function β€” the default Blast Query ID parser for Bio::Index::Blast.pm. It returns $1 from applying the regexp /^>\s*(\S+)/ to $header. regex girlies rise πŸ™ˆ
  • Returns β€” ID string
  • Args β€” a header line string

πŸ‘‘ Bio::Index::Abstract methods

filename

  • Title β€” filename
  • Usage β€”
$value = $self->filename();
$self->filename($value);
  • Function β€” gets or sets the name of the dbm index file.
  • Returns β€” the current value of filename
  • Args β€” value of filename if you're setting it, or nothing at all if you're just getting it.

write_flag

  • Title β€” write_flag
  • Usage β€”
$value = $self->write_flag();
$self->write_flag($value);
  • Function β€” gets or sets the value of write_flag, which is literally just "should the dbm file be opened with write access or not".
  • Returns β€” the current value of write_flag (default is 0)
  • Args β€” value of write_flag if setting, or none if getting.

dbm_package

  • Usage β€”
$value = $self->dbm_package();
$self->dbm_package($value);
  • Function β€” gets or sets the name of the Perl dbm module being used. If it's unset, it returns the value of the package variable $USE_DBM_TYPE; and if that's unset too, it picks the best dbm type available, choosing 'DB_File' over 'SDBM_File'. And fyi, Bio::Abstract::Index may work with other dbm file types too β€” no promises, but maybe πŸ¦‹
  • Returns β€” the current value of dbm_package
  • Args β€” value of dbm_package if setting, or none if getting.

get_stream

  • Title β€” get_stream
  • Usage β€” $stream = $index->get_stream( $id );
  • Function β€” returns a file handle with the file pointer sitting at the appropriate place. It's the way to get the actual file contents and not an object. very raw, very unfiltered.
WARNING: you have to parse the record delimiter yourself. Abstract will not do this for you. So this code
$fh = $index->get_stream($myid);
while( <$fh> ) {
   # do something
}

will parse the entire file if you don't put a last statement in, like

while( <$fh> ) {
   /^\/\// && last; # end of record
   # do something
}
  • Returns β€” a filehandle object
  • Args β€” string representing the accession number
  • Notes β€” this method should not be used without forethought. fr fr, think before you call 🧠

open_dbm

  • Usage β€” $index->open_dbm()
  • Function β€” opens the dbm file associated with the index object. Write access is only given if it's explicitly asked for, either by calling new(-write => 1) or by having set write_flag(1) on the index object. The type of dbm file opened is whatever dbm_package() returned, and the name of the file being opened comes from calling the filename() method.
  • Example β€” $index->_open_dbm()
  • Returns β€” 1 on success

_version

  • Title β€” _version
  • Usage β€” $type = $index->_version()
  • Function β€” returns a string that identifies the version of an index module. It's used to permanently mark an index file as having been created by a particular version of the index module. Must be provided by the sub class β€” no skipping, bestie.
  • Example β€” (blank)
  • Returns β€” (blank)
  • Args β€” none

_filename

  • Title β€” _filename
  • Usage β€” $index->_filename( FILE INT )
  • Function β€” indexes the file
  • Example β€” (blank)
  • Returns β€” (blank)
  • Args β€” (blank)

_file_handle

  • Title β€” _file_handle
  • Usage β€” $fh = $index->_file_handle( INT )
  • Function β€” returns an open filehandle for the file index INT. When it opens a new filehandle it caches it in the @{$index->_filehandle} array, and if the filehandle you asked for is already open, it just returns it straight out of the array. efficient queen πŸ‘‘
  • Example β€” $fist_file_indexed = $index->_file_handle( 0 );
  • Returns β€” ref to a filehandle
  • Args β€” INT

_file_count

  • Title β€” _file_count
  • Usage β€” $index->_file_count( INT )
  • Function β€” used by the index building sub in a sub class to keep track of how many files have been indexed. Sets or gets the number of files indexed depending on whether you call it with or without an argument.
  • Example β€” (blank)
  • Returns β€” INT
  • Args β€” INT

add_record

  • Title β€” add_record
  • Usage β€” $index->add_record( $id, @stuff );
  • Function β€” calls pack_record on @stuff, then adds the result of pack_record to the index database under the key $id. And if $id is a reference to an array, then a new entry gets added under a key corresponding to each element of that array. one id, many keys, the way that it just multiplies ✨
  • Example β€” $index->add_record( $id, $fileNumber, $begin, $end )
  • Returns β€” TRUE on success or FALSE on failure
  • Args β€” ID LIST

pack_record

  • Title β€” pack_record
  • Usage β€” $packed_string = $index->pack_record( LIST )
  • Function β€” packs an array of scalars into a single string joined by ASCII 034 (which is unlikely to ever show up in any of the strings), and returns it.
  • Example β€” $packed_string = $index->pack_record( $fileNumber, $begin, $end )
  • Returns β€” STRING or undef
  • Args β€” LIST

unpack_record

  • Title β€” unpack_record
  • Usage β€” $index->unpack_record( STRING )
  • Function β€” splits the string you gave it into an array, splitting on ASCII 034.
  • Example β€” ( $fileNumber, $begin, $end ) = $index->unpack_record( $self->db->{$id} )
  • Returns β€” a 3 element ARRAY
  • Args β€” STRING containing ASCII 034

DESTROY

  • Title β€” DESTROY
  • Usage β€” called automatically when the index goes out of scope
  • Function β€” closes the connection to the database and the handles to the sequence files. it's the goodbye hug πŸ€—
  • Returns β€” NEVER (like, literally never, don't wait around for it)
  • Args β€” NONE

okay that's the whole page, bestie, you're officially fluent πŸ’– this one was written by Jason Stajich, and it came from Perl v5.32.1 on 2021-08-15 β€” yes it's a little vintage, but vintage is just iconic with a longer track record πŸ‘‘βœ¨ go forth and index something πŸ¦‹

πŸ“¦ where this page comes from