Bio::S...lection(3pm)
π Bio::SeqFeature::Collection π
okay bestie, welcome to the manual page for Bio::SeqFeature::Collection from the User Contributed Perl Documentation collection. she's a container class for SeqFeatures, and she is so good at what she does β finding features within a range, matching a certain feature type, all that. let's get into it π
β¨ NAME β¨
Bio::SeqFeature::Collection β a container class for SeqFeatures, suitable for performing operations such as finding features within a range, that match a certain feature type, etc. she's giving organized queen energy fr fr π
πΈ SYNOPSIS πΈ
use Bio::SeqFeature::Collection;
use Bio::Location::Simple;
use Bio::Tools::GFF;
use Bio::Root::IO;
use File::Spec;
# let's first input some features
my $gffio = Bio::Tools::GFF->new(-file => File::Spec->catfile
("t","data","myco_sites.gff"),
-gff_version => 2);
my @features = ();
# loop over the input stream
while(my $feature = $gffio->next_feature()) {
# do something with feature
push @features, $feature;
}
$gffio->close();
# build the Collection object
my $col = Bio::SeqFeature::Collection->new();
# add these features to the object
my $totaladded = $col->add_features(\@features);
my @subset = $col->features_in_range(-start => 1,
-end => 25000,
-strand => 1,
-contain => 0);
# subset should have 18 entries for this dataset
print "size is ", scalar @subset, "\n";
@subset = $col->features_in_range(-range => Bio::Location::Simple->new
(-start => 70000,
-end => 150000,
-strand => -1),
-contain => 1,
-strandmatch => 'strong');
# subset should have 22 entries for this dataset
print "size is ", scalar @subset, "\n";
print "total number of features in collection is ",
$col->feature_count(),"\n";
like, look at her go π¦ she literally reads a GFF file, hoovers up all the features, and then pulls out exactly the ones you want. 18 entries in the first subset, 22 in the second, no cap.
π DESCRIPTION π
so here's the tea β this object will efficiently allow one to query subsets of ranges within a large collection of sequence features β and honestly, the objects just have to be Bio::RangeI compliant, that's the whole bar, she's not picky bestie π
how does she do it? by the creation of bins which are stored in order in a B-Tree data structure, as provided by the DB_File interface to the Berkeley DB. it's giving data structures degree, and she ate π₯
this is based on work done by Lincoln for storage in a mysql instance β but this version is intended to be an embedded in-memory implementation for easily querying for subsets of a large range set. so like, no server, no drama, just vibes πΈ
and guess what β collections can be made persistent by keeping the indexfile and passing in the -keep flag, like this:
my $collection = Bio::SeqFeature::Collection->new(-keep => 1,
-file => 'col.idx');
$collaction->add_features(\@features);
undef $collection;
# To reuse this collection, next time you initialize a Collection object
# specify the filename and the index will be reused.
$collection = Bio::SeqFeature::Collection->new(-keep => 1,
-file => 'col.idx');
yes the variable in that snippet is spelled $collaction. that's what's written, that's what we're keeping, don't @ me π (she's perfect even with a typo, ok?)
π«Ά 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 β genuinely, we love to hear from you π₯Ή
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 reponsive 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. give them the full context bestie, they can't debug a vibe check alone π
π 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
π AUTHOR - Jason Stajich
Email jason@bioperl.org β thank you king, the icon, the blueprint π
β CONTRIBUTORS
using code and strategy developed by Lincoln Stein (lstein@cshl.org) in the Bio::DB::GFF implementation. credit also to Lincoln for suggesting using Storable to serialize features rather than my previous implementation which kept the features in memory. the glow up was real πβ¨
π APPENDIX π
the rest of the documentation details each of the object methods. internal methods are usually preceded with a _ β so if you see an underscore, mind your business, that's private π
π§ new
- Title β
new - Usage β
my $obj = Bio::SeqFeature::Collection->new(); - Function β builds a brand new
Bio::SeqFeature::Collectionobject β¨ - Returns β
Bio::SeqFeature::Collection - Args β
-minbinβ minimum value to use for binning (default is100,000,000)-maxbinβ maximum value to use for binning (default is1,000)-fileβ filename to store/read theBTREEfrom rather than an in-memory structure (default is false and in-memory).-keepβ boolean, will not remove index file on object destruction.-featuresβ Array ref of features to add initially
yes bestie, that's what the defaults say β-minbindefaults to100,000,000and-maxbindefaults to1,000. we do not question the ancestors π
π¦ add_features
- Title β
add_features - Usage β
$collection->add_features(\@features); - Function β
- Returns β number of features added
- Args β arrayref of
Bio::SeqFeatureIobjects to index
(the Function line is literally empty in the original, she's mysterious like that π)
πΈ features_in_range
- Title β
features_in_range - Usage β
my @features = $collection->features_in_range($range) - Function β retrieves a list of features which were contained or overlap the the requested range (see Args for way to specify overlap or only those containe)d)
- Returns β List of
Bio::SeqFeatureIobjects - Args β
-range=>Bio::RangeIobject defining range to search,- OR
-start=> start,-end=> end,-strand=> strand-contain=> boolean β true if feature must be completely contained with range, OR false if should include features that simply overlap the range. Default:true.-strandmatch=>'strong'β ranges must have the same strand'weak'β ranges must have the same strand or no strand'ignore'β ignore strand information- Default.
'ignore'.
π remove_features
- Title β
remove_features - Usage β
$collection->remove_features(\@array) - Function β removes the requested sequence features (based on features which have the same location)
- Returns β Number of features removed
- Args β Arrayref of
Bio::RangeIobjects
β¨ get_all_features
- Title β
get_all_features - Usage β
my @f = $col->get_all_features() - Function β return all the features stored in this collection (Could be large)
- Returns β Array of
Bio::RangeIobjects - Args β None
she said could be large in parentheses, so like, heed the warning bestie π hydrate and maybe grab a snack before you call this one
π min_bin
- Title β
min_bin - Usage β
my $minbin= $self->min_bin; - Function β get/set the minimum value to use for binning
- Returns β integer
- Args β [optional] minimum bin value
π max_bin
- Title β
max_bin - Usage β
my $maxbin= $self->max_bin; - Function β get/set the maximum value to use for binning
- Returns β integer
- Args β [optional] maximum bin value
π feature_count
- Title β
feature_count - Usage β
my $c = $col->feature_count() - Function β retrieve the total number of features in the collection
- Returns β integer
- Args β none
π indexfile
- Title β
indexfile - Usage β
$obj->indexfile($newval) - Function β get/set the filename where index is kept
- Returns β value of
indexfile(a filename string) - Args β on set, new value (a filename string )
π keep
- Title β
keep - Usage β
$obj->keep($newval) - Function β get/set boolean flag to keep the
indexfileafter exiting program - Example β
- Returns β value of
keep(boolean) - Args β on set, new value (boolean)
and that's the whole page, bestie, we made it π«Ά this beauty ships as part of perl v5.32.1, dated 2021-08-15 β so like, she's vintage, she's classic, she's still serving π β¨ no cap, go index something iconic ππ
π¦ 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