Bio::I...tTable(3pm)
π 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 callBio::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 toSTDERRif TRUE.
π₯ Bio::Index::Blast implemented methods
fetch_report
- Title β
fetch_report - Usage β
my $blastreport = $idx->fetch_report($id); - Function β returns a
Bio::SearchIOreport 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_indexover 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_iduses 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
CODEif 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$1from 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
filenameif 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 is0) - Args β value of
write_flagif 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::Indexmay work with other dbm file types too β no promises, but maybe π¦ - Returns β the current value of
dbm_package - Args β value of
dbm_packageif 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 setwrite_flag(1)on the index object. The type of dbm file opened is whateverdbm_package()returned, and the name of the file being opened comes from calling thefilename()method. - Example β
$index->_open_dbm() - Returns β
1on 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_recordon@stuff, then adds the result ofpack_recordto the index database under the key$id. And if$idis 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 β
STRINGor 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 β
STRINGcontaining 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
- debian bookworm: libbio-perl-perl 1.7.8-1 Β· Perl
- debian trixie: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu jammy: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu noble: libbio-perl-perl 1.7.8-1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms