Bio::T...stPlus(3pm)
π Bio::Tools::Run::StandAloneBlastPlus π
okay bestie, so this is a page from User Contributed Perl Documentation, and the module we're fangirling over is Bio::T...stPlus(3pm) β yes the name got abbreviated all cute, but the real one is right there in a sec. πΈ
β¨ NAME β¨
Bio::Tools::Run::StandAloneBlastPlus β it's giving "compute with NCBI's blast+ suite" energy. Oh and heads up: it's marked ALPHA, so we're all early adopters here, no cap. π
π¦ SYNOPSIS π¦
okay so real talk first: this module is only related to Bio::Tools::Run::StandAloneBlast in name (and inspiration). That's it. You must use this module directly, no sneaky indirect vibes. π
Here's the whole mood board, literally the entire thing:
# existing blastdb:
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'mydb'
);
# create blastdb from fasta file and attach
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'mydb',
-db_data => 'myseqs.fas',
-create => 1
);
# create blastdb from BioPerl sequence collection objects
$alnio = Bio::AlignIO->new( -file => 'alignment.msf' );
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'mydb',
-db_data => $alnio,
-create => 1
);
@seqs = $alnio->next_aln->each_seq;
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'mydb',
-db_data => \@seqs,
-create => 1
);
# create database with masks
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'my_masked_db',
-db_data => 'myseqs.fas',
-masker => 'dustmasker',
-mask_data => 'maskseqs.fas',
-create => 1
);
# create a mask datafile separately
$mask_file = $fac->make_mask(
-data => 'maskseqs.fas',
-masker => 'dustmasker'
);
# query database for metadata
$info_hash = $fac->db_info;
$num_seq = $fac->db_num_sequences;
@mask_metadata = @{ $fac->db_filter_algorithms };
# perform blast methods
$result = $fac->tblastn( -query => $seqio );
# see Bio::Tools::Run::StandAloneBlastPlus::BlastMethods
# for many more details
likeβ¦ the range?? we got db creation, masking, metadata querying, AND actual blast runs in one file. main character energy fr fr. π₯
π DESCRIPTION π
π lowkey important: this module needs BLAST+ v. 2.2.24+ and higher. and until the API stabilizes for BLAST+, justβ¦ consider this module highly experimental. we're in our beta era, bestie. π
So here's the tea. This module, along with its bestie Bio::Tools::Run::StandAloneBlastPlus::BlastMethods, lets you run BLAST functions using the external program suite "blast+" β which lives at:
ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/
and it does all of that using BioPerl objects and Bio::SearchIO facilities. iconic. β¨
This wrapper can:
- prepare BLAST databases ποΈ
- run BLAST searches π
- run "blast+" programs independently πβοΈ
Basically it encapsulates object construction plus production of databases and masks. The actual blast analysis methods (blastp, psiblast, etc>) β yeah that stray > is in the original, we keep it exactly, no edits β live over in Bio::Tools::Run::StandAloneBlastPlus::BlastMethods. go check that one for the real fun. π
(more coming, don't go anywhere β this is only part 1 of 3 π )
π USAGE π
okay bestie, here's the whole vibe in two steps and honestly that's it:
- make a BlastPlus factory with the
new()constructor - run your BLAST analyses by calling the BLAST program you want by name, right off that factory object
The blast database itself + any masking data get attached to the factory (that's step 1). Your query sequences + any parameters that belong to a particular program go into the blast method call (that's step 2), and they get run against the database you already attached. π
π Factory construction/initialization π
The factory needs to know where your blast+ programs live. The BLASTPLUSDIR environment variable is checked for the default executable directory. You can set the program directory for individual factory instances with the PROG_DIR parameter. All the blast+ programs have to be reachable from that directory β as executable files or symlinks, either one is fine. π
Either the database or the BLAST subject data must be specified at object construction. Databases can be pre-existing formatted BLAST dbs, or built straight from fasta sequence files or BioPerl sequence object collections of several kinds. The key constructor parameters are DB_NAME, DB_DATA, DB_DIR.
To specify a pre-existing BLAST database, use DB_NAME on its own:
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-DB_NAME => 'mydb'
);
The directory can go in along with the basename, or you can pass it separately with DB_DIR:
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-DB_NAME => '~/home/blast/mydb'
);
#same as
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-DB_NAME => 'mydb', -DB_DIR => '~/home/blast'
);
Wanna create a BLAST database de novo? skip on down to "Creating a BLAST database" π¦
If you want to apply pre-existing mask data (like, the final ASN1 output from one of the blast+ masker programs) to the database before you query it, say so with MASK_FILE:
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-DB_NAME => 'mydb', -MASK_FILE => 'mymaskdata.asn'
);
πΈ Creating a BLAST database πΈ
There are several options for creating the database de novo out of attached data β both before and after factory construction. If you want a temporary database (one that cleanup() can delete), just leave out the -db_name parameter. If you do specify -db_name, the database gets preserved under the basename you gave it. π«Ά
Use -create => 1 to create a new database (otherwise the factory will go looking for an existing one). Use -overwrite => 1 to create and overwrite an existing database.
heads up bestie: the database is not created immediately on factory construction. It gets created if necessary on the first use of a factory BLAST method β or you can force database creation yourself by executing
$fac->make_db();
- Specify data during construction
With a FASTA file:
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'mydb',
-db_data => 'myseqs.fas',
-create => 1
);
With another BioPerl object collection:
$alnio = Bio::AlignIO->new( -file => 'alignment.msf' );
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'mydb',
-db_data => $alnio,
-create => 1
);
@seqs = $alnio->next_aln->each_seq;
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'mydb',
-db_data => \@seqs,
-create => 1
);
Other collections (e.g., Bio::SeqIO) are valid too. If a certain type does not work, please submit an enhancement request. π
To create temporary databases, leave out the -db_name, e.g.
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_data => 'myseqs.fas',
-create => 1
);
To get the tempfile basename, do:
$dbname = $fac->db;
- Specify data post-construction
Use the explicit attribute setters:
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-create => 1
);
$fac->set_db_data('myseqs.fas');
$fac->make_db;
π Creating and using mask data π
The blast+ mask utilities windowmasker, segmasker, and dustmasker are all available to you. Masking can be rolled right into database creation, or run later. If your mask data is already made and sitting in ASN1 format, set the -mask_file attribute at construction (peep "Factory constuction/initialization").
To create a mask from raw data or an existing database and apply that mask on database creation, build the factory like so:
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'my_masked_db',
-db_data => 'myseqs.fas',
-masker => 'dustmasker',
-mask_data => 'maskseqs.fas',
-create => 1
);
The masked database gets created during make_db.
The -mask_data parameter can be a FASTA filename or any BioPerl sequence object collection. If the datatype ('nucl' or 'prot') of the mask data isn't compatible with the masker you picked, an exception gets thrown with a message saying exactly that. π
To create a mask ASN1 file you can use in the -mask_file parameter separately from the attached database, call the make_mask() method directly:
$mask_file = $fac->make_mask(-data => 'maskseqs.fas',
-masker => 'dustmasker');
# segmasker can use a blastdb as input
$mask_file = $fac->make_mask(-mask_db => 'mydb',
-masker => 'segmasker')
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'my_masked_db',
-db_data => 'myseqs.fas',
-mask_file => $mask_file
-create => 1
);
β Getting database information β
To get a hash holding useful metadata on an existing database (the kind you get by running blastdbcmd -info), use db_info():
# get info on the attached database..
$info = $fac->db_info;
# get info on another database
$info = $fac->db_info('~/home/blastdbs/another');
To grab one particular info element for the attached database, just call the element name off the factory:
$num_seqs = $fac->db_num_sequences;
# info on all the masks applied to the db, if any:
@masking_info = @{ $fac->db_filter_algorithms };
π¦ Accessing the Bio::Tools::Run::BlastPlus factory π¦
The blast+ programs are actually executed by a Bio::Tools::Run::BlastPlus wrapper instance. That instance is right there for peeking and poking in the StandAloneBlastPlus factory() attribute. And for convenience, BlastPlus methods can be run from the StandAloneBlastPlus object too β they're delegated to the factory() attribute. Like, to see which blast+ program is going to be executed, check either
$fac->factory->command
or
$fac->command
Same energy, the current parameters for the BlastPlus factory are:
@parameters = $fac->get_parameters
π§ Cleaning up temp files π§
Temporary analysis files produced under a single factory instance can be unlinked by running
$fac->cleanup;
Tempfiles generally are not removed unless you explicitly call that method. cleanup() only unlinks "registered" files and databases. All temporary files are automatically registered β and in particular, "anonymous" databases (such as
$fac->Bio::Tools::Run::StandAloneBlastPlus->new(
-db_data => 'myseqs.fas',
-create => 1
);
with no -db_name specification) are registered for cleanup. Any file or database can be registered with an internal method:
$fac->_register_temp_for_cleanup('testdb');
π Other Goodies π
- You can check whether a given basename points to a properly formatted BLAST database by doing
$is_good = $fac->check_db('putative_db');
- User parameters can be passed to the underlying blast+ programs (if you know what you're doing π) with
db_make_argsandmask_make_args:
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
-db_name => 'customdb',
-db_data => 'myseqs.fas',
-db_make_args => [ '-taxid_map' => 'seq_to_taxa.txt' ],
-masker => 'windowmasker',
-mask_data => 'myseqs.fas',
-mask_make_args => [ '-dust' => 'T' ],
-create => 1
);
- You can stop exceptions from being thrown by failed blast+ program executions by setting
no_throw_on_crash. Then examine the error withstderr():
$fac->no_throw_on_crash(1);
$fac->make_db;
if ($fac->stderr =~ /Error:/) {
#handle error
...
}
β¨ SEE ALSO β¨
Bio::Tools::Run::StandAloneBlastPlus::BlastMethods, Bio::Tools::Run::BlastPlus
π 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. π«Ά
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 responsive 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.
π 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:
http://redmine.open-bio.org/projects/bioperl/
π AUTHOR - Mark A. Jensen π
Email maj -at- fortinbras -dot- us
π CONTRIBUTORS π
(no names listed in the original β this section is empty, bestie, no cap)
π APPENDIX π
okay bestie, here's the deep lore π The rest of the docs break down every single object method one by one. And heads up: methods that are ~internal~ usually start with an underscore _, iykyk π«Ά
β¨ new β¨
- Title β
new - Usage β
my $obj = new Bio::Tools::Run::StandAloneBlastPlus();
- Function β builds a brand new
Bio::Tools::Run::StandAloneBlastPlusobject, main character energy fr - Returns β an instance of
Bio::Tools::Run::StandAloneBlastPlusπ - Args β named argument (key => value) pairs:
-db: blastdb name
πΈ db() πΈ
- Title β
db - Usage β
$obj->db($newval) - Function β holds the basename of the local blast database
- Example β
- Returns β value of
db(a scalar string) - Args β readonly π«βοΈ
π¦ factory() π¦
- Title β
factory - Usage β
$obj->factory($newval) - Function β attribute containing the
Bio::Tools::Run::BlastPlusfactory - Example β
- Returns β value of
factory(aBio::Tools::Run::BlastPlusobject) - Args β readonly
β program_version() β
- Title β
program_version - Usage β
$version = $bedtools_fac->program_version() - Function β returns the program version (if available, no promises bestie)
- Returns β string representing location and version of the program
- Note β this works around the
WrapperBase::version()method conflicting with the-versionparameter for SABlast (good argument for not having getter/setters for these)
π package_version() π
- Title β
package_version - Usage β
$version = $bedtools_fac->package_version() - Function β returns the BLAST+ package version (if available)
- Returns β string representing BLAST+ package version (may differ from
version()) π
π DB methods π
π make_db() π
- Title β
make_db - Usage β
- Function β create the blast database (if necessary), imposing masking if specified
- Returns β true on success
- Args β
π make_mask() π
- Title β
make_mask - Usage β
- Function β create masking data based on specified parameters
- Returns β mask data filename (scalar string)
- Args β
β¨ db_info() β¨
- Title β
db_info - Usage β
- Function β get info for database (via
blastdbcmd -info); add factory attributes - Returns β hash of database attributes
- Args β [optional] db name (scalar string) (default: currently attached db)
π§ set_db_make_args() π§
- Title β
set_db_make_args - Usage β
- Function β set the DB make arguments attribute with checking π
- Returns β true on success
- Args β arrayref or hashref of named arguments
πΈ set_mask_make_args() πΈ
- Title β
set_mask_make_args - Usage β
- Function β set the masker make arguments attribute with checking
- Returns β true on success
- Args β arrayref or hasref of named arguments
π check_db() π
- Title β
check_db - Usage β
- Function β determine if database with registered name and dir exists
- Returns β
1if db present,0if not present, undef if name/dir not set - Args β
- [optional] db name (default is 'registered' name in
$self->db) - [optional] db directory (default is 'registered' dir in
$self->db_dir)
- [optional] db name (default is 'registered' name in
π₯ no_throw_on_crash() π₯
- Title β
no_throw_on_crash - Usage β
$fac->no_throw_on_crash($newval) - Function β set to prevent an exeception throw on a failed blast program execution
- Example β
- Returns β value of
no_throw_on_crash(boolean) - Args β on set, new value (boolean)
π«Ά Internals π«Ά
bestie these are the backstage crew, don't touch unless you know what you're doing π
π¦ _fastize() π¦
- Title β
_fastize - Usage β
- Function β convert a sequence collection to a temporary fasta file (sans gaps)
- Returns β fasta filename (scalar string)
- Args β sequence collection
π _register_temp_for_cleanup() π
- Title β
_register_temp_for_cleanup - Usage β
- Function β register a file for cleanup with
cleanup()method - Returns β true on success
- Args β a file name or a blastdb basename (scalar string)
π cleanup() π
- Title β
cleanup - Usage β
- Function β unlink files registered for cleanup
- Returns β true on success
- Args β
π AUTOLOAD π
In this module, "AUTOLOAD()" delegates Bio::Tools::Run::WrapperBase and Bio::Tools::Run::WrapperBase::CommandExts methods (including those of Bio::ParamterBaseI) to the "factory()" attribute:
$fac->stderr
gives you
$fac->factory->stderr
If $AUTOLOAD isn't pointing to a WrapperBase method, then AUTOLOAD attempts to return a "db_info" attribute: e.g.
$fac->db_num_sequences
works by looking in the $fac->db_info() hash. πͺ
Finally, if $AUTOLOAD is pointing to a blast query method, AUTOLOAD runs "run" with the "-method" parameter appropriately set. slay β¨
aaaand that's the whole page bestie, we ate and left no crumbs π
β¨ this one's perl v5.36.0, dated 2023-01-22, and it's the Bio::T...stPlus(3pm) page β go forth and blast, mwah ππΈπ¦
π¦ where this page comes from
- debian bookworm: libbio-perl-run-perl 1.7.3-9 Β· Perl
- ubuntu noble: libbio-perl-run-perl 1.7.3-9 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms