Bio::D...eleydb(3pm)
Bio::DB::SeqFeature::Store::berkeleydb π
okay so bestie, welcome to the User Contributed Perl Documentation for this one β it's Bio::DB::SeqFeature::Store::berkeleydb, aka the berkeleydb storage + retrieval situation for sequence annotation data, living in Berkeleydb files. let's get into it π¦
β¨ NAME β¨
Bio::DB::SeqFeature::Store::berkeleydb β Storage and retrieval of sequence annotation data in Berkeleydb files π
πΈ SYNOPSIS πΈ
use Bio::DB::SeqFeature::Store;
# Create a database from the feature files located in /home/fly4.3 and store
# the database index in the same directory:
my $db = Bio::DB::SeqFeature::Store->new( -adaptor => 'berkeleydb',
-dir => '/home/fly4.3');
# Create a database that will monitor the files in /home/fly4.3, but store
# the indexes in /var/databases/fly4.3
$db = Bio::DB::SeqFeature::Store->new( -adaptor => 'berkeleydb',
-dir => '/home/fly4.3',
-dsn => '/var/databases/fly4.3');
# Create a feature database from scratch
$db = Bio::DB::SeqFeature::Store->new( -adaptor => 'berkeleydb',
-dsn => '/var/databases/fly4.3',
-create => 1);
# get a feature from somewhere
my $feature = Bio::SeqFeature::Generic->new(...);
# store it
$db->store($feature) or die "Couldn't store!";
# primary ID of the feature is changed to indicate its primary ID
# in the database...
my $id = $feature->primary_id;
# get the feature back out
my $f = $db->fetch($id);
# change the feature and update it
$f->start(100);
$db->update($f) or $self->throw("Couldn't update!");
# use the GFF3 loader to do a bulk write:
my $loader = Bio::DB::SeqFeature::Store::GFF3Loader->new(-store => $db,
-verbose => 0,
-fast => 1);
$loader->load('/home/fly4.3/dmel-all.gff');
# searching...
# ...by id
my @features = $db->fetch_many(@list_of_ids);
# ...by name
@features = $db->get_features_by_name('ZK909');
# ...by alias
@features = $db->get_features_by_alias('sma-3');
# ...by type
@features = $db->get_features_by_type('gene');
# ...by location
@features = $db->get_features_by_location(-seq_id=>'Chr1',-start=>4000,-end=>600000);
# ...by attribute
@features = $db->get_features_by_attribute({description => 'protein kinase'})
# ...by the GFF "Note" field
@result_list = $db->search_notes('kinase');
# ...by arbitrary combinations of selectors
@features = $db->features(-name => $name,
-type => $types,
-seq_id => $seqid,
-start => $start,
-end => $end,
-attributes => $attributes);
# ...using an iterator
my $iterator = $db->get_seq_stream(-name => $name,
-type => $types,
-seq_id => $seqid,
-start => $start,
-end => $end,
-attributes => $attributes);
while (my $feature = $iterator->next_seq) {
# do something with the feature
}
# ...limiting the search to a particular region
my $segment = $db->segment('Chr1',5000=>6000);
my @features = $segment->features(-type=>['mRNA','match']);
# what feature types are defined in the database?
my @types = $db->types;
# getting & storing sequence information
# Warning: this returns a string, and not a PrimarySeq object
$db->insert_sequence('Chr1','GATCCCCCGGGATTCCAAAA...');
my $sequence = $db->fetch_sequence('Chr1',5000=>6000);
# create a new feature in the database
my $feature = $db->new_feature(-primary_tag => 'mRNA',
-seq_id => 'chr3',
-start => 10000,
-end => 11000);
π DESCRIPTION π
So Bio::DB::SeqFeature::Store::berkeleydb is the Berkeleydb adaptor for Bio::DB::SeqFeature::Store. bestie, you do NOT create it directly β you go through Bio::DB::SeqFeature::Store->new() and let it do the work for you. periodt π
For the full usage tea, go read Bio::DB::SeqFeature::Store β it has all the complete instructions.
π Using the berkeleydb adaptor
The Berkeley database is literally just a series of Berkeleydb index files, plus a couple of special purpose indexes. β¨
You've got options, and honestly they all slay:
- create the index files from scratch by making a new database and calling
new_feature()over and over again π - create the database and then bulk populate it using the GFF3 loader π¦
- monitor a directory of preexisting GFF3 and FASTA files and rebuild the indexes whenever one or more of the fields changes π
That last mode is probably the most convenient, ngl. Just know that the indexer will only pay attention to files that end with .gff3, .wig and .fa. iykyk π§
π The new() constructor
The new() constructor method takes all the arguments recognized by Bio::DB::SeqFeature::Store, plus a few extra ones of its own. cute, right? π
Standard arguments:
-adaptorβ The name of the Adaptor class (defaultDBI::mysql)-serializerβ The name of the serializer class (defaultStorable)-index_subfeaturesβ Whether or not to make subfeatures searchable (defaulttrue)-cacheβ Activate LRU caching feature -- size of cache-compressβ Compresses features before storing them in database usingCompress::Zlib
Adaptor-specific arguments:
-dsnβ Where the index files are stored-dirβ Where the source (GFF3, FASTA) files are stored-autoindexβ An alias for-dir.-writeβ Pass true to open the index files for writing.-createβ Pass true to create the index files if they don't exist (implies-write=>1)-lockingβ Use advisory locking to avoid one process trying to read from the database while another is updating it (may not work properly over NFS).-tempβ Pass true to create temporary index files that will be deleted once the script exits.-verboseβ Pass true to report autoindexing operations onSTDERR. (default istrue).
Examples:
To create an empty database which will be populated using calls to store() or new_feature(), or which will be bulk-loaded using the GFF3 loader:
$db = Bio::DB::SeqFeature::Store->new( -adaptor => 'berkeleydb',
-dsn => '/var/databases/fly4.3',
-create => 1);
To open a preexisting database in read-only mode:
$db = Bio::DB::SeqFeature::Store->new( -adaptor => 'berkeleydb',
-dsn => '/var/databases/fly4.3');
To open a preexisting database in read/write (update) mode:
$db = Bio::DB::SeqFeature::Store->new( -adaptor => 'berkeleydb',
-dsn => '/var/databases/fly4.3',
-write => 1);
To monitor a set of GFF3 and FASTA files located in a directory and create/update the database indexes as needed. The indexes will be stored in a new subdirectory named "indexes":
$db = Bio::DB::SeqFeature::Store->new( -adaptor => 'berkeleydb',
-dir => '/var/databases/fly4.3');
As above, but store the source files and index files in separate directories:
$db = Bio::DB::SeqFeature::Store->new( -adaptor => 'berkeleydb',
-dsn => '/var/databases/fly4.3',
-dir => '/home/gff3_files/fly4.3');
To be indexed, files must end with one of .gff3 (GFF3 format), .fa (FASTA format) or .wig (WIG format). π
-autoindex is an alias for -dir. (yes, again, it's just the same thing wearing a different outfit π
)
bestie pls β you should specify -locking in a multiuser environment, including the case in which the database is being used by a web server at the same time another user might be updating it. don't skip this one π«Ά
See Bio::DB::SeqFeature::Store for all the access methods supported by this adaptor. The various methods for storing and updating features and sequences into the database are supported, but there is no locking. If two processes try to update the same database simultaneously, the database will likely become corrupted. π that's not the vibe, so don't do it.
π BUGS π
This is an early version, so there are certainly some bugs. Please use the BioPerl bug tracking system to report bugs. π (we love a humble icon, ngl)
β SEE ALSO β
bioperlBio::DB::SeqFeatureBio::DB::SeqFeature::StoreBio::DB::SeqFeature::GFF3LoaderBio::DB::SeqFeature::SegmentBio::DB::SeqFeature::Store::memoryBio::DB::SeqFeature::Store::DBI::mysql
π AUTHOR π
Lincoln Stein <lstein@cshl.org>.
Copyright (c) 2006 Cold Spring Harbor Laboratory.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie π«Ά this one's documented for perl v5.40.0 and dated 2024-10-11. slay, go annotate some sequences πβ¨π
π¦ where this page comes from
- ubuntu resolute: libbio-db-seqfeature-perl 1.7.5-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libbio-db-seqfeature-perl 1.7.5-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms