| Summary | Included libraries | Package variables | Synopsis | Description | General documentation | Methods |
use Bio::DB::SeqFeature::Store;
# Open the feature database my $db = Bio::DB::SeqFeature::Store->new( -adaptor => 'DBI::mysql', -dsn => 'dbi:mysql:test', -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 die "Couldn't update!"; # 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 primary id @features = $db->get_feature_by_primary_id(42); # note no plural!!! # ...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']); # 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); # what feature types are defined in the database? my @types = $db->types; # create a new feature in the database my $feature = $db->new_feature(-primary_tag => 'mRNA', -seq_id => 'chr3', -start => 10000, -end => 11000); # load an entire GFF3 file, using the GFF3 loader... my $loader = Bio::DB::SeqFeature::Store::GFF3Loader->new(-store => $db, -verbose => 1, -fast => 1); $loader->load('./my_genome.gff3');
| api_version | No description | Code |
| new | Description | Code |
| init_database | Description | Code |
| post_init | Description | Code |
| store | Description | Code |
| store_noindex | Description | Code |
| no_blobs | Description | Code |
| new_feature | Description | Code |
| delete | Description | Code |
| get_feature_by_id | Description | Code |
| fetch | Description | Code |
| get_feature_by_primary_id | Description | Code |
| fetch_many | Description | Code |
| get_seq_stream | Description | Code |
| get_features_by_name | Description | Code |
| get_feature_by_name | Description | Code |
| get_features_by_alias | Description | Code |
| get_features_by_type | Description | Code |
| get_features_by_location | Description | Code |
| get_features_by_attribute | Description | Code |
| features | Description | Code |
| seq_ids | Description | Code |
| search_attributes | Description | Code |
| search_notes | Description | Code |
| types | Description | Code |
| insert_sequence | Description | Code |
| fetch_sequence | Description | Code |
| segment | Description | Code |
| seqfeature_class | Description | Code |
| reindex | Description | Code |
| attributes | Description | Code |
| start_bulk_update | Description | Code |
| finish_bulk_update | No description | Code |
| add_SeqFeature | Description | Code |
| fetch_SeqFeatures | Description | Code |
| debug | Description | Code |
| serializer | Description | Code |
| do_compress | No description | Code |
| index_subfeatures | Description | Code |
| clone | Description | Code |
| TIEHASH | No description | Code |
| STORE | No description | Code |
| FETCH | No description | Code |
| FIRSTKEY | No description | Code |
| NEXTKEY | No description | Code |
| EXISTS | No description | Code |
| DELETE | No description | Code |
| CLEAR | No description | Code |
| SCALAR | No description | Code |
| _init_database | Description | Code |
| _store | Description | Code |
| _fetch | Description | Code |
| _fetch_many | Description | Code |
| _update_indexes | Description | Code |
| _start_reindexing | Description | Code |
| _end_reindexing | No description | Code |
| _features | Description | Code |
| _search_attributes | Description | Code |
| can_store_parentage | Description | Code |
| _add_SeqFeature | Description | Code |
| _fetch_SeqFeatures | Description | Code |
| _insert_sequence | Description | Code |
| _fetch_sequence | Description | Code |
| _seq_ids | Description | Code |
| _start_bulk_update | Description | Code |
| _finish_bulk_update | No description | Code |
| _firstid | No description | Code |
| _nextid | No description | Code |
| _existsid | No description | Code |
| _deleteid | No description | Code |
| _clearall | No description | Code |
| _featurecount | No description | Code |
| new_instance | Description | Code |
| init | Description | Code |
| default_settings | Description | Code |
| default_serializer | Description | Code |
| setting | Description | Code |
| subfeatures_are_indexed | Description | Code |
| subfeature_types_are_indexed | Description | Code |
| subfeature_locations_are_indexed | Description | Code |
| setup_segment_args | Description | Code |
| store_and_cache | Description | Code |
| init_cache | Description | Code |
| cache | Description | Code |
| load_class | Description | Code |
| freeze | Description | Code |
| thaw | Description | Code |
| thaw_object | Description | Code |
| feature_names | Description | Code |
| new | code | next | Top |
Title : newThis class method creates a new database connection. The following -name=>$value arguments are accepted: Name ValueThe -index_subfeatures argument, if true, tells the module to create indexes for a feature and all its subfeatures (and its subfeatues' subfeatures). Indexing subfeatures means that you will be able to search for the gene, its mRNA subfeatures and the exons inside each mRNA. It also means when you search the database for all features contained within a particular location, you will get the gene, the mRNAs and all the exons as individual objects as well as subfeatures of each other. NOTE: this option is only honored when working with a normalized feature class such as Bio::DB::SeqFeature. The -cache argument, if true, tells the module to try to create a LRU (least-recently-used) object cache using the Tie::Cacher module. Caching will cause two objects that share the same primary_id to (often, but not always) share the same memory location, and may improve performance modestly. The argument is taken as the desired size for the cache. If you pass "1" as the cache value, a reasonable default cache size will be chosen. Caching requires the Tie::Cacher module to be installed. If the module is not installed, then caching will silently be disabled. The -compress argument, if true, will cause the feature data to be compressed before storing it. This will make the database somewhat smaller at the cost of decreasing performance. The -create argument, if true, will either initialize or reinitialize the database. It is needed the first time a database is used. The new() method of individual adaptors recognize additional arguments. The default DBI::mysql adaptor recognizes the following ones: Name Value |
| init_database | code | prev | next | Top |
Title : init_databaseCall this after Bio::DB::SeqFeature::Store->new() to initialize a new database. In the case of a DBI database, this method installs the schema but does not create the database. You have to do this offline using the appropriate command-line tool. In the case of the "berkeleydb" adaptor, this creates an empty BTREE database. If there is any data already in the database, init_database() called with no arguments will have no effect. To permanently erase the data already there and prepare to receive a fresh set of data, pass a true argument. |
| post_init | code | prev | next | Top |
| This method is invoked after init_database for use by certain adaptors (currently only the memory adaptor) to do automatic data loading after initialization. It is passed a copy of the init_database() args. |
| store | code | prev | next | Top |
Title : storeThis method stores a list of features into the database. Each feature is updated so that its primary_id becomes the primary ID of the serialized feature stored in the database. If all features were successfully stored, the method returns true. In the DBI implementation, the store is performed as a single transaction and the transaction is rolled back if one or more store operations failed. You can find out what the primary ID of the feature has become by calling the feature's primary_id() method: $db->store($my_feature) or die "Oh darn";If the feature contains subfeatures, they will all be stored recursively. In the case of Bio::DB::SeqFeature and Bio::DB::SeqFeature::Store::NormalizedFeature, the subfeatures will be stored in a normalized way so that each subfeature appears just once in the database. Subfeatures will be indexed for separate retrieval based on the current value of index_subfeatures(). If you call store() with one or more features that already have valid primary_ids, then an existing object(s) will be replaced. Note that when using normalized features such as Bio::DB::SeqFeature, the subfeatures are not recursively updated when you update the parent feature. You must manually update each subfeatures that has changed. |
| store_noindex | code | prev | next | Top |
Title : store_noindexThis method stores a list of features into the database but does not make them searchable. The only way to access the features is via their primary IDs. This method is ordinarily only used internally to store subfeatures that are not indexed. |
| no_blobs | code | prev | next | Top |
Title : no_blobsThis method saves lots of space in the database, which may in turn lead to large performance increases in extreme cases (over 7 million features in the db). Currently only applies to the mysql implementation. |
| new_feature | code | prev | next | Top |
Title : new_featureThis method creates and stores a new Bio::SeqFeatureI object using the specialized Bio::DB::SeqFeature class. This class is able to store its subfeatures in a normalized fashion, allowing subfeatures to be shared among multiple parents (e.g. multiple exons shared among several mRNAs). The arguments are the same as for Bio::DB::SeqFeature->new(), which in turn are similar to Bio::SeqFeature::Generic->new() and Bio::Graphics::Feature->new(). The most important difference is the -index option, which controls whether the feature will be indexed for retrieval (default is true). Ordinarily, you would only want to turn indexing off when creating subfeatures, because features stored without indexes will only be reachable via their primary IDs or their parents. Arguments are as follows: -seq_id the reference sequenceAliases: -id an alias for -display_nameYou can change the seqfeature implementation generated by new() by passing the name of the desired seqfeature class to $db->seqfeature_class(). |
| delete | code | prev | next | Top |
Title : deleteThis method looks up the primary IDs from a list of features and deletes them from the database, returning true if all deletions are successful. WARNING: The current DBI::mysql implementation has some issues that need to be resolved, namely (1) normalized subfeatures are NOT recursively deleted; and (2) the deletions are not performed in a transaction. |
| get_feature_by_id | code | prev | next | Top |
Title : get_feature_by_idThis method returns a previously-stored feature from the database using its primary ID. If the primary ID is invalid, it returns undef. |
| fetch | code | prev | next | Top |
Title : fetchThis is an alias for get_feature_by_id(). |
| get_feature_by_primary_id | code | prev | next | Top |
Title : get_feature_by_primary_idThis method returns a previously-stored feature from the database using its primary ID. If the primary ID is invalid, it returns undef. This method is identical to fetch(). |
| fetch_many | code | prev | next | Top |
Title : fetch_manySame as fetch() except that you can pass a list of primary IDs or a ref to an array of IDs. |
| get_seq_stream | code | prev | next | Top |
Title : get_seq_streamWhen called without any arguments this method will return an iterator object that will traverse all indexed features in the database. Call the iterator's next_seq() method to step through them (in no particular order): my $iterator = $db->get_seq_stream;You can select a subset of features by passing a series of filter arguments. The arguments are identical to those accepted by $db->features(). |
| get_features_by_name | code | prev | next | Top |
Title : get_features_by_nameThis method searches the display_name of all features for matches against the provided name. GLOB style wildcares ("*", "?") are accepted, but may be slow. The method returns the list of matches, which may be zero, 1 or more than one features. Be prepared to receive more than one result, as display names are not guaranteed to be unique. For backward compatibility with gbrowse, this method is also known as get_feature_by_name(). |
| get_feature_by_name | code | prev | next | Top |
Title : get_feature_by_nameThis method is provided for backward compatibility with gbrowse. |
| get_features_by_alias | code | prev | next | Top |
Title : get_features_by_aliasThis method is similar to get_features_by_name() except that it will also search through the feature aliases. Aliases can be created by storing features that contain one or more Alias tags. Wildards are accepted. |
| get_features_by_type | code | prev | next | Top |
Title : get_features_by_typeThis method will return a list of features that have any of the primary tags given in the argument list. For compatibility with gbrowse and Bio::DB::GFF, types can be qualified using a colon: primary_tag:source_tagin which case only features that match both the primary_tag and the indicated source_tag will be returned. If the database was loaded from a GFF3 file, this corresponds to the third and second columns of the row, in that order. For example, given the GFF3 lines: ctg123 geneFinder exon 1300 1500 . + . ID=exon001exon001 and exon002 will be returned by searching for type "exon", but only exon001 will be returned by searching for type "exon:fgenesH". |
| get_features_by_location | code | prev | next | Top |
Title : get_features_by_locationThis method fetches features based on a location range lookup. You call it using a positional list of arguments, or a list of (-argument=>$value) pairs. The positional form is as follows: $db->get_features_by_location($seqid [[,$start,]$end])The $seqid is the name of the sequence on which the feature resides, and start and end are optional endpoints for the match. If the endpoints are missing then any feature on the indicated seqid is returned. Examples: get_features_by_location('chr1'); # all features on chromosome 1Location lookups are overlapping. A feature will be returned if itpartially or completely overlaps the indicated range. The named argument form gives you more control: Argument ValueThe -strand argument, if present, can be one of "0" to find features that are on both strands, "+1" to find only plus strand features, and "-1" to find only minus strand features. Specifying a strand of undef is the same as not specifying this argument at all, and retrieves all features regardless of their strandedness. The -range_type argument, if present, can be one of "overlaps" (the default), to find features whose positions overlap the indicated range, "contains," to find features whose endpoints are completely contained within the indicated range, and "contained_in" to find features whose endpoints are both outside the indicated range. |
| get_features_by_attribute | code | prev | next | Top |
Title : get_features_by_attributeThis implements a simple tag filter. Pass a list of tag names and their values. The module will return a list of features whose tag names and values match. Tag names are case insensitive. If multiple tag name/value pairs are present, they will be ANDed together. To match any of a list of values, use an array reference for the value. Examples: # return all features whose "function" tag is "GO:0000123" |
| features | code | prev | next | Top |
Title : featuresThis is the workhorse for feature query and retrieval. It takes a series of -name=>$value arguments filter arguments. Features that match all the filters are returned. Argument ValueYou may also provide features() with a list of scalar values (the first element of which must not begin with a dash), in which case it will treat the list as a feature type filter. Examples: All features on chromosome 1: @features = $db->features(-seqid=>'Chr1');All features on chromosome 1 between 5000 and 6000: @features = $db->features(-seqid=>'Chr1',-start=>5000,-end=>6000);All mRNAs on chromosome 1 between 5000 and 6000: @features = $db->features(-seqid=>'Chr1',-start=>5000,-end=>6000,-types=>'mRNA');All confirmed mRNAs and repeats on chromosome 1 that overlap the range 5000..6000: @features = $db->features(-seqid => 'Chr1',-start=>5000,-end=>6000,All confirmed mRNAs and repeats on chromosome 1 strictly contained within the range 5000..6000: @features = $db->features(-seqid => 'Chr1',-start=>5000,-end=>6000,All genes and repeats: @features = $db->features('gene','repeat_region'); |
| seq_ids | code | prev | next | Top |
Title : seq_ids |
| search_attributes | code | prev | next | Top |
Title : search_attributesGiven a search string, this method performs a full-text search of the specified attributes and returns an array of results. You may pass a scalar attribute name to search the values of one attribute (e.g. "Note") or you may pass an array reference to search inside multiple attributes (['Note','Alias','Parent']).Each row of the returned array is a arrayref containing the following fields: column 1 The display name of the featureNOTE: This search will fail to find features that do not have a display name! You can use fetch() or fetch_many() with the returned IDs to get to the features themselves. |
| search_notes | code | prev | next | Top |
Title : search_notesGiven a search string, this method performs a full-text search of the "Notes" attribute and returns an array of results. Each row of the returned array is a arrayref containing the following fields: column 1 The display_name of the feature, suitable for passing to get_feature_by_name()NOTE: This is equivalent to $db->search_attributes('full text search string','Note',$limit). This search will fail to find features that do not have a display name! |
| types | code | prev | next | Top |
Title : types |
| insert_sequence | code | prev | next | Top |
Title : insert_sequenceThis method inserts the DNA or protein sequence fragment $sequence_string, identified by the ID $seq_id, into the database at the indicated offset $offset. It is used internally by the GFF3Loader to load sequence data from the files. |
| fetch_sequence | code | prev | next | Top |
Title : fetch_sequenceThis method retrieves a portion of the indicated sequence. The arguments are: Argument ValueYou can call fetch_sequence using the following shortcuts: $seq = $db->fetch_sequence('chr3'); # entire chromosome |
| segment | code | prev | next | Top |
Title : segmentThis is a convenience method that can be used when you are interested in the contents of a particular sequence landmark, such as a contig. Specify the ID of a sequence or other landmark in the database and optionally a start and endpoint relative to that landmark. The method will look up the region and return a Bio::DB::SeqFeature::Segment object that spans it. You can then use this segment object to make location-restricted queries on the database. Example: $segment = $db->segment('contig23',1,1000); # first 1000 bp of contig23Although you will usually want to fetch segments that correspond tophysical sequences in the database, you can actually use any feature in the database as the sequence ID. The segment() method will perform a get_features_by_name() internally and then transform the feature into the appropriate coordinates. The named feature should exist once and only once in the database. If it exists multiple times in the database and you attempt to call segment() in a scalar context, you will get an exception. A workaround is to call the method in a list context, as in: my ($segment) = $db->segment('contig23',1,1000);or my @segments = $db->segment('contig23',1,1000);However, having multiple same-named features in the database is oftenan indication of underlying data problems. If the optional $absolute argument is a true value, then the specified coordinates are relative to the reference (absolute) coordinates. |
| seqfeature_class | code | prev | next | Top |
Title : seqfeature_class |
| reindex | code | prev | next | Top |
Title : reindexThis method will force the secondary indexes (name, location, attributes, feature types) to be recalculated. It may be useful to rebuild a corrupted database. |
| attributes | code | prev | next | Top |
Title : attributes |
| start_bulk_update,finish_bulk_update | code | prev | next | Top |
Title : start_bulk_update,finish_bulk_updateWith some adaptors (currently only the DBI::mysql adaptor), these methods signal the adaptor that a large number of insertions or updates are to be performed, and activate certain optimizations. These methods are called automatically by the Bio::DB::SeqFeature::Store::GFF3Loader module. Example: $db->start_bulk_update; |
| add_SeqFeature | code | prev | next | Top |
Title : add_SeqFeatureIf can_store_parentage() returns true, then some store-aware features (e.g. Bio::DB::SeqFeature) will invoke this method to store feature/subfeature relationships in a normalized table. |
| fetch_SeqFeatures | code | prev | next | Top |
Title : fetch_SeqFeaturesIf can_store_parentage() returns true, then some store-aware features (e.g. Bio::DB::SeqFeature) will invoke this method to retrieve feature/subfeature relationships from the database. |
| debug | code | prev | next | Top |
Title : debugThis method gets/sets a flag that turns on verbose progress messages. Currently this will not do very much. |
| serializer | code | prev | next | Top |
Title : serializerYou can use this method to set the serializer, but do not attempt to change the serializer once the database is initialized and populated. |
| index_subfeatures | code | prev | next | Top |
Title : index_subfeaturesIf true, the store() method will add a searchable index to both the top-level feature and all its subfeatures, allowing the search functions to return features at any level of the conainment hierarchy. If false, only the top level feature will be indexed, meaning that you will only be able to get at subfeatures by fetching the top-level feature and then traversing downward using get_SeqFeatures(). You are free to change this setting at any point during the creation and population of a database. One database can contain both indexed and unindexed subfeatures. |
| clone | code | prev | next | Top |
| The clone() method should be used when you want to pass the Bio::DB::SeqFeature::Store object to a child process across a fork(). The child must call clone() before making any queries. The default behavior is to do nothing, but adaptors that use the DBI interface may need to implement this in order to avoid database handle errors. See the dbi adaptor for an example. |
| _init_database | code | prev | next | Top |
Title : _init_databaseThis method is the back end for init_database(). It must be implemented by an adaptor that inherits from Bio::DB::SeqFeature::Store. It returns true on success. |
| _store | code | prev | next | Top |
Title : _storeThis method is the back end for store() and store_noindex(). It should write the seqfeature objects into the database. If indexing is requested, the features should be indexed for query and retrieval. Otherwise the features should be stored without indexing (it is not required that adaptors respect this). If the object has no primary_id (undef), then the object is written into the database and assigned a new primary_id. If the object already has a primary_id, then the system will perform an update, replacing whatever was there before. In practice, the implementation will serialize each object using the freeze() method and then store it in the database under the corresponding primary_id. The object is then updated with the primary_id. |
| _fetch | code | prev | next | Top |
Title : _fetchThis method is the back end for fetch(). It accepts a primary_id and returns a feature object. It must be implemented by the adaptor. In practice, the implementation will retrieve the serialized Bio::SeqfeatureI object from the database and pass it to the thaw() method to unserialize it and synchronize the primary_id. |
| _fetch_many | code | prev | next | Top |
Title : _fetch_manyThis method fetches many features specified by a list of IDs. The default implementation simply calls _fetch() once for each primary_id. Implementors can override it if needed for efficiency. |
| _update_indexes | code | prev | next | Top |
Title : _update_indexesThis method is called by reindex() to update the searchable indexes for a feature object that has changed. |
| _start_reindexing, _end_reindexing | code | prev | next | Top |
Title : _start_reindexing, _end_reindexingThese methods are called by reindex() before and immediately after a series of reindexing operations. The default behavior is to do nothing, but these methods can be overridden by an adaptor in order to perform optimizations, turn off autocommits, etc. |
| _features | code | prev | next | Top |
Title : _featuresThis is the backend for features(), get_features_by_name(), get_features_by_location(), etc. Arguments are as described for the features() method, except that only the named-argument form is recognized. |
| _search_attributes | code | prev | next | Top |
Title : _search_attributesSee search_attributes() for the format of the results list. The only difference between this and the public method is that the tag list is guaranteed to be an array reference. |
| can_store_parentage | code | prev | next | Top |
Title : can_store_parentageOverride this method and return true if this adaptor supports the _add_SeqFeature() and _get_SeqFeatures() methods, which are used for storing feature parent/child relationships in a normalized fashion. Default is false (parent/child relationships are stored in denormalized form in each feature). |
| _add_SeqFeature | code | prev | next | Top |
Title : _add_SeqFeatureIf can_store_parentage() returns true, then some store-aware features (e.g. Bio::DB::SeqFeature) will invoke this method to store feature/subfeature relationships in a normalized table. |
| _fetch_SeqFeatures | code | prev | next | Top |
Title : _fetch_SeqFeaturesIf can_store_parentage() returns true, then some store-aware features (e.g. Bio::DB::SeqFeature) will invoke this method to retrieve feature/subfeature relationships from the database. |
| _insert_sequence | code | prev | next | Top |
Title : _insert_sequenceThis is the back end for insert_sequence(). Adaptors must implement this method in order to store and retrieve nucleotide or protein sequence. |
| _fetch_sequence | code | prev | next | Top |
Title : _fetch_sequenceThis is the back end for fetch_sequence(). Adaptors must implement this method in order to store and retrieve nucleotide or protein sequence. |
| _seq_ids | code | prev | next | Top |
Title : _seq_idsThis method is invoked by seq_ids() to return all sequence IDs (coordinate systems) known to the database. |
| _start_bulk_update,_finish_bulk_update | code | prev | next | Top |
Title : _start_bulk_update, _finish_bulk_updateThese are the backends for start_bulk_update() and finish_bulk_update(). The default behavior of both methods is to do nothing. |
| new_instance | code | prev | next | Top |
Title : new_instanceThis method is called internally by new() to create a new uninitialized instance of Bio::DB::SeqFeature::Store. It is used internally and should not be called by application software. |
| init | code | prev | next | Top |
Title : initThis method is called internally by new() to initialize a newly-created object using the arguments passed to new(). It is to be overridden by Bio::DB::SeqFeature::Store adaptors. |
| default_settings | code | prev | next | Top |
Title : default_settingsThis method is may be overridden by adaptors. It is responsible for setting up object default settings. |
| default_serializer | code | prev | next | Top |
Title : default_serializerThis method returns the name of an available serializer module. |
| setting | code | prev | next | Top |
Title : settingThis is a low-level procedure for persistently storing database settings. It can be overridden by adaptors. |
| subfeatures_are_indexed | code | prev | next | Top |
Title : subfeatures_are_indexedThis method is used internally by the Bio::DB::SeqFeature class to optimize some of its operations. It returns true if all of the subfeatures in the database are indexed; it returns false if at least one of the subfeatures is not indexed. Do not attempt to change the value of this setting unless you are writing an adaptor. |
| subfeature_types_are_indexed | code | prev | next | Top |
Title : subfeature_types_are_indexedThis method returns true if subfeature types are indexed. Default is to return the value of subfeatures_are_indexed(). |
| subfeature_locations_are_indexed | code | prev | next | Top |
Title : subfeature_locations_are_indexedThis method returns true if subfeature locations are indexed. Default is to return the value of subfeatures_are_indexed(). |
| setup_segment_args | code | prev | next | Top |
Title : setup_segment_argsThis method is used internally by segment() to translate positional arguments into named argument=>value pairs. |
| store_and_cache | code | prev | next | Top |
Title : store_and_cacheThis private method stores the list of Bio::SeqFeatureI objects into the database and caches them in memory for retrieval. |
| init_cache | code | prev | next | Top |
Title : init_cacheThis method is used internally by new() to create the Tie::Cacher instance used for the in-memory feature cache. |
| cache | code | prev | next | Top |
Title : cacheThis method returns the Tie::Cacher object used for the in-memory feature cache. |
| load_class | code | prev | next | Top |
Title : load_classThis method is used by thaw() to load the code for a blessed object. This ensures that all the object's methods are available. |
| freeze | code | prev | next | Top |
Title : freezeThis method converts a Bio::SeqFeatureI object into a serialized form suitable for storage into a database. The feature's primary ID is set to undef before it is serialized. This avoids any potential mismatch between the primary ID used as the database key and the primary ID stored in the serialized object. |
| thaw | code | prev | next | Top |
Title : thawThis method is the reverse of the freeze(). The supplied primary_id becomes the primary_id() of the returned Bio::SeqFeatureI object. This implementation checks for a deserialized object in the cache before it calls thaw_object() to do the actual deserialization. |
| thaw_object | code | prev | next | Top |
Title : thaw_objectAfter thaw() checks the cache and comes up empty, this method is invoked to thaw the object. |
| feature_names | code | prev | next | Top |
Title : feature_namesThis is an internal utility function which, given a Bio::SeqFeatureI object, returns two array refs. The first is a list of official names for the feature, and the second is a list of aliases. This is slightly skewed towards GFF3 usage, so the official names are the display_name(), plus all tag values named 'Name', plus all tag values named 'ID'. The aliases are all tag values named 'Alias'. |
| api_version | description | prev | next | Top |
1.2}
| new | description | prev | next | Top |
my $self = shift; my ($adaptor,$serializer,$index_subfeatures,$cache,$compress,$debug,$create,$args); if (@_ == 1) { $args = {DSN => shift} } else { ($adaptor,$serializer,$index_subfeatures,$cache,$compress,$debug,$create,$args) = rearrange(['ADAPTOR', 'SERIALIZER', 'INDEX_SUBFEATURES', 'CACHE', 'COMPRESS', 'DEBUG', 'CREATE', ],@_); } $adaptor ||= 'DBI::mysql'; $args->{WRITE}++ if $create; $args->{CREATE}++ if $create; my $class = "Bio::DB::SeqFeature::Store::$adaptor"; eval "require $class " or croak $@; $cache &&= eval "require Tie::Cacher; 1"; my $obj = $class->new_instance(); $obj->debug($debug) if defined $debug; $obj->init($args); $obj->init_cache($cache) if $cache; $obj->do_compress($compress); $obj->serializer($serializer) if defined $serializer; $obj->index_subfeatures($index_subfeatures) if defined $index_subfeatures; $obj->seqfeature_class('Bio::DB::SeqFeature'); $obj->post_init($args); $obj;}
| init_database | description | prev | next | Top |
my $self = shift; $self->_init_database(@_);}
| post_init | description | prev | next | Top |
| store | description | prev | next | Top |
my $self = shift; my $result = $self->store_and_cache(1,@_);}
| store_noindex | description | prev | next | Top |
my $self = shift; $self->store_and_cache(0,@_);}
| no_blobs | description | prev | next | Top |
my $self = shift; if (@_) { $self->{no_blobs} = shift } return $self->{no_blobs} || 0;}
| new_feature | description | prev | next | Top |
my $self = shift; return $self->seqfeature_class->new(-store=>$self,@_);}
| delete | description | prev | next | Top |
my $self = shift; my $success = 1; for my $object (@_) { my $id = $object->primary_id; $success &&= $self->_deleteid($id); } $success;}
| get_feature_by_id | description | prev | next | Top |
my $self = shift; $self->fetch(@_);}
| fetch | description | prev | next | Top |
my $self = shift; @_ or croak "usage: fetch(\$primary_id)"; my $primary_id = shift; if (my $cache = $self->cache()) { return $cache->fetch($primary_id) if $cache->exists($primary_id); my $object = $self->_fetch($primary_id); $cache->store($primary_id,$object); return $object; } else { return $self->_fetch($primary_id); }}
| get_feature_by_primary_id | description | prev | next | Top |
shift->fetch(@_);}
| fetch_many | description | prev | next | Top |
my $self = shift; @_ or croak 'usage: fetch_many($id1,$id2,$id3...)'; my @ids = map {ref($_) ? @$_ : $_} @_ or return; $self->_fetch_many(@ids);}
| get_seq_stream | description | prev | next | Top |
my $self = shift; $self->_features(-iterator=>1,@_);}
| get_features_by_name | description | prev | next | Top |
my $self = shift; my ($class,$name,$types,$allow_alias); if (@_ == 1) { # get_features_by_name('name');}
$name = shift; } else { # get_features_by_name('class'=>'name'), get_feature_by_name(-name=>'name')
($class,$name,$allow_alias,$types) = rearrange([qw(CLASS NAME ALIASES),[qw(TYPE TYPES)]],@_); } # hacky workaround for assumption in Bio::DB::GFF that unclassed reference points were of type "Sequence"
undef $class if $class && $class eq 'Sequence'; $self->_features(-name=>$name,-class=>$class,-aliases=>$allow_alias,-type=>$types);
| get_feature_by_name | description | prev | next | Top |
shift->get_features_by_name(@_)}
| get_features_by_alias | description | prev | next | Top |
my $self = shift; my @args = @_; if (@_ == 1) { @args = (-name=>shift); } push @args,(-aliases=>1); $self->get_features_by_name(@args);}
| get_features_by_type | description | prev | next | Top |
my $self = shift; my @types = @_; $self->_features(-type=>\@types);}
| get_features_by_location | description | prev | next | Top |
my $self = shift; my ($seqid,$start,$end,$strand,$rangetype) = rearrange([['SEQ_ID','SEQID','REF'],'START',['STOP','END'],'STRAND','RANGE_TYPE'],@_); $self->_features(-seqid=>$seqid, -start=>$start||undef, -end=>$end||undef, -strand=>$strand||undef, -range_type=>$rangetype);}
| get_features_by_attribute | description | prev | next | Top |
my $self = shift; my %attributes = ref($_[0]) ? %{$_[0]} : @_; %attributes or $self->throw("Usage: get_feature_by_attribute(attribute_name=>\$attribute_value...)"); $self->_features(-attributes=>\%attributes); } ###}
# features() call -- main query interface
#
| features | description | prev | next | Top |
my $self = shift; my @args; if (@_ == 0) { @args = (); } elsif ($_[0] !~/^-/) { my @types = @_; @args = (-type=>\@types); } else { @args = @_; } $self->_features(@args);}
| seq_ids | description | prev | next | Top |
my $self = shift; return $self->_seq_ids();}
| search_attributes | description | prev | next | Top |
my $self = shift; my ($search_string,$attribute_names,$limit) = @_; my $attribute_array = ref $attribute_names && ref $attribute_names eq 'ARRAY' ? $attribute_names : [$attribute_names]; return $self->_search_attributes($search_string,$attribute_array,$limit);}
| search_notes | description | prev | next | Top |
my $self = shift; my ($search_string,$limit) = @_; return $self->_search_attributes($search_string,['Note'],$limit);}
| types | description | prev | next | Top |
shift->throw_not_implemented;}
| insert_sequence | description | prev | next | Top |
my $self = shift; my ($seqid,$seq,$offset) = @_; $offset ||= 0; $self->_insert_sequence($seqid,$seq,$offset);}
| fetch_sequence | description | prev | next | Top |
my $self = shift; my ($seqid,$start,$end,$class,$bioseq) = rearrange([['NAME','SEQID','SEQ_ID'], 'START',['END','STOP'],'CLASS','BIOSEQ'],@_); $seqid = "$seqid:$class" if defined $class; my $seq = $self->_fetch_sequence($seqid,$start,$end); return $seq unless $bioseq; require Bio::Seq unless Bio::Seq->can('new'); my $display_id = defined $start ? "$seqid:$start..$end" : $seqid; return Bio::Seq->new(-display_id=>$display_id,-seq=>$seq);}
| segment | description | prev | next | Top |
my $self = shift; my (@features,@args); if (@_ == 1 && blessed($_[0])) { @features = @_; @args = (); } else { @args = $self->setup_segment_args(@_); @features = $self->get_features_by_name(@args); } if (!wantarray && @features > 1) { $self->throw(<<END); segment() called in a scalar context but multiple features match. Either call in a list context or narrow your search using the -types or -class arguments END } my ($rel_start,$rel_end,$abs) = rearrange(['START',['STOP','END'],'ABSOLUTE'],@args); $rel_start = 1 unless defined $rel_start; my @segments; for my $f (@features) { my $seqid = $f->seq_id; my $strand = $f->strand; my ($start,$end); if ($abs) { $start = $rel_start; $end = defined $rel_end ? $rel_end : $start + $f->length - 1; } else { my $re = defined $rel_end ? $rel_end : $f->end - $f->start + 1; if ($strand >= 0) { $start = $f->start + $rel_start - 1; $end = $f->start + $re - 1; } else { $start = $f->end - $re + 1; $end = $f->end - $rel_start + 1; } } push @segments,Bio::DB::SeqFeature::Segment->new($self,$seqid,$start,$end,$strand); } return wantarray ? @segments : $segments[0];}
| seqfeature_class | description | prev | next | Top |
my $self = shift; my $d = $self->{seqfeatureclass}; if (@_) { my $class = shift; eval "require $class"; $self->throw("$class does not implement the Bio::SeqFeatureI interface") unless $class->isa('Bio::SeqFeatureI'); $self->{seqfeatureclass} = $class; } $d;}
| reindex | description | prev | next | Top |
my $self = shift; my $count = 0; my $now; my $last_time = time(); $self->_start_reindexing; my $iterator = $self->get_seq_stream; while (my $f = $iterator->next_seq) { if (++$count %1000 == 0) { $now = time(); my $elapsed = sprintf(" in %5.2fs",$now - $last_time); $last_time = $now; print STDERR "$count features indexed$elapsed...",' 'x60; print STDERR -t STDOUT && !$ENV{EMACS} ? "\r" : "\n"; } $self->_update_indexes($f); } $self->_end_reindexing;}
| attributes | description | prev | next | Top |
my $self = shift; shift->throw_not_implemented;}
| start_bulk_update | description | prev | next | Top |
shift->_start_bulk_update(@_)}
| finish_bulk_update | description | prev | next | Top |
shift->_finish_bulk_update(@_)}
| add_SeqFeature | description | prev | next | Top |
shift->_add_SeqFeature(@_)}
| fetch_SeqFeatures | description | prev | next | Top |
my $self = shift; my $obj = shift; return unless defined $obj->primary_id; $self->_fetch_SeqFeatures($obj,@_);}
| debug | description | prev | next | Top |
my $self = shift; my $d = $self->{debug}; $self->{debug} = shift if @_; $d;}
| serializer | description | prev | next | Top |
my $self = shift; my $d = $self->setting('serializer'); if (@_) { my $serializer = shift; eval "require $serializer; 1" or croak $@; $self->setting(serializer=>$serializer); if ($serializer eq 'Storable') { $Storable::forgive_me =1; $Storable::Deparse = 1; $Storable::Eval = 1; } } $d;}
| do_compress | description | prev | next | Top |
my $self = shift; if (@_) { my $do_compress = shift; $self->setting(compress => $do_compress); } my $d = $self->setting('compress'); if ($d) { eval "use Compress::Zlib; 1" or croak $@ unless Compress::Zlib->can('compress'); } $d;}
| index_subfeatures | description | prev | next | Top |
my $self = shift; my $d = $self->setting('index_subfeatures'); $self->setting('index_subfeatures'=>shift) if @_; $d;}
| clone | description | prev | next | Top |
| TIEHASH | description | prev | next | Top |
my $class = shift; return $class->new(@_);}
| STORE | description | prev | next | Top |
my $self = shift; my ($key,$feature) = @_; $key =~ /^\d+$/ && $key > 0 or croak "keys must be positive integers"; $self->load_class($feature); $feature->primary_id($key); $self->store($feature);}
| FETCH | description | prev | next | Top |
my $self = shift; $self->fetch(@_);}
| FIRSTKEY | description | prev | next | Top |
my $self = shift; $self->_firstid;}
| NEXTKEY | description | prev | next | Top |
my $self = shift; my $lastkey = shift; $self->_nextid($lastkey);}
| EXISTS | description | prev | next | Top |
my $self = shift; my $key = shift; $self->existsid($key);}
| DELETE | description | prev | next | Top |
my $self = shift; my $key = shift; $self->_deleteid($key);}
| CLEAR | description | prev | next | Top |
my $self = shift; $self->_clearall;}
| SCALAR | description | prev | next | Top |
my $self = shift; $self->_featurecount; } ###################### TO BE IMPLEMENTED BY ADAPTOR ##########}
| _init_database | description | prev | next | Top |
shift->throw_not_implemented}
| _store | description | prev | next | Top |
my $self = shift; my $indexed = shift; my @objs = @_; $self->throw_not_implemented;}
| _fetch | description | prev | next | Top |
shift->throw_not_implemented}
| _fetch_many | description | prev | next | Top |
my $self = shift; return map {$self->_fetch($_)} @_;}
| _update_indexes | description | prev | next | Top |
shift->throw_not_implemented}
| _start_reindexing | description | prev | next | Top |
| _end_reindexing | description | prev | next | Top |
| _features | description | prev | next | Top |
shift->throw_not_implemented}
| _search_attributes | description | prev | next | Top |
shift->throw_not_implemented}
| can_store_parentage | description | prev | next | Top |
return;}| _add_SeqFeature | description | prev | next | Top |
shift->throw_not_implemented}
| _fetch_SeqFeatures | description | prev | next | Top |
shift->throw_not_implemented}
| _insert_sequence | description | prev | next | Top |
shift->throw_not_implemented}
| _fetch_sequence | description | prev | next | Top |
shift->throw_not_implemented}
| _seq_ids | description | prev | next | Top |
shift->throw_not_implemented}
| _start_bulk_update | description | prev | next | Top |
| _finish_bulk_update | description | prev | next | Top |
| _firstid | description | prev | next | Top |
shift->throw_not_implemented}
| _nextid | description | prev | next | Top |
shift->throw_not_implemented}
| _existsid | description | prev | next | Top |
shift->throw_not_implemented}
| _deleteid | description | prev | next | Top |
shift->throw_not_implemented}
| _clearall | description | prev | next | Top |
shift->throw_not_implemented}
| _featurecount | description | prev | next | Top |
shift->throw_not_implemented}
| new_instance | description | prev | next | Top |
my $class = shift; return bless {},ref($class) || $class;}
| init | description | prev | next | Top |
my $self = shift; $self->default_settings();}
| default_settings | description | prev | next | Top |
my $self = shift; $self->serializer($self->default_serializer); $self->index_subfeatures(1);}
| default_serializer | description | prev | next | Top |
my $self = shift; # try Storable}
eval "require Storable; 1" and return 'Storable'; eval "require Data::Dumper; 1" and return 'Data::Dumper'; croak "Unable to load either Storable or Data::Dumper. Please provide a serializer using -serializer";
| setting | description | prev | next | Top |
my $self = shift; my $variable_name = shift; my $d = $self->{setting}{$variable_name}; $self->{setting}{$variable_name} = shift if @_; $d;}
| subfeatures_are_indexed | description | prev | next | Top |
my $self = shift; my $d = $self->setting('subfeatures_are_indexed'); $self->setting(subfeatures_are_indexed => shift) if @_; $d;}
| subfeature_types_are_indexed | description | prev | next | Top |
my $self = shift; return $self->subfeatures_are_indexed;}
| subfeature_locations_are_indexed | description | prev | next | Top |
my $self = shift; return $self->subfeatures_are_indexed;}
| setup_segment_args | description | prev | next | Top |
my $self = shift; return @_ if defined $_[0] && $_[0] =~ /^-/; return (-name=>$_[0],-start=>$_[1],-end=>$_[2]) if @_ == 3; return (-class=>$_[0],-name=>$_[1]) if @_ == 2; return (-name=>$_[0]) if @_ == 1; return;}
| store_and_cache | description | prev | next | Top |
my $self = shift; my $indexit = shift; my $result = $self->_store($indexit,@_); if (my $cache = $self->cache) { for my $obj (@_) { defined (my $id = eval {$obj->primary_id}) or next; $cache->store($id,$obj); } } $result;}
| init_cache | description | prev | next | Top |
my $self = shift; my $cache_size = shift; $cache_size = 5000 if $cache_size == 1; # in case somebody treats it as a flag}
$self->{cache} = Tie::Cacher->new($cache_size) or $self->throw("Couldn't tie cache: $!");
| cache | description | prev | next | Top |
shift->{cache}}
| load_class | description | prev | next | Top |
my $self = shift; my $obj = shift; return unless defined $obj; return if $self->{class_loaded}{ref $obj}++; unless ($obj && $obj->can('primary_id')) { my $class = ref $obj; eval "require $class"; } } #################################### Internal methods ####################}
| freeze | description | prev | next | Top |
my $self = shift; my $obj = shift; # Bio::SeqFeature::Generic contains cleanup methods, so we need to}
# localize the methods to undef temporarily so that we can serialize
local $obj->{'_root_cleanup_methods'} if exists $obj->{'_root_cleanup_methods'}; my ($id,$store); $id = $obj->primary_id(); $obj->primary_id(undef); # don't want primary ID to be stored in object
eval { $store = $obj->object_store; $obj->object_store(undef); # don't want a copy of the store in the object
}; my $serializer = $self->serializer; my $data; if ($serializer eq 'Data::Dumper') { my $d = Data::Dumper->new([$obj]); $d->Terse(1); $d->Deepcopy(1); $data = $d->Dump; } elsif ($serializer eq 'Storable') { $data = Storable::nfreeze($obj); } $obj->primary_id($id); # restore to original state
eval { $obj->object_store($store); }; $data = compress($data) if $self->do_compress; return $data;
| thaw | description | prev | next | Top |
my $self = shift; my ($obj,$primary_id) = @_; if (my $cache = $self->cache) { return $cache->fetch($primary_id) if $cache->exists($primary_id); my $object = $self->thaw_object($obj,$primary_id) or return; $cache->store($primary_id,$object); return $object; } else { return $self->thaw_object($obj,$primary_id); }}
| thaw_object | description | prev | next | Top |
my $self = shift; my ($obj,$primary_id) = @_; my $serializer = $self->serializer; my $object; $obj = uncompress($obj) if $self->do_compress; if ($serializer eq 'Data::Dumper') { $object = eval $obj; } elsif ($serializer eq 'Storable') { $object = Storable::thaw($obj); } # remember the primary ID of this object as well as the}
# identity of the store, so that we can do lazy loading;
# both of these are wrapped in an eval because not all
# bioseqfeatures support them (or want to)
$self->load_class($object); eval { $object->primary_id($primary_id); $object->object_store($self); }; $object;
| feature_names | description | prev | next | Top |
my $self = shift; my $obj = shift; my $primary_id = $obj->primary_id; my @names = $obj->display_name; push @names,$obj->get_tag_values('Name') if $obj->has_tag('Name'); push @names,$obj->get_tag_values('ID') if $obj->has_tag('ID'); @names = grep {defined $_ && $_ ne $primary_id} @names; my @aliases = grep {defined} $obj->get_tag_values('Alias') if $obj->has_tag('Alias'); return (\@names,\@aliases); } 1; __END__}
| Methods for Connecting and Initializating a Database | Top |
| Changing the Behavior of the Database | Top |
| TIE Interface | Top |
tie %h,'Bio::DB::SeqFeature::Store',-adaptor=>'DBI::mysql',-dsn=>'dbi:mysql:elegans';
$h{123} = $feature1;
$h{124} = $feature2;
print $h{123}->display_name;
| Optional methods needed to implement full TIEHASH interface | Top |
| Internal Methods | Top |
| BUGS | Top |
| SEE ALSO | Top |
| AUTHOR | Top |