Bio::DasI(3pm)

πŸ“¦
version 1.7.8 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

Bio::DasI β€” DAS-style access to a feature database πŸ¦‹

(psst, it's the Bio::DasI(3pm) page, from the User Contributed Perl Documentation, and yes bestie, this is part 1 of 2 so buckle up πŸ’…)


✨ SYNOPSIS ✨

okay so here's the vibe, literally just look at it:

# Open up a feature database somehow...
$db = Bio::DasI->new(@args);

@segments = $db->segment(-name  => 'NT_29921.4',
                         -start => 1,
                         -end   => 1000000);

# segments are Bio::Das::SegmentI - compliant objects

# fetch a list of features
@features = $db->features(-type=>['type1','type2','type3']);

# invoke a callback over features
$db->features(-type=>['type1','type2','type3'],
              -callback => sub { ... }
              );

$stream   = $db->get_seq_stream(-type=>['type1','type2','type3']);
while (my $feature = $stream->next_seq) {
   # each feature is a Bio::SeqFeatureI-compliant object
}

# get all feature types
@types   = $db->types;

# count types
%types   = $db->types(-enumerate=>1);

@feature = $db->get_feature_by_name($class=>$name);
@feature = $db->get_feature_by_target($target_name);
@feature = $db->get_feature_by_attribute($att1=>$value1,$att2=>$value2);
$feature = $db->get_feature_by_id($id);

$error = $db->error;

no cap, that's the whole mood right there πŸ”₯


🌸 DESCRIPTION 🌸

Bio::DasI is a simplified alternative interface to sequence annotation databases β€” the ones the distributed annotation system uses (peep Bio::Das for that 🫢).

So the way this scheme works: the genome is represented as a series of features, and a subset of those features are named. And those named features? They're the reference points you use to pull back "segments" (check Bio::Das::SegmentI πŸ’–), and those segments then become the basis for exploring the genome even further. It's giving ✨onion layers✨, bestie, one thing unlocks the next.

On top of a name, every feature also has a "class" β€” which is basically a namespace qualifier β€” and a "type", which describes what kind of feature it actually is. Das uses the GO consortium's ontology of feature types, so the type is actually an object of class Bio::Das::FeatureTypeI (see Bio::Das::FeatureTypeI, iykyk). And Bio::DasI gives you methods for interrogating the database for the types it contains, plus the counts of each type. iconic πŸ’…


🫢 FEEDBACK 🫢

πŸ’Œ Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules, fr fr. Send your comments and suggestions preferably to one of the Bioperl mailing lists β€” your participation is much appreciated, like genuinely πŸ₯Ή

bioperl-l@bioperl.org

🧚 Support

Please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org
and not to the module maintainer directly, bestie πŸ™ˆ Many experienced and reponsive experts will be able look at the problem and quickly address it. If at all possible, please include a thorough description of the problem with code and data examples. the more deets the better πŸ’–

πŸ› Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web:

https://github.com/bioperl/bioperl-live/issues

πŸ‘‘ AUTHOR - Lincoln Stein πŸ‘‘

Email lstein@cshl.org πŸ’Œ


okay that's the whole first chunk, and there's more coming so don't go anywhere πŸŒˆπŸ’œ

✨ APPENDIX ✨

okay bestie this is the part where we get into the actual methods, one by one, no skimming allowed. πŸ’– Internal methods usually start with an underscore, so if you see a _ at the front, that's the secret menu. iykyk.


🌸 new 🌸

Title   : new
Usage   : Bio::DasI->new(@args)
Function: Create new Bio::DasI object
Returns : a Bio::DasI object
Args    : see below

The new() method makes you a brand-new object, slay. πŸŽ€ You hand it either one single argument that's a connection string, or this whole little list of -name=>value args:

  • -dsn β€” the connection string for the database πŸ—„οΈ
  • -adaptor β€” name of an adaptor class to use when connecting
  • -aggregator β€” an array ref holding a list of aggregators, aka the "semantic mappers" to apply to the database
  • -user β€” authentication username
  • -pass β€” authentication password πŸ”

and heads up, implementors of DasI are allowed to add other arguments on top of these. it's giving "menu has secret items". ✨


πŸ¦‹ types πŸ¦‹

Title   : types
Usage   : $db->types(@args)
Function: return list of feature types in database
Returns : a list of Bio::Das::FeatureTypeI objects
Args    : see below

This routine hands you back a list of the feature types the database knows about. bonus: you can also find out how many times each feature shows up. πŸ‘‘

Arguments are -option=>value pairs like this:

  • -enumerate β€” if true, count the features

The returned value is a list of Bio::Das::FeatureTypeI objects (go look at Bio::Das::FeatureTypeI).

and here's the lil plot twist 🫢: if -enumerate is true, the function returns a hash (not a hash reference, bestie, a real hash) where the keys are the stringified versions of Bio::Das::FeatureTypeI and the values are the number of times each feature appears in the database.


🧚 parse_types 🧚

Title   : parse_types
Usage   : $db->parse_types(@args)
Function: parses list of types
Returns : an array ref containing ['method','source'] pairs
Args    : a list of types in 'method:source' form
Status  : internal

This one takes an array of type names shaped like "method:source" and gives you back an array reference full of ['method','source'] pairs. it'll also happily accept a single argument that's an array reference containing the list of type names. versatile icon. πŸ’…


🌈 segment 🌈

Title   : segment
Usage   : $db->segment(@args);
Function: create a segment object
Returns : segment object(s)
Args    : see below

This method generates a Bio::Das::SegmentI object (peep Bio::Das::SegmentI). once you've got that segment, you can use it to find overlapping features and the raw sequence. πŸ”₯

When you make the segment() call, you tell it the ID of a sequence landmark (think an accession number, a clone, or a contig) plus a positional range relative to that landmark. If you don't give a range, the whole entire region the landmark spans gets used to generate the segment. no range, no problem.

Arguments are -option=>value pairs like so:

  • -name β€” ID of the landmark sequence.
  • -class β€” a namespace qualifier. the database does not have to honor namespace qualifiers, but if it does, this is where the qualifier goes.
  • -version β€” version number of the landmark. again, the database isn't required to honor versions, but if it does, this is where the version goes.
  • -start β€” start of the segment relative to the landmark. positions follow standard 1-based sequence rules. if you don't specify it, it defaults to the beginning of the landmark.
  • -end β€” end of the segment relative to the landmark. if you don't specify it, it defaults to the end of the landmark.

The return value is a list of Bio::Das::SegmentI objects. now here's the rule 🚨: if you call it in scalar context and there are no more than one segments that satisfy the request, then it's allowed to return the segment. otherwise? the method must throw a "multiple segment exception". it's giving strict, and honestly? respect.


⭐ features ⭐

Title   : features
Usage   : $db->features(@args)
Function: get all features, possibly filtered by type
Returns : a list of Bio::SeqFeatureI objects
Args    : see below
Status  : public

This routine grabs features out of the database regardless of position. use it to get everything, or just a subset based on their type. main character retrieval energy. πŸ‘‘

Arguments are -option=>value pairs, as follows:

  • -types β€” list of feature types to return. the argument is an array of Bio::Das::FeatureTypeI objects, or a set of strings that can be converted into FeatureTypeI objects.
  • -callback β€” a callback to invoke on each feature. the subroutine gets passed each Bio::SeqFeatureI object in turn.
  • -attributes β€” a hash reference containing attributes to match.

The -attributes argument is a hashref holding one or more attributes to match against, like:

-attributes => { Gene => 'abc-1',
                 Note => 'confirmed' }

Attribute matching is plain simple exact string matching, and multiple attributes get ANDed together. want a fancier take on all this? go see Bio::DB::ConstraintsI.

If you provide a callback, it gets invoked on each feature in turn. and if that callback returns a false value, iteration will be interrupted. also β€” when a callback is provided, the method returns undef. so don't be out here expecting a list, bestie. πŸ’€


πŸŽ€ get_feature_by_name πŸŽ€

Title   : get_feature_by_name
Usage   : $db->get_feature_by_name(-class=>$class,-name=>$name)
Function: fetch features by their name
Returns : a list of Bio::SeqFeatureI objects
Args    : the class and name of the desired feature
Status  : public

Use this one to fetch named feature(s) out of the database. the -class and -name arguments mean the exact same thing they do in segment(), and it also accepts these lil short-cut forms:

  1. one argument: the argument is treated as the feature name
  2. two arguments: the arguments are treated as the class and name (note: this uses _rearrange() so the first argument must not begin with a hyphen or it'll be interpreted as a named argument). πŸ™ˆ

This method may return zero, one, or several Bio::SeqFeatureI objects. and the implementor may allow the name to contain wildcards, in which case standard C-shell glob semantics are expected. ✨


πŸ’œ get_feature_by_target πŸ’œ

Title   : get_feature_by_target
Usage   : $db->get_feature_by_target($class => $name)
Function: fetch features by their similarity target
Returns : a list of Bio::SeqFeatureI objects
Args    : the class and name of the desired feature
Status  : public

Use this one to fetch a named feature from the database based on its similarity hit. the arguments are the same as get_feature_by_name(). and if this isn't implemented, the interface just defaults to using get_feature_by_name(). chill fallback, love that for it. 🫢


🌸 get_feature_by_id 🌸

Title   : get_feature_by_id
Usage   : $db->get_feature_by_target($id)
Function: fetch a feature by its ID
Returns : a Bio::SeqFeatureI objects
Args    : the ID of the feature
Status  : public

If the database hands out unique feature IDs, this is your girl for retrieving a single feature from the database. and if you don't override it? this interface calls get_feature_by_name() and returns the first element. easy. πŸ’…


πŸ¦‹ get_feature_by_attribute πŸ¦‹

Title   : get_feature_by_attribute
Usage   : $db->get_feature_by_attribute(attribute1=>value1,attribute2=>value2)
Function: fetch features by combinations of attribute values
Returns : a list of Bio::SeqFeatureI objects
Args    : the class and name of the desired feature
Status  : public

Use this one to fetch a whole set of features from the database. attributes are a list of name=>value pairs, and they get logically ANDed together. but wait β€” if an attribute value is an array reference, then the list of values inside that array is treated as an alternative set of values to be ORed together. and/or combos, we love a flexible queen. πŸ‘‘


🧚 search_notes 🧚

Title   : search_notes
Usage   : $db->search_notes($search_term,$max_results)
Function: full-text search on features, ENSEMBL-style
Returns : an array of [$name,$description,$score]
Args    : see below
Status  : public

This routine does a full-text search on feature attributes (which attributes exactly? depends on the implementation, bestie) and hands you back a list of [$name,$description,$score], where $name is the feature ID, $description is a human-readable description like a locus line, and $score is the match strength. ✨

now listen β€” since this is a decidedly non-standard thing to do (but the generic genome browser uses it anyway 😭), the default method returns an empty list. so good news: you do not have to implement it. no cap.


πŸ”₯ get_seq_stream πŸ”₯

Title   : get_seq_stream
Usage   : $seqio = $db->get_seq_stream(@args)
Function: Performs a query and returns an iterator over it
Returns : a Bio::SeqIO stream capable of returning Bio::SeqFeatureI objects
Args    : As in features()
Status  : public

This routine takes the same arguments as features(), but returns a Bio::SeqIO::Stream-compliant object instead. use it like this:

$stream = $db->get_seq_stream('exon');
while (my $exon = $stream->next_seq) {
   print $exon,"\n";
}
NOTE: in the interface this method is aliased to get_feature_stream(), because that name is just more descriptive. ✨

πŸ‘‘ refclass πŸ‘‘

Title   : refclass
Usage   : $class = $db->refclass
Function: returns the default class to use for segment() calls
Returns : a string
Args    : none
Status  : public

For data sources that use namespaces to tell reference sequence accessions apart, this returns the default namespace (or "class") to use. and this interface defines a default of "Accession". that's it, that's the whole method, and she's iconic for it. πŸ’–


and that's a wrap on Bio::DasI(3pm) bestie!! πŸŽ‰πŸ¦‹ this page shipped as part of perl v5.32.1, dated 2021-08-15 β€” so go forth, query those features, and remember: every option we covered is exactly the option that's there, no more, no less. periodt. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from