Bio::D...Loader(3pm)
Bio::D...Loader(3pm) π
okay bestie, this is a User Contributed Perl Documentation page for Bio::DB::SeqFeature::Store::GFF3Loader and it is <em>lowkey</em> a whole vibe. buckle up. π¦
β¨ NAME β¨
Bio::DB::SeqFeature::Store::GFF3Loader β it's the GFF3 file loader for Bio::DB::SeqFeature::Store. that's the whole job, she loads GFF3 into your store, and she does it iconically. π
β¨ SYNOPSIS β¨
so like, here's the whole ~moment~ in code:
use Bio::DB::SeqFeature::Store;
use Bio::DB::SeqFeature::Store::GFF3Loader;
# Open the sequence database
my $db = Bio::DB::SeqFeature::Store->new( -adaptor => 'DBI::mysql',
-dsn => 'dbi:mysql:test',
-write => 1 );
my $loader = Bio::DB::SeqFeature::Store::GFF3Loader->new(-store => $db,
-verbose => 1,
-fast => 1);
$loader->load('./my_genome.gff3');
that's it. that's the whole plot. open db, make loader, load file. slay. β¨
β¨ DESCRIPTION β¨
okay so the Bio::DB::SeqFeature::Store::GFF3Loader object parses GFF3-format sequence annotation files and loads them into Bio::DB::SeqFeature::Store databases. for certain combos of SeqFeature classes and SeqFeature::Store databases, she has a "fast load" mode that greatly accelerates the loading of GFF3 databases β we're talking a factor of 5-10. no cap. π₯
the GFF3 file format has been extended <em>very slightly</em> to accommodate Bio::DB::SeqFeature::Store. here's what's new:
first up, the loader recognizes a new directive:
# #index-subfeatures [0|1]
note bestie: you can put a space between the two #s so GFF3 validators stop complaining. π«Ά
if this is true, then subfeatures are indexed (that's the default) so they can be retrieved with a query. see Bio::DB::SeqFeature::Store for an explanation of all that. if it's false, then subfeatures can only be accessed through their parent feature. periodt.
second, the loader recognizes a new attribute tag called index, which β if present β controls indexing of the current feature. example time:
ctg123 . TF_binding_site 1000 1012 . + . ID=tfbs00001;index=1
you can use this to turn indexing on and off, overriding the default for a particular feature. iconic.
heads up bestie! the loader keeps a record β <em>in memory</em> β of each feature that it has processed. if you find the loader running out of memory on particularly large GFF3 files, please split the input file into smaller pieces and do the load in steps. π
πΈ new πΈ
Title : new
Usage : $loader = Bio::DB::SeqFeature::Store::GFF3Loader->new(@options)
Function: create a new parser
Returns : a Bio::DB::SeqFeature::Store::GFF3Loader gff3 parser and loader
Args : several - see below
Status : public
this method creates a new GFF3 loader and establishes its connection with a Bio::DB::SeqFeature::Store database. the arguments are -name=>$value pairs, as described in this table:
Name Value
---- -----
-store A writable Bio::DB::SeqFeature::Store database handle.
-seqfeature_class The name of the type of Bio::SeqFeatureI object to create
and store in the database (Bio::DB::SeqFeature by default)
-sf_class A shorter alias for -seqfeature_class
-verbose Send progress information to standard error.
-fast If true, activate fast loading (see below)
-chunk_size Set the storage chunk size for nucleotide/protein sequences
(default 2000 bytes)
-tmp Indicate a temporary directory to use when loading non-normalized
features.
-ignore_seqregion Ignore ##sequence-region directives. The default is to create a
feature corresponding to the directive.
-noalias_target Don't create an Alias attribute for a target_id named in a
Target attribute. The default is to create an Alias
attribute containing the target_id found in a Target
attribute.
when you call new(), a connection to a Bio::DB::SeqFeature::Store database should already have been established and the database initialized (if appropriate). like, don't come to her with nothing set up. π
some combinations of Bio::SeqFeatures and Bio::DB::SeqFeature::Store databases support a fast loading mode. currently the only reliable implementation of fast loading is the combination of DBI::mysql with Bio::DB::SeqFeature. the other important restriction on fast loading is the requirement that a feature that contains subfeatures must occur in the GFF3 file before any of its subfeatures. otherwise the subfeatures that occurred before the parent feature will not be attached to the parent correctly. this restriction does not apply to normal (slow) loading. π
if you use an unnormalized feature class, such as Bio::SeqFeature::Generic, then the loader needs to create a temporary database in which to cache features until all their parts and subparts have been seen. this temporary database uses the "berkeleydb" adaptor. the -tmp option specifies the directory in which that database will be created. if it's not present, it defaults to the system default tmp directory specified by File::Spec->tmpdir().
the -chunk_size option lets you tune the representation of DNA/Protein sequence in the Store database. by default, sequences are split into 2000 base/residue chunks and then reassembled as needed. this avoids the problem of pulling a whole chromosome into memory just to fetch a short subsequence from somewhere in the middle. depending on your usage patterns, you may wish to tune this parameter using a chunk size that is larger or smaller than the default. tune away, bestie. π
π ignore_seqregion π
$ignore_it = $loader->ignore_seqregion([$new_flag])
get or set the ignore_seqregion flag, which β if true β will cause GFF3 ##sequence-region directives to be ignored. the default behavior is to create a feature corresponding to the region. β¨
π¦ noalias_target π¦
$noalias_target = $loader->noalias_target([$new_flag])
get or set the noalias_target flag, which β if true β will disable the creation of an Alias attribute for a target_id named in a Target attribute. the default is to create an Alias attribute containing the target_id found in a Target attribute. simple as that. π
π load π
Title : load
Usage : $count = $loader->load(@ARGV)
Function: load the indicated files or filehandles
Returns : number of feature lines loaded
Args : list of files or filehandles
Status : public
once the loader is created, invoke its load() method with a list of GFF3 or FASTA file paths or previously-opened filehandles in order to load them into the database. compressed files ending with .gz, .Z and .bz2 are automatically recognized and uncompressed on the fly. paths beginning with http: or ftp: are treated as URLs and opened using the LWP GET program (which must be on your path). π
FASTA files are recognized by their initial ">" character. do not feed the loader a file that is neither GFF3 nor FASTA.
bestie I'm so serious β I don't know what will happen, but it will probably not be what you expect. π
π accessors π
the following read-only accessors return values passed or created during new():
store() the long-term Bio::DB::SeqFeature::Store object
tmp_store() the temporary Bio::DB::SeqFeature::Store object used
during loading
sfclass() the Bio::SeqFeatureI class
fast() whether fast loading is active
seq_chunk_size() the sequence chunk size
verbose() verbose progress messages
π₯ Internal Methods π₯
the following methods are used internally and may be overridden by subclasses. iykyk.
default_seqfeature_class
$class = $loader->default_seqfeature_class
return the default SeqFeatureI class (Bio::DB::SeqFeature). β¨
subfeatures_normalized
$flag = $loader->subfeatures_normalized([$new_flag])
get or set a flag that indicates that the subfeatures are normalized. this is deduced from the SeqFeature class information. π§
subfeatures_in_table
$flag = $loader->subfeatures_in_table([$new_flag])
get or set a flag that indicates that feature/subfeature relationships are stored in a table. this is deduced from the SeqFeature class and Store information. π
load_fh
$count = $loader->load_fh($filehandle)
load the GFF3 data at the other end of the filehandle and return true if successful. internally, load_fh() invokes:
start_load();
do_load($filehandle);
finish_load();
start_load, finish_load
these methods are called at the start and end of a filehandle load. πΈ
do_load
$count = $loader->do_load($fh)
this is called by load_fh() to load the GFF3 file's filehandle and return the number of lines loaded. π
load_line
$loader->load_line($data);
load a line of a GFF3 file. you must bracket this with calls to start_load() and finish_load()!
$loader->start_load();
$loader->load_line($_) while <FH>;
$loader->finish_load();
do not skip the bracketing, bestie. she means it. π
handle_meta
$loader->handle_meta($meta_directive)
this method is called to handle meta-directives such as ##sequence-region. the method will receive the directive with the initial ## stripped off. β¨
handle_feature
$loader->handle_feature($gff3_line)
this method is called to process a single GFF3 line. it manipulates information stored in a data structure called $self->{load_data}. π
allow_whitespace
$allow_it = $loader->allow_whitespace([$newvalue]);
get or set the allow_whitespace flag. if true, then GFF3 files are allowed to be delimited with whitespace in addition to tabs. π
store_current_feature
$loader->store_current_feature()
this method is called to store the currently active feature in the database. it uses a data structure stored in $self->{load_data}. π
build_object_tree
$loader->build_object_tree()
this method gathers together features and subfeatures and builds the graph that connects them. π¦
build_object_tree_in_tables
$loader->build_object_tree_in_tables()
this method gathers together features and subfeatures and builds the graph that connects them, assuming that parent/child relationships will be stored in a database table. β¨
build_object_tree_in_features
$loader->build_object_tree_in_features()
this method gathers together features and subfeatures and builds the graph that connects them, assuming that parent/child relationships are stored in the seqfeature objects themselves. π
attach_children
$loader->attach_children($store,$load_data,$load_id,$feature)
this recursively adds children to features and their subfeatures. it is called when subfeatures are directly contained within other features, rather than stored in a relational table. π
fetch
my $feature = $loader->fetch($load_id)
So like, you give it a load ID β the one from the ID= attribute β and it returns the feature. From the temporary database? Or the permanent one? Whichever one it's actually stored in, bestie. It just knows. π
add_segment β¨
$loader->add_segment($parent,$child)
Use this when you need to add a split location to the parent. It's giving "connect the dots" energy. π§©
parse_attributes π
($reserved,$unreserved) = $loader->parse_attributes($attribute_line)
Okay so you pass in $attribute_line, and it parses all that info into two hashrefs. One holds the values of reserved attribute tags β like ID β and the other holds the values of the unreserved ones. Two hashrefs, zero confusion. β¨
start_or_finish_sequence π
$loader->start_or_finish_sequence('Chr9')
This gets called at the beginning and the end of a fasta section. It's literally the bookends of your sequence era. π¬
load_sequence π§¬
$loader->load_sequence('gatttcccaaa')
After you've called start_or_finish_sequence() for the first time, you can use this to load in some sequence. Feed it a string like 'gatttcccaaa' and it'll do its thing. π§¬
open_fh π
my $io_file = $loader->open_fh($filehandle_or_path)
You give it a filehandle or a path, and it opens that file or pipe. And bestie, it's smart β it recognizes compressed files and URLs and just does the right thing. No cap. π
time β°
my $time = $loader->time
Returns the current time in seconds. If Time::HiRes is available, it uses that for extra precision. It's giving "I know what time it is" energy. β°
unescape π οΈ
my $unescaped = GFF3Loader::unescape($escaped)
This is an internal utility, so like, you probably won't call it directly. But it's the same as CGI::Util::unescape, except it doesn't turn pluses into spaces and it ignores unicode escapes. It's got its own rules, periodt. π οΈ
local_ids π¦
my $ids = $self->local_ids;
my $id_cnt = @$ids;
After you've done a load, call this and you get an array ref with all the load file IDs that were inside the file you just loaded. Then you can do my $id_cnt = @$ids; to get how many there are. Slay. π¦
loaded_ids π
my $ids = $loader->loaded_ids;
my $id_cnt = @$ids;
Same vibe, but for feature primary ids. After a load, this gives you an array ref of every feature primary ID that got created during the load. Then my $id_cnt = @$ids; for the count. Iconic. π
BUGS π
Okay so real talk: this is an early version, so there are certainly some bugs. Like, for sure. If you find one, please use the BioPerl bug tracking system to report it. Don't just suffer in silence, bestie. π
SEE ALSO π
Go check these out if you wanna know more:
Bio::DB::SeqFeature::StoreBio::DB::SeqFeature::SegmentBio::DB::SeqFeature::NormalizedFeatureBio::DB::SeqFeature::GFF2LoaderBio::DB::SeqFeature::Store::DBI::mysqlBio::DB::SeqFeature::Store::berkeleydb
AUTHOR π
Written by the one and only 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.
Signing off β perl v5.40.0, 2024-10-11, Bio::D...Loader(3pm). Bye bestie! π«Άβ¨
π¦ 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