| 1 | package Bio::DB::SeqFeature::Store; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 10 | $Bio::DB::SeqFeature::Store::VERSION = '1.7.3'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | Bio::DB::SeqFeature::Store -- Storage and retrieval of sequence annotation data | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | use Bio::DB::SeqFeature::Store; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # Open the feature database | ||||||||||||||||||||||||||||||||||||||||||
| 13 | my $db = Bio::DB::SeqFeature::Store->new( -adaptor => 'DBI::mysql', | ||||||||||||||||||||||||||||||||||||||||||
| 14 | -dsn => 'dbi:mysql:test', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | -create => 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # Get a feature from somewhere | ||||||||||||||||||||||||||||||||||||||||||
| 18 | my $feature = Bio::SeqFeature::Generic->new(...); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # Store it | ||||||||||||||||||||||||||||||||||||||||||
| 21 | $db->store($feature) or die "Couldn't store!"; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | # If absent, a primary ID is added to the feature when it is stored in the | ||||||||||||||||||||||||||||||||||||||||||
| 24 | # database. Retrieve the primary ID | ||||||||||||||||||||||||||||||||||||||||||
| 25 | my $id = $feature->primary_id; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # Get the feature back out | ||||||||||||||||||||||||||||||||||||||||||
| 28 | my $feature = $db->fetch($id); | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # .... which is identical to | ||||||||||||||||||||||||||||||||||||||||||
| 31 | my $feature = $db->get_feature_by_primary_id($id); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # Change the feature and update it | ||||||||||||||||||||||||||||||||||||||||||
| 34 | $f->start(100); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | $db->store($f) or die "Couldn't update!"; | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | # Get all features at once | ||||||||||||||||||||||||||||||||||||||||||
| 38 | my @features = $db->features( ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # Retrieve multiple features by primary id | ||||||||||||||||||||||||||||||||||||||||||
| 41 | my @features = $db->fetch_many(@list_of_ids); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | # ...by name | ||||||||||||||||||||||||||||||||||||||||||
| 44 | @features = $db->get_features_by_name('ZK909'); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # ...by alias | ||||||||||||||||||||||||||||||||||||||||||
| 47 | @features = $db->get_features_by_alias('sma-3'); | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | # ...by type | ||||||||||||||||||||||||||||||||||||||||||
| 50 | @features = $db->get_features_by_type('gene'); | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | # ...by location | ||||||||||||||||||||||||||||||||||||||||||
| 53 | @features = $db->get_features_by_location(-seq_id=>'Chr1',-start=>4000,-end=>600000); | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # ...by attribute | ||||||||||||||||||||||||||||||||||||||||||
| 56 | @features = $db->get_features_by_attribute({description => 'protein kinase'}) | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # ...by the GFF "Note" field | ||||||||||||||||||||||||||||||||||||||||||
| 59 | @result_list = $db->search_notes('kinase'); | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # ...by arbitrary combinations of selectors | ||||||||||||||||||||||||||||||||||||||||||
| 62 | @features = $db->features(-name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | -type => $types, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | -seq_id => $seqid, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | -start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | -end => $end, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | -attributes => $attributes); | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | # Loop through the features using an iterator | ||||||||||||||||||||||||||||||||||||||||||
| 70 | my $iterator = $db->get_seq_stream(-name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | -type => $types, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | -seq_id => $seqid, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | -start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | -end => $end, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | -attributes => $attributes); | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | while (my $feature = $iterator->next_seq) { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | # do something with the feature | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # ...limiting the search to a particular region | ||||||||||||||||||||||||||||||||||||||||||
| 82 | my $segment = $db->segment('Chr1',5000=>6000); | ||||||||||||||||||||||||||||||||||||||||||
| 83 | my @features = $segment->features(-type=>['mRNA','match']); | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | # Getting coverage statistics across a region | ||||||||||||||||||||||||||||||||||||||||||
| 86 | my $summary = $db->feature_summary('Chr1',10_000=>1_110_000); | ||||||||||||||||||||||||||||||||||||||||||
| 87 | my ($bins) = $summary->get_tag_values('coverage'); | ||||||||||||||||||||||||||||||||||||||||||
| 88 | my $first_bin = $bins->[0]; | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | # Getting & storing sequence information | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # Warning: this returns a string, and not a PrimarySeq object | ||||||||||||||||||||||||||||||||||||||||||
| 92 | $db->insert_sequence('Chr1','GATCCCCCGGGATTCCAAAA...'); | ||||||||||||||||||||||||||||||||||||||||||
| 93 | my $sequence = $db->fetch_sequence('Chr1',5000=>6000); | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | # What feature types are defined in the database? | ||||||||||||||||||||||||||||||||||||||||||
| 96 | my @types = $db->types; | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | # Create a new feature in the database | ||||||||||||||||||||||||||||||||||||||||||
| 99 | my $feature = $db->new_feature(-primary_tag => 'mRNA', | ||||||||||||||||||||||||||||||||||||||||||
| 100 | -seq_id => 'chr3', | ||||||||||||||||||||||||||||||||||||||||||
| 101 | -start => 10000, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | -end => 11000); | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | # Load an entire GFF3 file, using the GFF3 loader... | ||||||||||||||||||||||||||||||||||||||||||
| 105 | my $loader = Bio::DB::SeqFeature::Store::GFF3Loader->new(-store => $db, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | -verbose => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | -fast => 1); | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | $loader->load('./my_genome.gff3'); | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | Bio::DB::SeqFeature::Store implements the Bio::SeqFeature::CollectionI | ||||||||||||||||||||||||||||||||||||||||||
| 116 | interface to allow you to persistently store Bio::SeqFeatureI objects | ||||||||||||||||||||||||||||||||||||||||||
| 117 | in a database and to later to retrieve them by a variety of | ||||||||||||||||||||||||||||||||||||||||||
| 118 | searches. This module is similar to the older Bio::DB::GFF module, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | with the following differences: | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | =item 1. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | No limitation on Bio::SeqFeatureI implementations | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | Unlike Bio::DB::GFF, Bio::DB::SeqFeature::Store works with | ||||||||||||||||||||||||||||||||||||||||||
| 128 | any Bio::SeqFeatureI object. | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | =item 2. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | No limitation on nesting of features & subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | Bio::DB::GFF is limited to features that have at most one | ||||||||||||||||||||||||||||||||||||||||||
| 135 | level of subfeature. Bio::DB::SeqFeature::Store can work with features | ||||||||||||||||||||||||||||||||||||||||||
| 136 | that have unlimited levels of nesting. | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | =item 3. | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | No aggregators | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | The aggregator architecture, which was necessary to impose order on | ||||||||||||||||||||||||||||||||||||||||||
| 143 | the GFF2 files that Bio::DB::GFF works with, does not apply to | ||||||||||||||||||||||||||||||||||||||||||
| 144 | Bio::DB::SeqFeature::Store. It is intended to store features that obey | ||||||||||||||||||||||||||||||||||||||||||
| 145 | well-defined ontologies, such as the Sequence Ontology | ||||||||||||||||||||||||||||||||||||||||||
| 146 | (http://song.sourceforge.net). | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | =item 4. | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | No relative locations | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | All locations defined by this module are relative to an absolute | ||||||||||||||||||||||||||||||||||||||||||
| 153 | sequence ID, unlike Bio::DB::GFF which allows you to define the | ||||||||||||||||||||||||||||||||||||||||||
| 154 | location of one feature relative to another. | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | We'll discuss major concepts in Bio::DB::SeqFeature::Store and then | ||||||||||||||||||||||||||||||||||||||||||
| 159 | describe how to use the module. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | =head2 Adaptors | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | Bio::DB::SeqFeature::Store is designed to work with a variety of | ||||||||||||||||||||||||||||||||||||||||||
| 164 | storage back ends called "adaptors." Adaptors are subclasses of | ||||||||||||||||||||||||||||||||||||||||||
| 165 | Bio::DB::SeqFeature::Store and provide the interface between the | ||||||||||||||||||||||||||||||||||||||||||
| 166 | store() and fetch() methods and the physical database. Currently the | ||||||||||||||||||||||||||||||||||||||||||
| 167 | number of adaptors is quite limited, but the number will grow soon. | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | =item memory | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | An implementation that stores all data in memory. This is useful for | ||||||||||||||||||||||||||||||||||||||||||
| 174 | small data sets of no more than 10,000 features (more or less, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | depending on system memory). | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | =item DBI::mysql | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | A full-featured implementation on top of the MySQL relational database | ||||||||||||||||||||||||||||||||||||||||||
| 180 | system. | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | =item berkeleydb | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | A full-feature implementation that runs on top of the BerkeleyDB | ||||||||||||||||||||||||||||||||||||||||||
| 185 | database. See L<Bio::DB::SeqFeature::Store::berkeleydb>. | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | If you do not explicitly specify the adaptor, then DBI::mysql will be | ||||||||||||||||||||||||||||||||||||||||||
| 191 | used by default. | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | =head2 Serializers | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | When Bio::DB::SeqFeature::Store stores a Bio::SeqFeatureI object into | ||||||||||||||||||||||||||||||||||||||||||
| 196 | the database, it serializes it into binary or text form. When it later | ||||||||||||||||||||||||||||||||||||||||||
| 197 | fetches the feature from the database, it unserializes it. Two | ||||||||||||||||||||||||||||||||||||||||||
| 198 | serializers are available: Recent versions of | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | =item Storable | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | This is a fast binary serializer. It is available in Perl versions | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 5.8.7 and higher and is used when available. | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | =item Data::Dumper | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | This is a slow text serializer that is available in Perl 5.8.0 and | ||||||||||||||||||||||||||||||||||||||||||
| 210 | higher. It is used when Storable is unavailable. | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | If you do not specify the serializer, then Storable will be used if | ||||||||||||||||||||||||||||||||||||||||||
| 215 | available; otherwise Data::Dumper. | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | =head2 Loaders and Normalized Features | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | The Bio::DB::SeqFeature::Store::GFF3Loader parses a GFF3-format file | ||||||||||||||||||||||||||||||||||||||||||
| 220 | and loads the annotations and sequence data into the database of your | ||||||||||||||||||||||||||||||||||||||||||
| 221 | choice. The script bp_seqfeature_load.pl (found in the | ||||||||||||||||||||||||||||||||||||||||||
| 222 | scripts/Bio-SeqFeature-Store/ subdirectory) is a thin front end to the | ||||||||||||||||||||||||||||||||||||||||||
| 223 | GFF3Loader. Other loaders may be written later. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | Although Bio::DB::SeqFeature::Store should work with any | ||||||||||||||||||||||||||||||||||||||||||
| 226 | Bio::SeqFeatureI object, there are some disadvantages to using | ||||||||||||||||||||||||||||||||||||||||||
| 227 | Bio::SeqFeature::Generic and other vanilla implementations. The major | ||||||||||||||||||||||||||||||||||||||||||
| 228 | issue is that if two vanilla features share the same subfeature | ||||||||||||||||||||||||||||||||||||||||||
| 229 | (e.g. two transcripts sharing an exon), the shared subfeature will be | ||||||||||||||||||||||||||||||||||||||||||
| 230 | cloned when stored into the database. | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | The special-purpose L<Bio::DB::SeqFeature> class is able to normalize | ||||||||||||||||||||||||||||||||||||||||||
| 233 | its subfeatures in the database, so that shared subfeatures are stored | ||||||||||||||||||||||||||||||||||||||||||
| 234 | only once. This minimizes wasted storage space. In addition, when | ||||||||||||||||||||||||||||||||||||||||||
| 235 | in-memory caching is turned on, each shared subfeature will usually | ||||||||||||||||||||||||||||||||||||||||||
| 236 | occupy only a single memory location upon restoration. | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 10 | ▶ | use base 'Bio::SeqFeature::CollectionI'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 10 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 10 | ▶ | use Bio::DB::GFF::Util::Rearrange; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 10 | ▶ | use Bio::DB::SeqFeature::Segment; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 10 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | # this probably shouldn't be here | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 10 | ▶ | use Bio::DB::SeqFeature; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 10 | *dna = *get_dna = *get_sequence = \&fetch_sequence; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 10 | *get_SeqFeatures = \&fetch_SeqFeatures; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | # local version | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub api_version { 1.2 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | =head1 Methods for Connecting and Initializating a Database | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | ## TODO: http://iowg.brcdevel.org/gff3.html#a_fasta is a dead link | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | Title : new | ||||||||||||||||||||||||||||||||||||||||||
| 266 | Usage : $db = Bio::DB::SeqFeature::Store->new(@options) | ||||||||||||||||||||||||||||||||||||||||||
| 267 | Function: connect to a database | ||||||||||||||||||||||||||||||||||||||||||
| 268 | Returns : A descendent of Bio::DB::Seqfeature::Store | ||||||||||||||||||||||||||||||||||||||||||
| 269 | Args : several - see below | ||||||||||||||||||||||||||||||||||||||||||
| 270 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | This class method creates a new database connection. The following | ||||||||||||||||||||||||||||||||||||||||||
| 273 | -name=E<gt>$value arguments are accepted: | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | Name Value | ||||||||||||||||||||||||||||||||||||||||||
| 276 | ---- ----- | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | -adaptor The name of the Adaptor class (default DBI::mysql) | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | -serializer The name of the serializer class (default Storable) | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | -index_subfeatures Whether or not to make subfeatures searchable | ||||||||||||||||||||||||||||||||||||||||||
| 283 | (default false) | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | -cache Activate LRU caching feature -- size of cache | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | -compress Compresses features before storing them in database | ||||||||||||||||||||||||||||||||||||||||||
| 288 | using Compress::Zlib | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | -create (Re)initialize the database. | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | The B<-index_subfeatures> argument, if true, tells the module to | ||||||||||||||||||||||||||||||||||||||||||
| 293 | create indexes for a feature and all its subfeatures (and its | ||||||||||||||||||||||||||||||||||||||||||
| 294 | subfeatures' subfeatures). Indexing subfeatures means that you will be | ||||||||||||||||||||||||||||||||||||||||||
| 295 | able to search for the gene, its mRNA subfeatures and the exons inside | ||||||||||||||||||||||||||||||||||||||||||
| 296 | each mRNA. It also means when you search the database for all features | ||||||||||||||||||||||||||||||||||||||||||
| 297 | contained within a particular location, you will get the gene, the | ||||||||||||||||||||||||||||||||||||||||||
| 298 | mRNAs and all the exons as individual objects as well as subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 299 | of each other. NOTE: this option is only honored when working with a | ||||||||||||||||||||||||||||||||||||||||||
| 300 | normalized feature class such as Bio::DB::SeqFeature. | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | The B<-cache> argument, if true, tells the module to try to create a | ||||||||||||||||||||||||||||||||||||||||||
| 303 | LRU (least-recently-used) object cache using the Tie::Cacher | ||||||||||||||||||||||||||||||||||||||||||
| 304 | module. Caching will cause two objects that share the same primary_id | ||||||||||||||||||||||||||||||||||||||||||
| 305 | to (often, but not always) share the same memory location, and may | ||||||||||||||||||||||||||||||||||||||||||
| 306 | improve performance modestly. The argument is taken as the desired | ||||||||||||||||||||||||||||||||||||||||||
| 307 | size for the cache. If you pass "1" as the cache value, a reasonable | ||||||||||||||||||||||||||||||||||||||||||
| 308 | default cache size will be chosen. Caching requires the Tie::Cacher | ||||||||||||||||||||||||||||||||||||||||||
| 309 | module to be installed. If the module is not installed, then caching | ||||||||||||||||||||||||||||||||||||||||||
| 310 | will silently be disabled. | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | The B<-compress> argument, if true, will cause the feature data to be | ||||||||||||||||||||||||||||||||||||||||||
| 313 | compressed before storing it. This will make the database somewhat | ||||||||||||||||||||||||||||||||||||||||||
| 314 | smaller at the cost of decreasing performance. | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | The B<-create> argument, if true, will either initialize or | ||||||||||||||||||||||||||||||||||||||||||
| 317 | reinitialize the database. It is needed the first time a database is | ||||||||||||||||||||||||||||||||||||||||||
| 318 | used. | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | The new() method of individual adaptors recognize additional | ||||||||||||||||||||||||||||||||||||||||||
| 321 | arguments. The default DBI::mysql adaptor recognizes the following | ||||||||||||||||||||||||||||||||||||||||||
| 322 | ones: | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | Name Value | ||||||||||||||||||||||||||||||||||||||||||
| 325 | ---- ----- | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | -dsn DBI data source (default dbi:mysql:test) | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | -autoindex A flag that controls whether or not to update | ||||||||||||||||||||||||||||||||||||||||||
| 330 | all search indexes whenever a feature is stored | ||||||||||||||||||||||||||||||||||||||||||
| 331 | or updated (default true). | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | -namespace A string that will be used to qualify each table, | ||||||||||||||||||||||||||||||||||||||||||
| 334 | thereby allowing you to store several independent | ||||||||||||||||||||||||||||||||||||||||||
| 335 | sequence feature databases in a single Mysql | ||||||||||||||||||||||||||||||||||||||||||
| 336 | database. | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | -dumpdir The path to a temporary directory that will be | ||||||||||||||||||||||||||||||||||||||||||
| 339 | used during "fast" loading. See | ||||||||||||||||||||||||||||||||||||||||||
| 340 | L<Bio::DB::SeqFeature::Store::GFF3Loader> for a | ||||||||||||||||||||||||||||||||||||||||||
| 341 | description of this. Default is the current | ||||||||||||||||||||||||||||||||||||||||||
| 342 | directory. | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | -write Make the database writable (implied by -create) | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | -fasta Provide an alternative DNA accessor object or path. | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | By default the database will store DNA sequences internally. However, | ||||||||||||||||||||||||||||||||||||||||||
| 349 | you may override this behavior by passing either a path to a FASTA | ||||||||||||||||||||||||||||||||||||||||||
| 350 | file, or any Perl object that recognizes the seq($seqid,$start,$end) | ||||||||||||||||||||||||||||||||||||||||||
| 351 | method. In the former case, the FASTA path will be passed to | ||||||||||||||||||||||||||||||||||||||||||
| 352 | Bio::DB::Fasta, possibly causing an index to be constructed. Suitable | ||||||||||||||||||||||||||||||||||||||||||
| 353 | examples of the latter type of object include the Bio::DB::Sam and | ||||||||||||||||||||||||||||||||||||||||||
| 354 | Bio::DB::Sam::Fai classes. | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 359 | # object constructor | ||||||||||||||||||||||||||||||||||||||||||
| 360 | # | ||||||||||||||||||||||||||||||||||||||||||
| 361 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my ($adaptor,$serializer,$index_subfeatures,$cache,$compress,$debug,$create,$fasta,$args); | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $args = {DSN => shift} | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ($adaptor,$serializer,$index_subfeatures,$cache,$compress,$debug,$create,$fasta,$args) = | |||||||||||||||||||||||||||||||||||||||||
| 369 | rearrange(['ADAPTOR', | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 'SERIALIZER', | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 'INDEX_SUBFEATURES', | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 'CACHE', | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 'COMPRESS', | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 'DEBUG', | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 'CREATE', | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 'FASTA', | ||||||||||||||||||||||||||||||||||||||||||
| 377 | ],@_); | ||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | $adaptor ||= 'DBI::mysql'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$adaptor ||= "DBI::mysql"
MC/DC0%0/1
$adaptor ||= "DBI::mysql"
$adaptor
Truth table0%0/2
A
A= $adaptor
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | $args->{WRITE}++ if $create; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $args->{CREATE}++ if $create; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my $class = "Bio::DB::SeqFeature::Store::$adaptor"; | |||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | eval "require $class " or croak $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | $cache &&= eval "require Tie::Cacher; 1"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$cache &&= eval "require Tie::Cacher; 1"
MC/DC0%0/2
$cache &&= eval "require Tie::Cacher; 1"
$cache
eval "require Tie::Cacher; 1"
Truth table0%0/3
A &&= B
A= $cacheB= eval "require Tie::Cacher; 1"
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $obj = $class->new_instance(); | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | $obj->debug($debug) if defined $debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $obj->init($args); | |||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | $obj->init_cache($cache) if $cache; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $obj->do_compress($compress); | |||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | $obj->serializer($serializer) if defined $serializer; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | $obj->index_subfeatures($index_subfeatures) if defined $index_subfeatures; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $obj->seqfeature_class('Bio::DB::SeqFeature'); | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | $obj->set_dna_accessor($fasta) if defined $fasta; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $obj->post_init($args); | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $obj; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | =head2 init_database | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | Title : init_database | ||||||||||||||||||||||||||||||||||||||||||
| 402 | Usage : $db->init_database([$erase_flag]) | ||||||||||||||||||||||||||||||||||||||||||
| 403 | Function: initialize a database | ||||||||||||||||||||||||||||||||||||||||||
| 404 | Returns : true | ||||||||||||||||||||||||||||||||||||||||||
| 405 | Args : (optional) flag to erase current data | ||||||||||||||||||||||||||||||||||||||||||
| 406 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | Call this after Bio::DB::SeqFeature::Store-E<gt>new() to initialize a | ||||||||||||||||||||||||||||||||||||||||||
| 409 | new database. In the case of a DBI database, this method installs the | ||||||||||||||||||||||||||||||||||||||||||
| 410 | schema but does B<not> create the database. You have to do this | ||||||||||||||||||||||||||||||||||||||||||
| 411 | offline using the appropriate command-line tool. In the case of the | ||||||||||||||||||||||||||||||||||||||||||
| 412 | "berkeleydb" adaptor, this creates an empty BTREE database. | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | If there is any data already in the database, init_database() called | ||||||||||||||||||||||||||||||||||||||||||
| 415 | with no arguments will have no effect. To permanently erase the data | ||||||||||||||||||||||||||||||||||||||||||
| 416 | already there and prepare to receive a fresh set of data, pass a true | ||||||||||||||||||||||||||||||||||||||||||
| 417 | argument. | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 422 | # wipe database clean and reinstall schema | ||||||||||||||||||||||||||||||||||||||||||
| 423 | # | ||||||||||||||||||||||||||||||||||||||||||
| 424 | sub init_database { | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_database: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $self->_init_database(@_); | |||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | =head2 post_init | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | This method is invoked after init_database for use by certain adaptors | ||||||||||||||||||||||||||||||||||||||||||
| 432 | (currently only the memory adaptor) to do automatic data loading after | ||||||||||||||||||||||||||||||||||||||||||
| 433 | initialization. It is passed a copy of the init_database() args. | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | ▶ | sub post_init { } | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post_init: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | =head2 add_features | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | Title : add_features | ||||||||||||||||||||||||||||||||||||||||||
| 443 | Usage : $success = $db->add_features(\@features) | ||||||||||||||||||||||||||||||||||||||||||
| 444 | Function: store one or more features into the database | ||||||||||||||||||||||||||||||||||||||||||
| 445 | Returns : true if successful | ||||||||||||||||||||||||||||||||||||||||||
| 446 | Args : array reference of Bio::SeqFeatureI objects | ||||||||||||||||||||||||||||||||||||||||||
| 447 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | sub add_features { | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | my ($self, $feats) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_features: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $result = $self->store_and_cache(1, @$feats); | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | =head2 store | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | Title : store | ||||||||||||||||||||||||||||||||||||||||||
| 459 | Usage : $success = $db->store(@features) | ||||||||||||||||||||||||||||||||||||||||||
| 460 | Function: store one or more features into the database | ||||||||||||||||||||||||||||||||||||||||||
| 461 | Returns : true if successful | ||||||||||||||||||||||||||||||||||||||||||
| 462 | Args : list of Bio::SeqFeatureI objects | ||||||||||||||||||||||||||||||||||||||||||
| 463 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | This method stores a list of features into the database. Each feature | ||||||||||||||||||||||||||||||||||||||||||
| 466 | is updated so that its primary_id becomes the primary ID of the | ||||||||||||||||||||||||||||||||||||||||||
| 467 | serialized feature stored in the database. If all features were | ||||||||||||||||||||||||||||||||||||||||||
| 468 | successfully stored, the method returns true. In the DBI | ||||||||||||||||||||||||||||||||||||||||||
| 469 | implementation, the store is performed as a single transaction and the | ||||||||||||||||||||||||||||||||||||||||||
| 470 | transaction is rolled back if one or more store operations failed. | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | In most cases, you should let the database assign the primary id. If | ||||||||||||||||||||||||||||||||||||||||||
| 473 | the object you store already has a primary_id, then the ID must adhere | ||||||||||||||||||||||||||||||||||||||||||
| 474 | to the datatype expected by the adaptor: an integer in the | ||||||||||||||||||||||||||||||||||||||||||
| 475 | case of the various DB adaptors, and a string in the case of the | ||||||||||||||||||||||||||||||||||||||||||
| 476 | memory and berkeley adaptors. | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | You can find out what the primary ID of the feature has become by | ||||||||||||||||||||||||||||||||||||||||||
| 479 | calling the feature's primary_id() method: | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | $db->store($my_feature) or die "Oh darn"; | ||||||||||||||||||||||||||||||||||||||||||
| 482 | my $id = $my_feature->primary_id; | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | If the feature contains subfeatures, they will all be stored | ||||||||||||||||||||||||||||||||||||||||||
| 485 | recursively. In the case of Bio::DB::SeqFeature and | ||||||||||||||||||||||||||||||||||||||||||
| 486 | Bio::DB::SeqFeature::Store::NormalizedFeature, the subfeatures will be | ||||||||||||||||||||||||||||||||||||||||||
| 487 | stored in a normalized way so that each subfeature appears just once | ||||||||||||||||||||||||||||||||||||||||||
| 488 | in the database. | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | Subfeatures will be indexed for separate retrieval based on the | ||||||||||||||||||||||||||||||||||||||||||
| 491 | current value of index_subfeatures(). | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | If you call store() with one or more features that already have valid | ||||||||||||||||||||||||||||||||||||||||||
| 494 | primary_ids, then any existing objects will be B<replaced>. Note that | ||||||||||||||||||||||||||||||||||||||||||
| 495 | when using normalized features such as Bio::DB::SeqFeature, the | ||||||||||||||||||||||||||||||||||||||||||
| 496 | subfeatures are not recursively updated when you update the parent | ||||||||||||||||||||||||||||||||||||||||||
| 497 | feature. You must manually update each subfeatures that has changed. | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 502 | # store one or more Bio::SeqFeatureI objects | ||||||||||||||||||||||||||||||||||||||||||
| 503 | # if they already have a primary_id will replace into the database | ||||||||||||||||||||||||||||||||||||||||||
| 504 | # otherwise will insert and primary_id will be added | ||||||||||||||||||||||||||||||||||||||||||
| 505 | # | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | # this version stores the object and flags it to be indexed | ||||||||||||||||||||||||||||||||||||||||||
| 508 | # for search via attributes, name, type or location | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | sub store { | ||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | my ($self, @feats) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
store: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | for my $feat (@feats) { | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | if ( (not ref $feat) || (not $feat->isa('Bio::SeqFeatureI')) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $feat and $feat->isa("Bio::SeqFeatureI")
MC/DC0%0/2
ref $feat and $feat->isa("Bio::SeqFeatureI")
ref $feat
$feat->isa("Bio::SeqFeatureI")
Truth table0%0/3
A and B
A= ref $featB= $feat->isa("Bio::SeqFeatureI")
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | die "Cannot store non-Bio::SeqFeatureI object '$feat'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my $result = $self->store_and_cache(1,@feats); | |||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | =head2 store_noindex | ||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | Title : store_noindex | ||||||||||||||||||||||||||||||||||||||||||
| 523 | Usage : $success = $db->store_noindex(@features) | ||||||||||||||||||||||||||||||||||||||||||
| 524 | Function: store one or more features into the database without indexing | ||||||||||||||||||||||||||||||||||||||||||
| 525 | Returns : true if successful | ||||||||||||||||||||||||||||||||||||||||||
| 526 | Args : list of Bio::SeqFeatureI objects | ||||||||||||||||||||||||||||||||||||||||||
| 527 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | This method stores a list of features into the database but does not | ||||||||||||||||||||||||||||||||||||||||||
| 530 | make them searchable. The only way to access the features is via their | ||||||||||||||||||||||||||||||||||||||||||
| 531 | primary IDs. This method is ordinarily only used internally to store | ||||||||||||||||||||||||||||||||||||||||||
| 532 | subfeatures that are not indexed. | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | # this version stores the object and flags it so that it is | ||||||||||||||||||||||||||||||||||||||||||
| 537 | # not searchable via attributes, name, type or location | ||||||||||||||||||||||||||||||||||||||||||
| 538 | # (typically used only for subfeatures) | ||||||||||||||||||||||||||||||||||||||||||
| 539 | sub store_noindex { | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
store_noindex: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $self->store_and_cache(0,@_); | |||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | =head2 no_blobs | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | Title : no_blobs | ||||||||||||||||||||||||||||||||||||||||||
| 547 | Usage : $db->no_blobs(1); | ||||||||||||||||||||||||||||||||||||||||||
| 548 | Function: decide if objects should be stored in the database as blobs. | ||||||||||||||||||||||||||||||||||||||||||
| 549 | Returns : boolean (default false) | ||||||||||||||||||||||||||||||||||||||||||
| 550 | Args : boolean (true to no longer store objects; when the corresponding | ||||||||||||||||||||||||||||||||||||||||||
| 551 | feature is retrieved it will instead be a minimal representation of | ||||||||||||||||||||||||||||||||||||||||||
| 552 | the object that was stored, as some simple Bio::SeqFeatureI object) | ||||||||||||||||||||||||||||||||||||||||||
| 553 | Status : dubious (new) | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | This method saves lots of space in the database, which may in turn lead to large | ||||||||||||||||||||||||||||||||||||||||||
| 556 | performance increases in extreme cases (over 7 million features in the db). | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | sub no_blobs { | ||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
no_blobs: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | if (@_) { $self->{no_blobs} = shift } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | return $self->{no_blobs} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'no_blobs'} || 0
MC/DC0%0/1
$self->{'no_blobs'} || 0
$self->{'no_blobs'}
Truth table0%0/2
A
A= $self->{'no_blobs'}
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | =head2 new_feature | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | Title : new_feature | ||||||||||||||||||||||||||||||||||||||||||
| 569 | Usage : $feature = $db->new_feature(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 570 | Function: create a new Bio::DB::SeqFeature object in the database | ||||||||||||||||||||||||||||||||||||||||||
| 571 | Returns : the new seqfeature | ||||||||||||||||||||||||||||||||||||||||||
| 572 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 573 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | This method creates and stores a new Bio::SeqFeatureI object using the | ||||||||||||||||||||||||||||||||||||||||||
| 576 | specialized Bio::DB::SeqFeature class. This class is able to store its | ||||||||||||||||||||||||||||||||||||||||||
| 577 | subfeatures in a normalized fashion, allowing subfeatures to be shared | ||||||||||||||||||||||||||||||||||||||||||
| 578 | among multiple parents (e.g. multiple exons shared among several | ||||||||||||||||||||||||||||||||||||||||||
| 579 | mRNAs). | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | The arguments are the same as for Bio::DB::SeqFeature-E<gt>new(), which in | ||||||||||||||||||||||||||||||||||||||||||
| 582 | turn are similar to Bio::SeqFeature::Generic-E<gt>new() and | ||||||||||||||||||||||||||||||||||||||||||
| 583 | Bio::Graphics::Feature-E<gt>new(). The most important difference is the | ||||||||||||||||||||||||||||||||||||||||||
| 584 | B<-index> option, which controls whether the feature will be indexed | ||||||||||||||||||||||||||||||||||||||||||
| 585 | for retrieval (default is true). Ordinarily, you would only want to | ||||||||||||||||||||||||||||||||||||||||||
| 586 | turn indexing off when creating subfeatures, because features stored | ||||||||||||||||||||||||||||||||||||||||||
| 587 | without indexes will only be reachable via their primary IDs or their | ||||||||||||||||||||||||||||||||||||||||||
| 588 | parents. | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | Arguments are as follows: | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | -seq_id the reference sequence | ||||||||||||||||||||||||||||||||||||||||||
| 593 | -start the start position of the feature | ||||||||||||||||||||||||||||||||||||||||||
| 594 | -end the stop position of the feature | ||||||||||||||||||||||||||||||||||||||||||
| 595 | -display_name the feature name (returned by seqname) | ||||||||||||||||||||||||||||||||||||||||||
| 596 | -primary_tag the feature type (returned by primary_tag) | ||||||||||||||||||||||||||||||||||||||||||
| 597 | -source the source tag | ||||||||||||||||||||||||||||||||||||||||||
| 598 | -score the feature score (for GFF compatibility) | ||||||||||||||||||||||||||||||||||||||||||
| 599 | -desc a description of the feature | ||||||||||||||||||||||||||||||||||||||||||
| 600 | -segments a list of subfeatures (see Bio::Graphics::Feature) | ||||||||||||||||||||||||||||||||||||||||||
| 601 | -subtype the type to use when creating subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 602 | -strand the strand of the feature (one of -1, 0 or +1) | ||||||||||||||||||||||||||||||||||||||||||
| 603 | -phase the phase of the feature (0..2) | ||||||||||||||||||||||||||||||||||||||||||
| 604 | -url a URL to link to when rendered with Bio::Graphics | ||||||||||||||||||||||||||||||||||||||||||
| 605 | -attributes a hashref of tag value attributes, in which the key is the tag | ||||||||||||||||||||||||||||||||||||||||||
| 606 | and the value is an array reference of values | ||||||||||||||||||||||||||||||||||||||||||
| 607 | -index index this feature if true | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | Aliases: | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | -id an alias for -display_name | ||||||||||||||||||||||||||||||||||||||||||
| 612 | -seqname an alias for -display_name | ||||||||||||||||||||||||||||||||||||||||||
| 613 | -display_id an alias for -display_name | ||||||||||||||||||||||||||||||||||||||||||
| 614 | -name an alias for -display_name | ||||||||||||||||||||||||||||||||||||||||||
| 615 | -stop an alias for end | ||||||||||||||||||||||||||||||||||||||||||
| 616 | -type an alias for primary_tag | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | You can change the seqfeature implementation generated by new() by | ||||||||||||||||||||||||||||||||||||||||||
| 619 | passing the name of the desired seqfeature class to | ||||||||||||||||||||||||||||||||||||||||||
| 620 | $db-E<gt>seqfeature_class(). | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | sub new_feature { | ||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_feature: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return $self->seqfeature_class->new(-store=>$self,@_); | |||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | =head2 delete | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | Title : delete | ||||||||||||||||||||||||||||||||||||||||||
| 632 | Usage : $success = $db->delete(@features) | ||||||||||||||||||||||||||||||||||||||||||
| 633 | Function: delete a list of feature from the database | ||||||||||||||||||||||||||||||||||||||||||
| 634 | Returns : true if successful | ||||||||||||||||||||||||||||||||||||||||||
| 635 | Args : list of features | ||||||||||||||||||||||||||||||||||||||||||
| 636 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | This method looks up the primary IDs from a list of features and | ||||||||||||||||||||||||||||||||||||||||||
| 639 | deletes them from the database, returning true if all deletions are | ||||||||||||||||||||||||||||||||||||||||||
| 640 | successful. | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | WARNING: The current DBI::mysql implementation has some issues that | ||||||||||||||||||||||||||||||||||||||||||
| 643 | need to be resolved, namely (1) normalized subfeatures are NOT | ||||||||||||||||||||||||||||||||||||||||||
| 644 | recursively deleted; and (2) the deletions are not performed in a | ||||||||||||||||||||||||||||||||||||||||||
| 645 | transaction. | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | sub delete { | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my $success = 1; | |||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | for my $object (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | my $id = $object->primary_id; | |||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if ( not defined $id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | warn "Could not delete feature without primary_id: $object"; | |||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $success = 0; | |||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $result = $self->_deleteid($id); | |||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | warn "Could not delete feature with id=$id" unless $result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | $success &&= $result; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$success &&= $result
MC/DC0%0/2
$success &&= $result
$success
$result
Truth table0%0/3
A &&= B
A= $successB= $result
| |||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $success; | |||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | =head2 fetch / get_feature_by_id / get_feature_by_primary_id | ||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||
| 668 | Title : fetch | ||||||||||||||||||||||||||||||||||||||||||
| 669 | get_feature_by_id | ||||||||||||||||||||||||||||||||||||||||||
| 670 | get_feature_by_primary_id | ||||||||||||||||||||||||||||||||||||||||||
| 671 | Usage : $feature = $db->fetch($primary_id) | ||||||||||||||||||||||||||||||||||||||||||
| 672 | Function: fetch a feature from the database using its primary ID | ||||||||||||||||||||||||||||||||||||||||||
| 673 | Returns : a feature | ||||||||||||||||||||||||||||||||||||||||||
| 674 | Args : primary ID of desired feature | ||||||||||||||||||||||||||||||||||||||||||
| 675 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | This method returns a previously-stored feature from the database | ||||||||||||||||||||||||||||||||||||||||||
| 678 | using its primary ID. If the primary ID is invalid, it returns undef. | ||||||||||||||||||||||||||||||||||||||||||
| 679 | Use fetch_many() to rapidly retrieve multiple features. | ||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 684 | # Fetch a Bio::SeqFeatureI from database using its primary_id | ||||||||||||||||||||||||||||||||||||||||||
| 685 | # | ||||||||||||||||||||||||||||||||||||||||||
| 686 | sub fetch { | ||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | @_ or croak "usage: fetch(\$primary_id)"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my $primary_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | if (my $cache = $self->cache()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | return $cache->fetch($primary_id) if $cache->exists($primary_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my $object = $self->_fetch($primary_id); | |||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | $cache->store($primary_id,$object); | |||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | return $object; | |||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 696 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | return $self->_fetch($primary_id); | |||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 700 | 10 | *get_feature_by_id = *get_feature_by_primary_id = \&fetch; | |||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | =head2 fetch_many | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | Title : fetch_many | ||||||||||||||||||||||||||||||||||||||||||
| 705 | Usage : @features = $db->fetch_many($primary_id,$primary_id,$primary_id...) | ||||||||||||||||||||||||||||||||||||||||||
| 706 | Function: fetch many features from the database using their primary ID | ||||||||||||||||||||||||||||||||||||||||||
| 707 | Returns : list of features | ||||||||||||||||||||||||||||||||||||||||||
| 708 | Args : a list of primary IDs or an array ref of primary IDs | ||||||||||||||||||||||||||||||||||||||||||
| 709 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | Same as fetch() except that you can pass a list of primary IDs or a | ||||||||||||||||||||||||||||||||||||||||||
| 712 | ref to an array of IDs. | ||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 717 | # Efficiently fetch a series of IDs from the database | ||||||||||||||||||||||||||||||||||||||||||
| 718 | # Can pass an array or an array ref | ||||||||||||||||||||||||||||||||||||||||||
| 719 | # | ||||||||||||||||||||||||||||||||||||||||||
| 720 | sub fetch_many { | ||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_many: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | @_ or croak 'usage: fetch_many($id1,$id2,$id3...)'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | my @ids = map {ref($_) ? @$_ : $_} @_ or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | $self->_fetch_many(@ids); | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | =head2 get_seq_stream | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | Title : get_seq_stream | ||||||||||||||||||||||||||||||||||||||||||
| 730 | Usage : $iterator = $db->get_seq_stream(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 731 | Function: return an iterator across all features in the database | ||||||||||||||||||||||||||||||||||||||||||
| 732 | Returns : a Bio::DB::SeqFeature::Store::Iterator object | ||||||||||||||||||||||||||||||||||||||||||
| 733 | Args : feature filters (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 734 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | When called without any arguments this method will return an iterator | ||||||||||||||||||||||||||||||||||||||||||
| 737 | object that will traverse all indexed features in the database. Call | ||||||||||||||||||||||||||||||||||||||||||
| 738 | the iterator's next_seq() method to step through them (in no | ||||||||||||||||||||||||||||||||||||||||||
| 739 | particular order): | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | my $iterator = $db->get_seq_stream; | ||||||||||||||||||||||||||||||||||||||||||
| 742 | while (my $feature = $iterator->next_seq) { | ||||||||||||||||||||||||||||||||||||||||||
| 743 | print $feature->primary_tag,' ',$feature->display_name,"\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | You can select a subset of features by passing a series of filter | ||||||||||||||||||||||||||||||||||||||||||
| 747 | arguments. The arguments are identical to those accepted by | ||||||||||||||||||||||||||||||||||||||||||
| 748 | $db-E<gt>features(). | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 753 | # Return an iterator across all features that are indexable | ||||||||||||||||||||||||||||||||||||||||||
| 754 | # | ||||||||||||||||||||||||||||||||||||||||||
| 755 | sub get_seq_stream { | ||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_seq_stream: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | $self->_features(-iterator=>1,@_); | |||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | =head2 get_features_by_name | ||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | Title : get_features_by_name | ||||||||||||||||||||||||||||||||||||||||||
| 763 | Usage : @features = $db->get_features_by_name($name) | ||||||||||||||||||||||||||||||||||||||||||
| 764 | Function: looks up features by their display_name | ||||||||||||||||||||||||||||||||||||||||||
| 765 | Returns : a list of matching features | ||||||||||||||||||||||||||||||||||||||||||
| 766 | Args : the desired name | ||||||||||||||||||||||||||||||||||||||||||
| 767 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | This method searches the display_name of all features for matches | ||||||||||||||||||||||||||||||||||||||||||
| 770 | against the provided name. GLOB style wildcares ("*", "?") are | ||||||||||||||||||||||||||||||||||||||||||
| 771 | accepted, but may be slow. | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | The method returns the list of matches, which may be zero, 1 or more | ||||||||||||||||||||||||||||||||||||||||||
| 774 | than one features. Be prepared to receive more than one result, as | ||||||||||||||||||||||||||||||||||||||||||
| 775 | display names are not guaranteed to be unique. | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | For backward compatibility with gbrowse, this method is also known as | ||||||||||||||||||||||||||||||||||||||||||
| 778 | get_feature_by_name(). | ||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 783 | # get_feature_by_name() return 0 or more features using a name lookup | ||||||||||||||||||||||||||||||||||||||||||
| 784 | # uses the Bio::DB::GFF API | ||||||||||||||||||||||||||||||||||||||||||
| 785 | # | ||||||||||||||||||||||||||||||||||||||||||
| 786 | sub get_features_by_name { | ||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_features_by_name: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | my ($class,$name,$types,$allow_alias); | |||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | if (@_ == 1) { # get_features_by_name('name'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 792 | } else { # get_features_by_name('class'=>'name'), get_feature_by_name(-name=>'name') | ||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | ($class,$name,$allow_alias,$types) = rearrange([qw(CLASS NAME ALIASES),[qw(TYPE TYPES)]],@_); | |||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | # hacky workaround for assumption in Bio::DB::GFF that unclassed reference points were of type "Sequence" | ||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | undef $class if $class && $class eq 'Sequence'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class and $class eq "Sequence"
MC/DC0%0/2
$class and $class eq "Sequence"
$class
$class eq "Sequence"
Truth table0%0/3
A and B
A= $classB= $class eq "Sequence"
| |||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | $self->_features(-name=>$name,-class=>$class,-aliases=>$allow_alias,-type=>$types); | |||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | =head2 get_feature_by_name | ||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||
| 804 | Title : get_feature_by_name | ||||||||||||||||||||||||||||||||||||||||||
| 805 | Usage : @features = $db->get_feature_by_name($name) | ||||||||||||||||||||||||||||||||||||||||||
| 806 | Function: looks up features by their display_name | ||||||||||||||||||||||||||||||||||||||||||
| 807 | Returns : a list of matching features | ||||||||||||||||||||||||||||||||||||||||||
| 808 | Args : the desired name | ||||||||||||||||||||||||||||||||||||||||||
| 809 | Status : Use get_features_by_name instead. | ||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | This method is provided for backward compatibility with gbrowse. | ||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | sub get_feature_by_name { shift->get_features_by_name(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_feature_by_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | =head2 get_features_by_alias | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | Title : get_features_by_alias | ||||||||||||||||||||||||||||||||||||||||||
| 820 | Usage : @features = $db->get_features_by_alias($name) | ||||||||||||||||||||||||||||||||||||||||||
| 821 | Function: looks up features by their display_name or alias | ||||||||||||||||||||||||||||||||||||||||||
| 822 | Returns : a list of matching features | ||||||||||||||||||||||||||||||||||||||||||
| 823 | Args : the desired name | ||||||||||||||||||||||||||||||||||||||||||
| 824 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | This method is similar to get_features_by_name() except that it will | ||||||||||||||||||||||||||||||||||||||||||
| 827 | also search through the feature aliases. Aliases can be created by | ||||||||||||||||||||||||||||||||||||||||||
| 828 | storing features that contain one or more Alias tags. Wildards are | ||||||||||||||||||||||||||||||||||||||||||
| 829 | accepted. | ||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | sub get_features_by_alias { | ||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_features_by_alias: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | @args = (-name=>shift); | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | push @args,(-aliases=>1); | |||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | $self->get_features_by_name(@args); | |||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||
| 843 | =head2 get_features_by_type | ||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||
| 845 | Title : get_features_by_type | ||||||||||||||||||||||||||||||||||||||||||
| 846 | Usage : @features = $db->get_features_by_type(@types) | ||||||||||||||||||||||||||||||||||||||||||
| 847 | Function: looks up features by their primary_tag | ||||||||||||||||||||||||||||||||||||||||||
| 848 | Returns : a list of matching features | ||||||||||||||||||||||||||||||||||||||||||
| 849 | Args : list of primary tags | ||||||||||||||||||||||||||||||||||||||||||
| 850 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | This method will return a list of features that have any of the | ||||||||||||||||||||||||||||||||||||||||||
| 853 | primary tags given in the argument list. For compatibility with | ||||||||||||||||||||||||||||||||||||||||||
| 854 | gbrowse and Bio::DB::GFF, types can be qualified using a colon: | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | primary_tag:source_tag | ||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | in which case only features that match both the primary_tag B<and> the | ||||||||||||||||||||||||||||||||||||||||||
| 859 | indicated source_tag will be returned. If the database was loaded from | ||||||||||||||||||||||||||||||||||||||||||
| 860 | a GFF3 file, this corresponds to the third and second columns of the | ||||||||||||||||||||||||||||||||||||||||||
| 861 | row, in that order. | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | For example, given the GFF3 lines: | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | ctg123 geneFinder exon 1300 1500 . + . ID=exon001 | ||||||||||||||||||||||||||||||||||||||||||
| 866 | ctg123 fgenesH exon 1300 1520 . + . ID=exon002 | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | exon001 and exon002 will be returned by searching for type "exon", but | ||||||||||||||||||||||||||||||||||||||||||
| 869 | only exon001 will be returned by searching for type "exon:fgenesH". | ||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||
| 873 | sub get_features_by_type { | ||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_features_by_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | my @types = @_; | |||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | $self->_features(-type=>\@types); | |||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | =head2 get_features_by_location | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | Title : get_features_by_location | ||||||||||||||||||||||||||||||||||||||||||
| 882 | Usage : @features = $db->get_features_by_location(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 883 | Function: looks up features by their location | ||||||||||||||||||||||||||||||||||||||||||
| 884 | Returns : a list of matching features | ||||||||||||||||||||||||||||||||||||||||||
| 885 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 886 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | This method fetches features based on a location range lookup. You | ||||||||||||||||||||||||||||||||||||||||||
| 889 | call it using a positional list of arguments, or a list of | ||||||||||||||||||||||||||||||||||||||||||
| 890 | (-argument=E<gt>$value) pairs. | ||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | The positional form is as follows: | ||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | $db->get_features_by_location($seqid [[,$start,]$end]) | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | The $seqid is the name of the sequence on which the feature resides, | ||||||||||||||||||||||||||||||||||||||||||
| 897 | and start and end are optional endpoints for the match. If the | ||||||||||||||||||||||||||||||||||||||||||
| 898 | endpoints are missing then any feature on the indicated seqid is | ||||||||||||||||||||||||||||||||||||||||||
| 899 | returned. | ||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||
| 901 | Examples: | ||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | get_features_by_location('chr1'); # all features on chromosome 1 | ||||||||||||||||||||||||||||||||||||||||||
| 904 | get_features_by_location('chr1',5000); # features between 5000 and the end | ||||||||||||||||||||||||||||||||||||||||||
| 905 | get_features_by_location('chr1',5000,8000); # features between 5000 and 8000 | ||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | Location lookups are overlapping. A feature will be returned if it | ||||||||||||||||||||||||||||||||||||||||||
| 908 | partially or completely overlaps the indicated range. | ||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||
| 910 | The named argument form gives you more control: | ||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | Argument Value | ||||||||||||||||||||||||||||||||||||||||||
| 913 | -------- ----- | ||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | -seq_id The name of the sequence on which the feature resides | ||||||||||||||||||||||||||||||||||||||||||
| 916 | -start Start of the range | ||||||||||||||||||||||||||||||||||||||||||
| 917 | -end End of the range | ||||||||||||||||||||||||||||||||||||||||||
| 918 | -strand Strand of the feature | ||||||||||||||||||||||||||||||||||||||||||
| 919 | -range_type Type of range to search over | ||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | The B<-strand> argument, if present, can be one of "0" to find | ||||||||||||||||||||||||||||||||||||||||||
| 922 | features that are on both strands, "+1" to find only plus strand | ||||||||||||||||||||||||||||||||||||||||||
| 923 | features, and "-1" to find only minus strand features. Specifying a | ||||||||||||||||||||||||||||||||||||||||||
| 924 | strand of undef is the same as not specifying this argument at all, | ||||||||||||||||||||||||||||||||||||||||||
| 925 | and retrieves all features regardless of their strandedness. | ||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | The B<-range_type> argument, if present, can be one of "overlaps" (the | ||||||||||||||||||||||||||||||||||||||||||
| 928 | default), to find features whose positions overlap the indicated | ||||||||||||||||||||||||||||||||||||||||||
| 929 | range, "contains," to find features whose endpoints are completely | ||||||||||||||||||||||||||||||||||||||||||
| 930 | contained within the indicated range, and "contained_in" to find | ||||||||||||||||||||||||||||||||||||||||||
| 931 | features whose endpoints are both outside the indicated range. | ||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||
| 933 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | sub get_features_by_location { | ||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_features_by_location: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | my ($seqid,$start,$end,$strand,$rangetype) = | |||||||||||||||||||||||||||||||||||||||||
| 938 | rearrange([['SEQ_ID','SEQID','REF'],'START',['STOP','END'],'STRAND','RANGE_TYPE'],@_); | ||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | $self->_features(-seqid=>$seqid, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$start || undef
$end || undef
$strand || undef
MC/DC0%0/1
$start || undef
$start
MC/DC0%0/1
$end || undef
$end
MC/DC0%0/1
$strand || undef
$strand
Truth table0%0/2
A
A= $start
Truth table0%0/2
A
A= $end
Truth table0%0/2
A
A= $strand
| |||||||||||||||||||||||||||||||||||||||||||
| 940 | -start=>$start||undef, | ||||||||||||||||||||||||||||||||||||||||||
| 941 | -end=>$end||undef, | ||||||||||||||||||||||||||||||||||||||||||
| 942 | -strand=>$strand||undef, | ||||||||||||||||||||||||||||||||||||||||||
| 943 | -range_type=>$rangetype); | ||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | =head2 get_features_by_attribute | ||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||
| 948 | Title : get_features_by_attribute | ||||||||||||||||||||||||||||||||||||||||||
| 949 | Usage : @features = $db->get_features_by_attribute(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 950 | Function: looks up features by their attributes/tags | ||||||||||||||||||||||||||||||||||||||||||
| 951 | Returns : a list of matching features | ||||||||||||||||||||||||||||||||||||||||||
| 952 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 953 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | This implements a simple tag filter. Pass a list of tag names and | ||||||||||||||||||||||||||||||||||||||||||
| 956 | their values. The module will return a list of features whose tag | ||||||||||||||||||||||||||||||||||||||||||
| 957 | names and values match. Tag names are case insensitive. If multiple | ||||||||||||||||||||||||||||||||||||||||||
| 958 | tag name/value pairs are present, they will be ANDed together. To | ||||||||||||||||||||||||||||||||||||||||||
| 959 | match any of a list of values, use an array reference for the value. | ||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | Examples: | ||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | # return all features whose "function" tag is "GO:0000123" | ||||||||||||||||||||||||||||||||||||||||||
| 964 | @features = $db->get_features_by_attribute(function => 'GO:0000123'); | ||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | # return all features whose "function" tag is "GO:0000123" or "GO:0000555" | ||||||||||||||||||||||||||||||||||||||||||
| 967 | @features = $db->get_features_by_attribute(function => ['GO:0000123','GO:0000555']); | ||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||
| 969 | # return all features whose "function" tag is "GO:0000123" or "GO:0000555" | ||||||||||||||||||||||||||||||||||||||||||
| 970 | # and whose "confirmed" tag is 1 | ||||||||||||||||||||||||||||||||||||||||||
| 971 | @features = $db->get_features_by_attribute(function => ['GO:0000123','GO:0000555'], | ||||||||||||||||||||||||||||||||||||||||||
| 972 | confirmed => 1); | ||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | sub get_features_by_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_features_by_attribute: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | my %attributes = ref($_[0]) ? %{$_[0]} : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | %attributes or $self->throw("Usage: get_feature_by_attribute(attribute_name=>\$attribute_value...)"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | $self->_features(-attributes=>\%attributes); | |||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||
| 982 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 983 | # features() call -- main query interface | ||||||||||||||||||||||||||||||||||||||||||
| 984 | # | ||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | =head2 features | ||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | Title : features | ||||||||||||||||||||||||||||||||||||||||||
| 989 | Usage : @features = $db->features(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 990 | Function: generalized query & retrieval interface | ||||||||||||||||||||||||||||||||||||||||||
| 991 | Returns : list of features | ||||||||||||||||||||||||||||||||||||||||||
| 992 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 993 | Status : Public | ||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||
| 995 | This is the workhorse for feature query and retrieval. It takes a | ||||||||||||||||||||||||||||||||||||||||||
| 996 | series of -name=E<gt>$value arguments filter arguments. Features that | ||||||||||||||||||||||||||||||||||||||||||
| 997 | match all the filters are returned. | ||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||
| 999 | Argument Value | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | -------- ----- | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||
| 1002 | Location filters: | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | -seq_id Chromosome, contig or other DNA segment | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | -seqid Synonym for -seq_id | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | -ref Synonym for -seqid | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | -start Start of range | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | -end End of range | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | -stop Synonym for -end | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | -strand Strand | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | -range_type Type of range match ('overlaps','contains','contained_in') | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||
| 1012 | Name filters: | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | -name Name of feature (may be a glob expression) | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | -aliases If true, match aliases as well as display names | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | -class Archaic argument for backward compatibility. | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | (-class=>'Clone',-name=>'ABC123') is equivalent | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | to (-name=>'Clone:ABC123') | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||
| 1019 | Type filters: | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | -types List of feature types (array reference) or one type (scalar) | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | -type Synonym for the above | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | -primary_tag Synonym for the above | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||
| 1024 | -attributes Hashref of attribute=>value pairs as per | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | get_features_by_attribute(). Multiple alternative values | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | can be matched by providing an array reference. | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | -attribute synonym for -attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||
| 1029 | You may also provide features() with a list of scalar values (the | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | first element of which must B<not> begin with a dash), in which case | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | it will treat the list as a feature type filter. | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||
| 1033 | Examples: | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||
| 1035 | All features: | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | @features = $db->features( ); | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | All features on chromosome 1: | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | @features = $db->features(-seqid=>'Chr1'); | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | All features on chromosome 1 between 5000 and 6000: | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | @features = $db->features(-seqid=>'Chr1',-start=>5000,-end=>6000); | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||
| 1046 | All mRNAs on chromosome 1 between 5000 and 6000: | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | @features = $db->features(-seqid=>'Chr1',-start=>5000,-end=>6000,-types=>'mRNA'); | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||
| 1050 | All confirmed mRNAs and repeats on chromosome 1 that overlap the range 5000..6000: | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||
| 1052 | @features = $db->features(-seqid => 'Chr1',-start=>5000,-end=>6000, | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | -types => ['mRNA','repeat'], | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | -attributes=> {confirmed=>1} | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | All confirmed mRNAs and repeats on chromosome 1 strictly contained within the range 5000..6000: | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | @features = $db->features(-seqid => 'Chr1',-start=>5000,-end=>6000, | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | -types => ['mRNA','repeat'], | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | -attributes=> {confirmed=>1} | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | -range_type => 'contained_in', | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | All genes and repeats: | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||
| 1067 | @features = $db->features('gene','repeat_region'); | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||
| 1069 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||
| 1071 | # documentation of args | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | # my ($seq_id,$start,$end,$strand, | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | # $name,$class,$allow_aliases, | ||||||||||||||||||||||||||||||||||||||||||
| 1074 | # $types, | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | # $attributes, | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | # $range_type, | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | # $iterator, | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | # ) = rearrange([['SEQID','SEQ_ID','REF'],'START',['STOP','END'],'STRAND', | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | # 'NAME','CLASS','ALIASES', | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | # ['TYPES','TYPE','PRIMARY_TAG'], | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | # ['ATTRIBUTES','ATTRIBUTE'], | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | # 'RANGE_TYPE', | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | # ],@_); | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | # $range_type ||= 'overlaps'; | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | sub features { | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
features: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | ▶ | if (@_ == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | @args = (); | |||||||||||||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | elsif ($_[0] !~/^-/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | my @types = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | @args = (-type=>\@types); | |||||||||||||||||||||||||||||||||||||||||
| 1094 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | $self->_features(@args); | |||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||
| 1101 | =head2 get_all_features | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | Title : get_all_features | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | Usage : @features = $db->get_all_features() | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | Function: get all feature in the database | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | Returns : list of features | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | Status : Public | ||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||
| 1110 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||
| 1112 | # for compatibility with Bio::SeqFeature::Collection | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | sub get_all_features { | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | ▶ | shift->features(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_features: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | =head2 seq_ids | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||
| 1119 | Title : seq_ids | ||||||||||||||||||||||||||||||||||||||||||
| 1120 | Usage : @ids = $db->seq_ids() | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | Function: Return all sequence IDs contained in database | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | Returns : list of sequence Ids | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||
| 1126 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||
| 1128 | sub seq_ids { | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seq_ids: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | return $self->_seq_ids(); | |||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||
| 1133 | =head2 search_attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||
| 1135 | Title : search_attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | Usage : @result_list = $db->search_attributes("text search string",[$tag1,$tag2...],$limit) | ||||||||||||||||||||||||||||||||||||||||||
| 1137 | Function: Search attributes for keywords occurring in a text string | ||||||||||||||||||||||||||||||||||||||||||
| 1138 | Returns : array of results | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | Args : full text search string, array ref of attribute names, and an optional feature limit | ||||||||||||||||||||||||||||||||||||||||||
| 1140 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||
| 1142 | Given a search string, this method performs a full-text search of the | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | specified attributes and returns an array of results. You may pass a | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | scalar attribute name to search the values of one attribute | ||||||||||||||||||||||||||||||||||||||||||
| 1145 | (e.g. "Note") or you may pass an array reference to search inside | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | multiple attributes (['Note','Alias','Parent']).Each row of the | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | returned array is a arrayref containing the following fields: | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||
| 1149 | column 1 The display name of the feature | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | column 2 The text of the note | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | column 3 A relevance score. | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | column 4 The feature type | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | column 5 The unique ID of the feature | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||
| 1155 | NOTE: This search will fail to find features that do not have a display name! | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||||||||||||
| 1157 | You can use fetch() or fetch_many() with the returned IDs to get to | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | the features themselves. | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||
| 1160 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||
| 1162 | sub search_attributes { | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_attributes: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | my ($search_string,$attribute_names,$limit) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | ▶ | my $attribute_array = ref $attribute_names | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $attribute_names and ref $attribute_names eq "ARRAY"
MC/DC0%0/2
ref $attribute_names and ref $attribute_names eq "ARRAY"
ref $attribute_names
ref $attribute_names eq "ARRAY"
Truth table0%0/3
A and B
A= ref $attribute_namesB= ref $attribute_names eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 1166 | && ref $attribute_names eq 'ARRAY' ? $attribute_names : [$attribute_names]; | ||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | return $self->_search_attributes($search_string,$attribute_array,$limit); | |||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||
| 1170 | =head2 search_notes | ||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||
| 1172 | Title : search_notes | ||||||||||||||||||||||||||||||||||||||||||
| 1173 | Usage : @result_list = $db->search_notes("full text search string",$limit) | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | Function: Search the notes for a text string | ||||||||||||||||||||||||||||||||||||||||||
| 1175 | Returns : array of results | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | Args : full text search string, and an optional feature limit | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||
| 1179 | Given a search string, this method performs a full-text search of the | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | "Notes" attribute and returns an array of results. Each row of the | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | returned array is a arrayref containing the following fields: | ||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||
| 1183 | column 1 The display_name of the feature, suitable for passing to get_feature_by_name() | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | column 2 The text of the note | ||||||||||||||||||||||||||||||||||||||||||
| 1185 | column 3 A relevance score. | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | column 4 The type | ||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||
| 1188 | NOTE: This is equivalent to $db-E<gt>search_attributes('full text search | ||||||||||||||||||||||||||||||||||||||||||
| 1189 | string','Note',$limit). This search will fail to find features that do | ||||||||||||||||||||||||||||||||||||||||||
| 1190 | not have a display name! | ||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||
| 1192 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||
| 1194 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | # search_notes() | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | sub search_notes { | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_notes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | my ($search_string,$limit) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | return $self->_search_attributes($search_string,['Note'],$limit); | |||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||
| 1203 | =head2 types | ||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||
| 1205 | Title : types | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | Usage : @type_list = $db->types | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | Function: Get all the types in the database | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | Returns : array of Bio::DB::GFF::Typename objects | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1210 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||
| 1212 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | sub types { | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | ▶ | shift->throw_not_implemented; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
types: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||
| 1218 | =head2 insert_sequence | ||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||
| 1220 | Title : insert_sequence | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | Usage : $success = $db->insert_sequence($seqid,$sequence_string,$offset) | ||||||||||||||||||||||||||||||||||||||||||
| 1222 | Function: Inserts sequence data into the database at the indicated offset | ||||||||||||||||||||||||||||||||||||||||||
| 1223 | Returns : true if successful | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||
| 1227 | This method inserts the DNA or protein sequence fragment | ||||||||||||||||||||||||||||||||||||||||||
| 1228 | $sequence_string, identified by the ID $seq_id, into the database at | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | the indicated offset $offset. It is used internally by the GFF3Loader | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | to load sequence data from the files. | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||
| 1232 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1235 | # insert_sequence() | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | # insert a bit of primary sequence into the database | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1239 | sub insert_sequence { | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_sequence: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | my ($seqid,$seq,$offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | ▶ | $offset ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$offset ||= 0
MC/DC0%0/1
$offset ||= 0
$offset
Truth table0%0/2
A
A= $offset
| |||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | $self->_insert_sequence($seqid,$seq,$offset); | |||||||||||||||||||||||||||||||||||||||||
| 1244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||
| 1247 | =head2 fetch_sequence | ||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||
| 1249 | Title : fetch_sequence | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | Usage : $sequence = $db->fetch_sequence(-seq_id=>$seqid,-start=>$start,-end=>$end) | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | Function: Fetch the indicated subsequene from the database | ||||||||||||||||||||||||||||||||||||||||||
| 1252 | Returns : The sequence string (not a Bio::PrimarySeq object!) | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||
| 1256 | This method retrieves a portion of the indicated sequence. The arguments are: | ||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||
| 1258 | Argument Value | ||||||||||||||||||||||||||||||||||||||||||
| 1259 | -------- ----- | ||||||||||||||||||||||||||||||||||||||||||
| 1260 | -seq_id Chromosome, contig or other DNA segment | ||||||||||||||||||||||||||||||||||||||||||
| 1261 | -seqid Synonym for -seq_id | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | -name Synonym for -seq_id | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | -start Start of range | ||||||||||||||||||||||||||||||||||||||||||
| 1264 | -end End of range | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | -class Obsolete argument used for Bio::DB::GFF compatibility. If | ||||||||||||||||||||||||||||||||||||||||||
| 1266 | specified will qualify the seq_id as "$class:$seq_id". | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | -bioseq Boolean flag; if true, returns a Bio::PrimarySeq object instead | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | of a sequence string. | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | You can call fetch_sequence using the following shortcuts: | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||
| 1272 | $seq = $db->fetch_sequence('chr3'); # entire chromosome | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | $seq = $db->fetch_sequence('chr3',1000); # position 1000 to end of chromosome | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | $seq = $db->fetch_sequence('chr3',undef,5000); # position 1 to 5000 | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | $seq = $db->fetch_sequence('chr3',1000,5000); # positions 1000 to 5000 | ||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||
| 1277 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||
| 1279 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1280 | # fetch_sequence() | ||||||||||||||||||||||||||||||||||||||||||
| 1281 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | # equivalent to old Bio::DB::GFF->dna() method | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1284 | sub fetch_sequence { | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_sequence: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | my ($seqid,$start,$end,$class,$bioseq) = rearrange([['NAME','SEQID','SEQ_ID'], | |||||||||||||||||||||||||||||||||||||||||
| 1287 | 'START',['END','STOP'],'CLASS','BIOSEQ'],@_); | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | ▶ | $seqid = "$seqid:$class" if defined $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | my $seq = $self->seq($seqid,$start,$end); | |||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | ▶ | return $seq unless $bioseq; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | ▶ | require Bio::Seq unless Bio::Seq->can('new'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | ▶ | my $display_id = defined $start ? "$seqid:$start..$end" : $seqid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | return Bio::Seq->new(-display_id=>$display_id,-seq=>$seq); | |||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||
| 1297 | =head2 segment | ||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||
| 1299 | Title : segment | ||||||||||||||||||||||||||||||||||||||||||
| 1300 | Usage : $segment = $db->segment($seq_id [,$start] [,$end] [,$absolute]) | ||||||||||||||||||||||||||||||||||||||||||
| 1301 | Function: restrict the database to a sequence range | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | Returns : a Bio::DB::SeqFeature::Segment object | ||||||||||||||||||||||||||||||||||||||||||
| 1303 | Args : sequence id, start and end ranges (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 1304 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||||||||||
| 1306 | This is a convenience method that can be used when you are interested | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | in the contents of a particular sequence landmark, such as a | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | contig. Specify the ID of a sequence or other landmark in the database | ||||||||||||||||||||||||||||||||||||||||||
| 1309 | and optionally a start and endpoint relative to that landmark. The | ||||||||||||||||||||||||||||||||||||||||||
| 1310 | method will look up the region and return a | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | Bio::DB::SeqFeature::Segment object that spans it. You can then use | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | this segment object to make location-restricted queries on the database. | ||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||
| 1314 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||
| 1316 | $segment = $db->segment('contig23',1,1000); # first 1000 bp of contig23 | ||||||||||||||||||||||||||||||||||||||||||
| 1317 | my @mRNAs = $segment->features('mRNA'); # all mRNAs that overlap segment | ||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||
| 1319 | Although you will usually want to fetch segments that correspond to | ||||||||||||||||||||||||||||||||||||||||||
| 1320 | physical sequences in the database, you can actually use any feature | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | in the database as the sequence ID. The segment() method will perform | ||||||||||||||||||||||||||||||||||||||||||
| 1322 | a get_features_by_name() internally and then transform the feature | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | into the appropriate coordinates. | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||
| 1325 | The named feature should exist once and only once in the database. If | ||||||||||||||||||||||||||||||||||||||||||
| 1326 | it exists multiple times in the database and you attempt to call | ||||||||||||||||||||||||||||||||||||||||||
| 1327 | segment() in a scalar context, you will get an exception. A workaround | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | is to call the method in a list context, as in: | ||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||
| 1330 | my ($segment) = $db->segment('contig23',1,1000); | ||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||
| 1332 | or | ||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||
| 1334 | my @segments = $db->segment('contig23',1,1000); | ||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||
| 1336 | However, having multiple same-named features in the database is often | ||||||||||||||||||||||||||||||||||||||||||
| 1337 | an indication of underlying data problems. | ||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||
| 1339 | If the optional $absolute argument is a true value, then the specified | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | coordinates are relative to the reference (absolute) coordinates. | ||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||
| 1342 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||
| 1344 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1345 | # Replacement for Bio::DB::GFF->segment() method | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | sub segment { | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
segment: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | my (@features,@args); | |||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | ▶ | if (@_ == 1 && blessed($_[0])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and builtin::blessed($_[0])
MC/DC0%0/2
@_ == 1 and builtin::blessed($_[0])
@_ == 1
builtin::blessed($_[0])
Truth table0%0/3
A and B
A= @_ == 1B= builtin::blessed($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | @features = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | @args = (); | |||||||||||||||||||||||||||||||||||||||||
| 1354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1355 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | @args = $self->setup_segment_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | @features = $self->get_features_by_name(@args); | |||||||||||||||||||||||||||||||||||||||||
| 1358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | ▶ | if (!wantarray && @features > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not wantarray and @features > 1
MC/DC0%0/2
not wantarray and @features > 1
not wantarray
@features > 1
Truth table0%0/3
not(A) and B
A= not wantarrayB= @features > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | $self->throw(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 1361 | segment() called in a scalar context but multiple features match. | ||||||||||||||||||||||||||||||||||||||||||
| 1362 | Either call in a list context or narrow your search using the -types or -class arguments | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | my ($rel_start,$rel_end,$abs) = rearrange(['START',['STOP','END'],'ABSOLUTE'],@args); | |||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | ▶ | $rel_start = 1 unless defined $rel_start; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | my @segments; | |||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | for my $f (@features) { | |||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | my $seqid = $f->seq_id; | |||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | my $strand = $f->strand; | |||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | my ($start,$end); | |||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | ▶ | if ($abs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | $start = $rel_start; | |||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | ▶ | $end = defined $rel_end ? $rel_end : $start + $f->length - 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1377 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | ▶ | my $re = defined $rel_end ? $rel_end : $f->end - $f->start + 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | ▶ | if ($strand >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | $start = $f->start + $rel_start - 1; | |||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | $end = $f->start + $re - 1; | |||||||||||||||||||||||||||||||||||||||||
| 1383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1384 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | $start = $f->end - $re + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | $end = $f->end - $rel_start + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | my $id = eval{$f->primary_id}; | |||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | push @segments,Bio::DB::SeqFeature::Segment->new($self,$seqid,$start,$end,$strand,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | ▶ | return wantarray ? @segments : $segments[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||
| 1395 | =head2 seqfeature_class | ||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||
| 1397 | Title : seqfeature_class | ||||||||||||||||||||||||||||||||||||||||||
| 1398 | Usage : $classname = $db->seqfeature_class([$new_classname]) | ||||||||||||||||||||||||||||||||||||||||||
| 1399 | Function: get or set the name of the Bio::SeqFeatureI class generated by new_feature() | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | Returns : name of class | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | Args : new classname (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||
| 1404 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||
| 1406 | sub seqfeature_class { | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seqfeature_class: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | my $d = $self->{seqfeatureclass}; | |||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | eval "require $class"; | |||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | ▶ | $self->throw("$class does not implement the Bio::SeqFeatureI interface") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1413 | unless $class->isa('Bio::SeqFeatureI'); | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | $self->{seqfeatureclass} = $class; | |||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 1417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||
| 1419 | =head2 reindex | ||||||||||||||||||||||||||||||||||||||||||
| 1420 | |||||||||||||||||||||||||||||||||||||||||||
| 1421 | Title : reindex | ||||||||||||||||||||||||||||||||||||||||||
| 1422 | Usage : $db->reindex | ||||||||||||||||||||||||||||||||||||||||||
| 1423 | Function: reindex the database | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | Returns : nothing | ||||||||||||||||||||||||||||||||||||||||||
| 1425 | Args : nothing | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||
| 1428 | This method will force the secondary indexes (name, location, | ||||||||||||||||||||||||||||||||||||||||||
| 1429 | attributes, feature types) to be recalculated. It may be useful to | ||||||||||||||||||||||||||||||||||||||||||
| 1430 | rebuild a corrupted database. | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||
| 1432 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||
| 1434 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | # force reindexing | ||||||||||||||||||||||||||||||||||||||||||
| 1436 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1437 | sub reindex { | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reindex: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | my $now; | |||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | my $last_time = time(); | |||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | $self->_start_reindexing; | |||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | my $iterator = $self->get_seq_stream; | |||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | ▶ | while (my $f = $iterator->next_seq) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | ▶ | if (++$count %1000 == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | $now = time(); | |||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | my $elapsed = sprintf(" in %5.2fs",$now - $last_time); | |||||||||||||||||||||||||||||||||||||||||
| 1451 | 0 | $last_time = $now; | |||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | print STDERR "$count features indexed$elapsed...",' 'x60; | |||||||||||||||||||||||||||||||||||||||||
| 1453 | 0 | ▶ | print STDERR -t STDOUT && !$ENV{EMACS} ? "\r" : "\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-t STDOUT and not $ENV{"EMACS"}
MC/DC0%0/2
-t STDOUT and not $ENV{"EMACS"}
-t STDOUT
not $ENV{"EMACS"}
Truth table0%0/3
A and not(B)
A= -t STDOUTB= not $ENV{"EMACS"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | $self->_update_indexes($f); | |||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||
| 1458 | 0 | $self->_end_reindexing; | |||||||||||||||||||||||||||||||||||||||||
| 1459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||
| 1461 | =head2 attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||
| 1463 | Title : attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1464 | Usage : @a = $db->attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | Function: Returns list of all known attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1466 | Returns : Returns list of all known attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | Args : nothing | ||||||||||||||||||||||||||||||||||||||||||
| 1468 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||
| 1470 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||
| 1472 | sub attributes { | ||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attributes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1474 | 0 | shift->throw_not_implemented; | |||||||||||||||||||||||||||||||||||||||||
| 1475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||
| 1478 | =head2 start_bulk_update,finish_bulk_update | ||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||
| 1480 | Title : start_bulk_update,finish_bulk_update | ||||||||||||||||||||||||||||||||||||||||||
| 1481 | Usage : $db->start_bulk_update | ||||||||||||||||||||||||||||||||||||||||||
| 1482 | $db->finish_bulk_update | ||||||||||||||||||||||||||||||||||||||||||
| 1483 | Function: Activate optimizations for large number of insertions/updates | ||||||||||||||||||||||||||||||||||||||||||
| 1484 | Returns : nothing | ||||||||||||||||||||||||||||||||||||||||||
| 1485 | Args : nothing | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||
| 1488 | With some adaptors (currently only the DBI::mysql adaptor), these | ||||||||||||||||||||||||||||||||||||||||||
| 1489 | methods signal the adaptor that a large number of insertions or | ||||||||||||||||||||||||||||||||||||||||||
| 1490 | updates are to be performed, and activate certain optimizations. These | ||||||||||||||||||||||||||||||||||||||||||
| 1491 | methods are called automatically by the | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | Bio::DB::SeqFeature::Store::GFF3Loader module. | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||
| 1494 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||
| 1496 | $db->start_bulk_update; | ||||||||||||||||||||||||||||||||||||||||||
| 1497 | for my $f (@features) { | ||||||||||||||||||||||||||||||||||||||||||
| 1498 | $db->store($f); | ||||||||||||||||||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1500 | $db->finish_bulk_update; | ||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||
| 1502 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||
| 1504 | 0 | ▶ | sub start_bulk_update { shift->_start_bulk_update(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_bulk_update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1505 | 0 | ▶ | sub finish_bulk_update { shift->_finish_bulk_update(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish_bulk_update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||
| 1507 | =head2 add_SeqFeature | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||
| 1509 | Title : add_SeqFeature | ||||||||||||||||||||||||||||||||||||||||||
| 1510 | Usage : $count = $db->add_SeqFeature($parent,@children) | ||||||||||||||||||||||||||||||||||||||||||
| 1511 | Function: store a parent/child relationship between a $parent and @children | ||||||||||||||||||||||||||||||||||||||||||
| 1512 | features that are already stored in the database | ||||||||||||||||||||||||||||||||||||||||||
| 1513 | Returns : number of children successfully stored | ||||||||||||||||||||||||||||||||||||||||||
| 1514 | Args : parent feature or primary ID and children features or primary IDs | ||||||||||||||||||||||||||||||||||||||||||
| 1515 | Status : OPTIONAL; MAY BE IMPLEMENTED BY ADAPTORS | ||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||
| 1517 | If can_store_parentage() returns true, then some store-aware features | ||||||||||||||||||||||||||||||||||||||||||
| 1518 | (e.g. Bio::DB::SeqFeature) will invoke this method to store | ||||||||||||||||||||||||||||||||||||||||||
| 1519 | feature/subfeature relationships in a normalized table. | ||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||
| 1521 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||
| 1523 | # these two are called only if _can_store_subFeatures() returns true | ||||||||||||||||||||||||||||||||||||||||||
| 1524 | # _add_SeqFeature ($parent,@children) | ||||||||||||||||||||||||||||||||||||||||||
| 1525 | 0 | ▶ | sub add_SeqFeature { shift->_add_SeqFeature(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_SeqFeature: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||||||||||||
| 1527 | =head2 fetch_SeqFeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | |||||||||||||||||||||||||||||||||||||||||||
| 1529 | Title : fetch_SeqFeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1530 | Usage : @children = $db->fetch_SeqFeatures($parent_feature) | ||||||||||||||||||||||||||||||||||||||||||
| 1531 | Function: return the immediate subfeatures of the indicated feature | ||||||||||||||||||||||||||||||||||||||||||
| 1532 | Returns : list of subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1533 | Args : the parent feature and an optional list of children types | ||||||||||||||||||||||||||||||||||||||||||
| 1534 | Status : OPTIONAL; MAY BE IMPLEMENTED BY ADAPTORS | ||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||
| 1536 | If can_store_parentage() returns true, then some store-aware features | ||||||||||||||||||||||||||||||||||||||||||
| 1537 | (e.g. Bio::DB::SeqFeature) will invoke this method to retrieve | ||||||||||||||||||||||||||||||||||||||||||
| 1538 | feature/subfeature relationships from the database. | ||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||
| 1540 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||||||||||||
| 1542 | # _get_SeqFeatures($parent,@child_types) | ||||||||||||||||||||||||||||||||||||||||||
| 1543 | sub fetch_SeqFeatures { | ||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | ▶ | my ($self, $parent, @child_types) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_SeqFeatures: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1545 | 0 | ▶ | return unless defined $parent->primary_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | $self->_fetch_SeqFeatures($parent,@child_types); | |||||||||||||||||||||||||||||||||||||||||
| 1547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||
| 1551 | =head1 Changing the Behavior of the Database | ||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||
| 1553 | These methods allow you to modify the behavior of the database. | ||||||||||||||||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||||||||||||||||
| 1555 | =head2 debug | ||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||
| 1557 | Title : debug | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | Usage : $debug_flag = $db->debug([$new_flag]) | ||||||||||||||||||||||||||||||||||||||||||
| 1559 | Function: set the debug flag | ||||||||||||||||||||||||||||||||||||||||||
| 1560 | Returns : current debug flag | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | Args : new debug flag | ||||||||||||||||||||||||||||||||||||||||||
| 1562 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||
| 1564 | This method gets/sets a flag that turns on verbose progress | ||||||||||||||||||||||||||||||||||||||||||
| 1565 | messages. Currently this will not do very much. | ||||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||
| 1567 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||
| 1569 | sub debug { | ||||||||||||||||||||||||||||||||||||||||||
| 1570 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | my $d = $self->{debug}; | |||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | ▶ | $self->{debug} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 1574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||||||||||
| 1576 | =head2 serializer | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | |||||||||||||||||||||||||||||||||||||||||||
| 1578 | Title : serializer | ||||||||||||||||||||||||||||||||||||||||||
| 1579 | Usage : $serializer = $db->serializer([$new_serializer]) | ||||||||||||||||||||||||||||||||||||||||||
| 1580 | Function: get/set the name of the serializer | ||||||||||||||||||||||||||||||||||||||||||
| 1581 | Returns : the name of the current serializer class | ||||||||||||||||||||||||||||||||||||||||||
| 1582 | Args : (optional) the name of a new serializer | ||||||||||||||||||||||||||||||||||||||||||
| 1583 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||
| 1585 | You can use this method to set the serializer, but do not attempt to | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | change the serializer once the database is initialized and populated. | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | |||||||||||||||||||||||||||||||||||||||||||
| 1588 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||||||||||||||||
| 1590 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1591 | # serializer | ||||||||||||||||||||||||||||||||||||||||||
| 1592 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1593 | sub serializer { | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serializer: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | my $d = $self->setting('serializer'); | |||||||||||||||||||||||||||||||||||||||||
| 1596 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | my $serializer = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | ▶ | eval "require $serializer; 1" or croak $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | $self->setting(serializer=>$serializer); | |||||||||||||||||||||||||||||||||||||||||
| 1600 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 1602 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||
| 1604 | =head2 dna_accessor | ||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||
| 1606 | Title : dna_accessor | ||||||||||||||||||||||||||||||||||||||||||
| 1607 | Usage : $dna_accessor = $db->dna_accessor([$new_dna_accessor]) | ||||||||||||||||||||||||||||||||||||||||||
| 1608 | Function: get/set the name of the dna_accessor | ||||||||||||||||||||||||||||||||||||||||||
| 1609 | Returns : the current dna_accessor object, if any | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | Args : (optional) the dna_accessor object | ||||||||||||||||||||||||||||||||||||||||||
| 1611 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||
| 1613 | You can use this method to request or set the DNA accessor. | ||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||
| 1615 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||||||||||||
| 1617 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1618 | # dna_accessor | ||||||||||||||||||||||||||||||||||||||||||
| 1619 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1620 | sub dna_accessor { | ||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dna_accessor: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | my $d = $self->{dna_accessor}; | |||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | ▶ | $self->{dna_accessor} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 1625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||
| 1627 | sub can_do_seq { | ||||||||||||||||||||||||||||||||||||||||||
| 1628 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_do_seq: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1629 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1630 | return | ||||||||||||||||||||||||||||||||||||||||||
| 1631 | 0 | ▶ | UNIVERSAL::can($obj,'seq') || | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
UNIVERSAL::can($obj, 'seq') || UNIVERSAL::can($obj, 'fetch_sequence')
MC/DC0%0/2
UNIVERSAL::can($obj, 'seq') || UNIVERSAL::can($obj, 'fetch_sequence')
UNIVERSAL::can($obj, 'seq')
UNIVERSAL::can($obj, 'fetch_sequence')
Truth table0%0/3
A || B
A= UNIVERSAL::can($obj, 'seq')B= UNIVERSAL::can($obj, 'fetch_sequence')
| |||||||||||||||||||||||||||||||||||||||||||
| 1632 | UNIVERSAL::can($obj,'fetch_sequence'); | ||||||||||||||||||||||||||||||||||||||||||
| 1633 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||
| 1635 | sub set_dna_accessor { | ||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_dna_accessor: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1637 | 0 | my $accessor = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1638 | 0 | ▶ | if (-e $accessor) { # a file, assume it is a fasta file | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1639 | 0 | ▶ | eval "require Bio::DB::Fasta" unless Bio::DB::Fasta->can('new'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1640 | 0 | ▶ | my $a = Bio::DB::Fasta->new($accessor) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1641 | or croak "Can't open FASTA file $accessor: $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | $self->dna_accessor($a); | |||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | ▶ | if (ref $accessor && $self->can_do_seq($accessor)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $accessor and $self->can_do_seq($accessor)
MC/DC0%0/2
ref $accessor and $self->can_do_seq($accessor)
ref $accessor
$self->can_do_seq($accessor)
Truth table0%0/3
A and B
A= ref $accessorB= $self->can_do_seq($accessor)
| |||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | $self->dna_accessor($accessor); # already built | |||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||||||||||||||||
| 1652 | sub do_compress { | ||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_compress: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | my $do_compress = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | $self->setting(compress => $do_compress); | |||||||||||||||||||||||||||||||||||||||||
| 1657 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | my $d = $self->setting('compress'); | |||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | if ($d) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | ▶ | eval "use Compress::Zlib; 1" or croak $@ unless Compress::Zlib->can('compress'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
'Compress::Zlib'->can('compress') || (eval 'use Compress::Zlib; 1' || croak($@))
eval "use Compress::Zlib; 1" or croak($@)
MC/DC0%0/3
'Compress::Zlib'->can('compress') || (eval 'use Compress::Zlib; 1' || croak($@))
'Compress::Zlib'->can('compress')
eval "use Compress::Zlib; 1"
croak($@)
Truth table0%0/4
A || B or C
A= 'Compress::Zlib'->can('compress')B= eval "use Compress::Zlib; 1"C= croak($@)
| |||||||||||||||||||||||||||||||||||||||||||
| 1661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 1663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1664 | |||||||||||||||||||||||||||||||||||||||||||
| 1665 | =head2 index_subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||
| 1667 | Title : index_subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1668 | Usage : $flag = $db->index_subfeatures([$new_value]) | ||||||||||||||||||||||||||||||||||||||||||
| 1669 | Function: flag whether to index subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1670 | Returns : current value of the flag | ||||||||||||||||||||||||||||||||||||||||||
| 1671 | Args : (optional) new value of the flag | ||||||||||||||||||||||||||||||||||||||||||
| 1672 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||||||||||||||||
| 1674 | If true, the store() method will add a searchable index to both the | ||||||||||||||||||||||||||||||||||||||||||
| 1675 | top-level feature and all its subfeatures, allowing the search | ||||||||||||||||||||||||||||||||||||||||||
| 1676 | functions to return features at any level of the containment | ||||||||||||||||||||||||||||||||||||||||||
| 1677 | hierarchy. If false, only the top level feature will be indexed, | ||||||||||||||||||||||||||||||||||||||||||
| 1678 | meaning that you will only be able to get at subfeatures by fetching | ||||||||||||||||||||||||||||||||||||||||||
| 1679 | the top-level feature and then traversing downward using | ||||||||||||||||||||||||||||||||||||||||||
| 1680 | get_SeqFeatures(). | ||||||||||||||||||||||||||||||||||||||||||
| 1681 | |||||||||||||||||||||||||||||||||||||||||||
| 1682 | You are free to change this setting at any point during the creation | ||||||||||||||||||||||||||||||||||||||||||
| 1683 | and population of a database. One database can contain both indexed | ||||||||||||||||||||||||||||||||||||||||||
| 1684 | and unindexed subfeatures. | ||||||||||||||||||||||||||||||||||||||||||
| 1685 | |||||||||||||||||||||||||||||||||||||||||||
| 1686 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1687 | |||||||||||||||||||||||||||||||||||||||||||
| 1688 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1689 | # whether to index subfeatures by default | ||||||||||||||||||||||||||||||||||||||||||
| 1690 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1691 | sub index_subfeatures { | ||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_subfeatures: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | my $d = $self->setting('index_subfeatures'); | |||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | ▶ | $self->setting('index_subfeatures'=>shift) if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 1696 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||||||||||||||||
| 1698 | =head2 clone | ||||||||||||||||||||||||||||||||||||||||||
| 1699 | |||||||||||||||||||||||||||||||||||||||||||
| 1700 | The clone() method should be used when you want to pass the | ||||||||||||||||||||||||||||||||||||||||||
| 1701 | Bio::DB::SeqFeature::Store object to a child process across a | ||||||||||||||||||||||||||||||||||||||||||
| 1702 | fork(). The child must call clone() before making any queries. | ||||||||||||||||||||||||||||||||||||||||||
| 1703 | |||||||||||||||||||||||||||||||||||||||||||
| 1704 | The default behavior is to do nothing, but adaptors that use the DBI | ||||||||||||||||||||||||||||||||||||||||||
| 1705 | interface may need to implement this in order to avoid database handle | ||||||||||||||||||||||||||||||||||||||||||
| 1706 | errors. See the dbi adaptor for an example. | ||||||||||||||||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||||||||||||||||
| 1708 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||
| 1710 | ▶ | sub clone { } | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1711 | |||||||||||||||||||||||||||||||||||||||||||
| 1712 | ################################# TIE interface #################### | ||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||
| 1714 | =head1 TIE Interface | ||||||||||||||||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||||||||||||||||
| 1716 | This module implements a full TIEHASH interface. The keys are the | ||||||||||||||||||||||||||||||||||||||||||
| 1717 | primary IDs of the features in the database. Example: | ||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||
| 1719 | tie %h,'Bio::DB::SeqFeature::Store',-adaptor=>'DBI::mysql',-dsn=>'dbi:mysql:elegans'; | ||||||||||||||||||||||||||||||||||||||||||
| 1720 | $h{123} = $feature1; | ||||||||||||||||||||||||||||||||||||||||||
| 1721 | $h{124} = $feature2; | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | print $h{123}->display_name; | ||||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||
| 1724 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||
| 1726 | sub TIEHASH { | ||||||||||||||||||||||||||||||||||||||||||
| 1727 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | return $class->new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 1729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||||||||||||||||
| 1731 | sub STORE { | ||||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1733 | 0 | my ($key,$feature) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1734 | 0 | ▶ | $key =~ /^\d+$/ && $key > 0 or croak "keys must be positive integers"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key =~ /^\d+$/ and $key > 0
MC/DC0%0/2
$key =~ /^\d+$/ and $key > 0
$key =~ /^\d+$/
$key > 0
Truth table0%0/3
A and B
A= $key =~ /^\d+$/B= $key > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1735 | 0 | $self->load_class($feature); | |||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | $feature->primary_id($key); | |||||||||||||||||||||||||||||||||||||||||
| 1737 | 0 | $self->store($feature); | |||||||||||||||||||||||||||||||||||||||||
| 1738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||||||||||||||||
| 1740 | sub FETCH { | ||||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | $self->fetch(@_); | |||||||||||||||||||||||||||||||||||||||||
| 1743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||
| 1745 | sub FIRSTKEY { | ||||||||||||||||||||||||||||||||||||||||||
| 1746 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1747 | 0 | $self->_firstid; | |||||||||||||||||||||||||||||||||||||||||
| 1748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||||||||||
| 1750 | sub NEXTKEY { | ||||||||||||||||||||||||||||||||||||||||||
| 1751 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1752 | 0 | my $lastkey = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1753 | 0 | $self->_nextid($lastkey); | |||||||||||||||||||||||||||||||||||||||||
| 1754 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||
| 1756 | sub EXISTS { | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | $self->existsid($key); | |||||||||||||||||||||||||||||||||||||||||
| 1760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||
| 1762 | sub DELETE { | ||||||||||||||||||||||||||||||||||||||||||
| 1763 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DELETE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1764 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1765 | 0 | $self->_deleteid($key); | |||||||||||||||||||||||||||||||||||||||||
| 1766 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||
| 1768 | sub CLEAR { | ||||||||||||||||||||||||||||||||||||||||||
| 1769 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1770 | 0 | $self->_clearall; | |||||||||||||||||||||||||||||||||||||||||
| 1771 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||||||||||||||||
| 1773 | sub SCALAR { | ||||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SCALAR: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | $self->_featurecount; | |||||||||||||||||||||||||||||||||||||||||
| 1776 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1777 | |||||||||||||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||||||||||||
| 1779 | ###################### TO BE IMPLEMENTED BY ADAPTOR ########## | ||||||||||||||||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||||||||||||||||
| 1781 | =head2 _init_database | ||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||
| 1783 | Title : _init_database | ||||||||||||||||||||||||||||||||||||||||||
| 1784 | Usage : $success = $db->_init_database([$erase]) | ||||||||||||||||||||||||||||||||||||||||||
| 1785 | Function: initialize an empty database | ||||||||||||||||||||||||||||||||||||||||||
| 1786 | Returns : true on success | ||||||||||||||||||||||||||||||||||||||||||
| 1787 | Args : optional boolean flag to erase contents of an existing database | ||||||||||||||||||||||||||||||||||||||||||
| 1788 | Status : ABSTRACT METHOD; MUST BE IMPLEMENTED BY AN ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||||||||||||||||
| 1790 | This method is the back end for init_database(). It must be | ||||||||||||||||||||||||||||||||||||||||||
| 1791 | implemented by an adaptor that inherits from | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | Bio::DB::SeqFeature::Store. It returns true on success. @features = $db->features(-seqid=>'Chr1'); | ||||||||||||||||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||||||||||||||||
| 1794 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1795 | |||||||||||||||||||||||||||||||||||||||||||
| 1796 | 0 | ▶ | sub _init_database { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_database: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1797 | |||||||||||||||||||||||||||||||||||||||||||
| 1798 | =head2 _store | ||||||||||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||||||||||
| 1800 | Title : _store | ||||||||||||||||||||||||||||||||||||||||||
| 1801 | Usage : $success = $db->_store($indexed,@objects) | ||||||||||||||||||||||||||||||||||||||||||
| 1802 | Function: store seqfeature objects into database | ||||||||||||||||||||||||||||||||||||||||||
| 1803 | Returns : true on success | ||||||||||||||||||||||||||||||||||||||||||
| 1804 | Args : a boolean flag indicating whether objects are to be indexed, | ||||||||||||||||||||||||||||||||||||||||||
| 1805 | and one or more objects | ||||||||||||||||||||||||||||||||||||||||||
| 1806 | Status : ABSTRACT METHOD; MUST BE IMPLEMENTED BY AN ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||||||||||||||||
| 1808 | This method is the back end for store() and store_noindex(). It should | ||||||||||||||||||||||||||||||||||||||||||
| 1809 | write the seqfeature objects into the database. If indexing is | ||||||||||||||||||||||||||||||||||||||||||
| 1810 | requested, the features should be indexed for query and | ||||||||||||||||||||||||||||||||||||||||||
| 1811 | retrieval. Otherwise the features should be stored without indexing | ||||||||||||||||||||||||||||||||||||||||||
| 1812 | (it is not required that adaptors respect this). | ||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||
| 1814 | If the object has no primary_id (undef), then the object is written | ||||||||||||||||||||||||||||||||||||||||||
| 1815 | into the database and assigned a new primary_id. If the object already | ||||||||||||||||||||||||||||||||||||||||||
| 1816 | has a primary_id, then the system will perform an update, replacing | ||||||||||||||||||||||||||||||||||||||||||
| 1817 | whatever was there before. | ||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||
| 1819 | In practice, the implementation will serialize each object using the | ||||||||||||||||||||||||||||||||||||||||||
| 1820 | freeze() method and then store it in the database under the | ||||||||||||||||||||||||||||||||||||||||||
| 1821 | corresponding primary_id. The object is then updated with the | ||||||||||||||||||||||||||||||||||||||||||
| 1822 | primary_id. | ||||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||
| 1824 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||||||||||
| 1826 | # _store($indexed,@objs) | ||||||||||||||||||||||||||||||||||||||||||
| 1827 | sub _store { | ||||||||||||||||||||||||||||||||||||||||||
| 1828 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_store: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1829 | 0 | my $indexed = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1830 | 0 | my @objs = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | $self->throw_not_implemented; | |||||||||||||||||||||||||||||||||||||||||
| 1832 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||
| 1834 | =head2 _fetch | ||||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||
| 1836 | Title : _fetch | ||||||||||||||||||||||||||||||||||||||||||
| 1837 | Usage : $feature = $db->_fetch($primary_id) | ||||||||||||||||||||||||||||||||||||||||||
| 1838 | Function: fetch feature from database | ||||||||||||||||||||||||||||||||||||||||||
| 1839 | Returns : feature | ||||||||||||||||||||||||||||||||||||||||||
| 1840 | Args : primary id | ||||||||||||||||||||||||||||||||||||||||||
| 1841 | Status : ABSTRACT METHOD; MUST BE IMPLEMENTED BY AN ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||
| 1843 | This method is the back end for fetch(). It accepts a primary_id and | ||||||||||||||||||||||||||||||||||||||||||
| 1844 | returns a feature object. It must be implemented by the adaptor. | ||||||||||||||||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||||||||||||||||
| 1846 | In practice, the implementation will retrieve the serialized | ||||||||||||||||||||||||||||||||||||||||||
| 1847 | Bio::SeqfeatureI object from the database and pass it to the thaw() | ||||||||||||||||||||||||||||||||||||||||||
| 1848 | method to unserialize it and synchronize the primary_id. | ||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||
| 1850 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||
| 1852 | # _fetch($id) | ||||||||||||||||||||||||||||||||||||||||||
| 1853 | 0 | ▶ | sub _fetch { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1854 | |||||||||||||||||||||||||||||||||||||||||||
| 1855 | =head2 _fetch_many | ||||||||||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||||||||||
| 1857 | Title : _fetch_many | ||||||||||||||||||||||||||||||||||||||||||
| 1858 | Usage : $feature = $db->_fetch_many(@primary_ids) | ||||||||||||||||||||||||||||||||||||||||||
| 1859 | Function: fetch many features from database | ||||||||||||||||||||||||||||||||||||||||||
| 1860 | Returns : feature | ||||||||||||||||||||||||||||||||||||||||||
| 1861 | Args : primary id | ||||||||||||||||||||||||||||||||||||||||||
| 1862 | Status : private -- does not need to be implemented | ||||||||||||||||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||||||||||||||||
| 1864 | This method fetches many features specified by a list of IDs. The | ||||||||||||||||||||||||||||||||||||||||||
| 1865 | default implementation simply calls _fetch() once for each | ||||||||||||||||||||||||||||||||||||||||||
| 1866 | primary_id. Implementors can override it if needed for efficiency. | ||||||||||||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||||||||||||
| 1868 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||
| 1870 | # _fetch_many(@ids) | ||||||||||||||||||||||||||||||||||||||||||
| 1871 | # this one will fall back to many calls on fetch() if you don't | ||||||||||||||||||||||||||||||||||||||||||
| 1872 | # override it | ||||||||||||||||||||||||||||||||||||||||||
| 1873 | sub _fetch_many { | ||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_many: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1875 | 0 | return map {$self->_fetch($_)} @_; | |||||||||||||||||||||||||||||||||||||||||
| 1876 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||||||||||||||||
| 1878 | =head2 _update_indexes | ||||||||||||||||||||||||||||||||||||||||||
| 1879 | |||||||||||||||||||||||||||||||||||||||||||
| 1880 | Title : _update_indexes | ||||||||||||||||||||||||||||||||||||||||||
| 1881 | Usage : $success = $db->_update_indexes($feature) | ||||||||||||||||||||||||||||||||||||||||||
| 1882 | Function: update the indexes for a feature | ||||||||||||||||||||||||||||||||||||||||||
| 1883 | Returns : true on success | ||||||||||||||||||||||||||||||||||||||||||
| 1884 | Args : A seqfeature object | ||||||||||||||||||||||||||||||||||||||||||
| 1885 | Status : ABSTRACT METHOD; MUST BE IMPLEMENTED BY AN ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 1886 | |||||||||||||||||||||||||||||||||||||||||||
| 1887 | This method is called by reindex() to update the searchable indexes | ||||||||||||||||||||||||||||||||||||||||||
| 1888 | for a feature object that has changed. | ||||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||
| 1890 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||||||||||||||||
| 1892 | # this is called to index a feature | ||||||||||||||||||||||||||||||||||||||||||
| 1893 | 0 | ▶ | sub _update_indexes { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_indexes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1894 | |||||||||||||||||||||||||||||||||||||||||||
| 1895 | =head2 _start_reindexing, _end_reindexing | ||||||||||||||||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||||||||||||||||
| 1897 | Title : _start_reindexing, _end_reindexing | ||||||||||||||||||||||||||||||||||||||||||
| 1898 | Usage : $db->_start_reindexing() | ||||||||||||||||||||||||||||||||||||||||||
| 1899 | $db->_end_reindexing | ||||||||||||||||||||||||||||||||||||||||||
| 1900 | Function: flag that a series of reindexing operations is beginning/ending | ||||||||||||||||||||||||||||||||||||||||||
| 1901 | Returns : true on success | ||||||||||||||||||||||||||||||||||||||||||
| 1902 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1903 | Status : MAY BE IMPLEMENTED BY AN ADAPTOR (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 1904 | |||||||||||||||||||||||||||||||||||||||||||
| 1905 | These methods are called by reindex() before and immediately after a | ||||||||||||||||||||||||||||||||||||||||||
| 1906 | series of reindexing operations. The default behavior is to do | ||||||||||||||||||||||||||||||||||||||||||
| 1907 | nothing, but these methods can be overridden by an adaptor in order to | ||||||||||||||||||||||||||||||||||||||||||
| 1908 | perform optimizations, turn off autocommits, etc. | ||||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||
| 1910 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1911 | |||||||||||||||||||||||||||||||||||||||||||
| 1912 | # these do not necessary have to be overridden | ||||||||||||||||||||||||||||||||||||||||||
| 1913 | # they are called at beginning and end of reindexing process | ||||||||||||||||||||||||||||||||||||||||||
| 1914 | ▶ | sub _start_reindexing {} | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start_reindexing: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1915 | ▶ | sub _end_reindexing {} | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_end_reindexing: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1916 | |||||||||||||||||||||||||||||||||||||||||||
| 1917 | =head2 _features | ||||||||||||||||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||||||||||||||||
| 1919 | Title : _features | ||||||||||||||||||||||||||||||||||||||||||
| 1920 | Usage : @features = $db->_features(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 1921 | Function: back end for all get_feature_by_*() queries | ||||||||||||||||||||||||||||||||||||||||||
| 1922 | Returns : list of features | ||||||||||||||||||||||||||||||||||||||||||
| 1923 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 1924 | Status : ABSTRACT METHOD; MUST BE IMPLEMENTED BY ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||
| 1926 | This is the backend for features(), get_features_by_name(), | ||||||||||||||||||||||||||||||||||||||||||
| 1927 | get_features_by_location(), etc. Arguments are as described for the | ||||||||||||||||||||||||||||||||||||||||||
| 1928 | features() method, except that only the named-argument form is | ||||||||||||||||||||||||||||||||||||||||||
| 1929 | recognized. | ||||||||||||||||||||||||||||||||||||||||||
| 1930 | |||||||||||||||||||||||||||||||||||||||||||
| 1931 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1932 | |||||||||||||||||||||||||||||||||||||||||||
| 1933 | # bottleneck query generator | ||||||||||||||||||||||||||||||||||||||||||
| 1934 | 0 | ▶ | sub _features { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_features: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1935 | |||||||||||||||||||||||||||||||||||||||||||
| 1936 | =head2 _search_attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||||||||||
| 1938 | Title : _search_attributes | ||||||||||||||||||||||||||||||||||||||||||
| 1939 | Usage : @result_list = $db->_search_attributes("text search string",[$tag1,$tag2...],$limit) | ||||||||||||||||||||||||||||||||||||||||||
| 1940 | Function: back end for the search_attributes() method | ||||||||||||||||||||||||||||||||||||||||||
| 1941 | Returns : results list | ||||||||||||||||||||||||||||||||||||||||||
| 1942 | Args : as per search_attributes() | ||||||||||||||||||||||||||||||||||||||||||
| 1943 | Status : ABSTRACT METHOD; MUST BE IMPLEMENTED BY ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 1944 | |||||||||||||||||||||||||||||||||||||||||||
| 1945 | See search_attributes() for the format of the results list. The only | ||||||||||||||||||||||||||||||||||||||||||
| 1946 | difference between this and the public method is that the tag list is | ||||||||||||||||||||||||||||||||||||||||||
| 1947 | guaranteed to be an array reference. | ||||||||||||||||||||||||||||||||||||||||||
| 1948 | |||||||||||||||||||||||||||||||||||||||||||
| 1949 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1950 | |||||||||||||||||||||||||||||||||||||||||||
| 1951 | 0 | ▶ | sub _search_attributes { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_search_attributes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1952 | |||||||||||||||||||||||||||||||||||||||||||
| 1953 | =head2 can_store_parentage | ||||||||||||||||||||||||||||||||||||||||||
| 1954 | |||||||||||||||||||||||||||||||||||||||||||
| 1955 | Title : can_store_parentage | ||||||||||||||||||||||||||||||||||||||||||
| 1956 | Usage : $flag = $db->can_store_parentage | ||||||||||||||||||||||||||||||||||||||||||
| 1957 | Function: return true if this adaptor can store parent/child relationships | ||||||||||||||||||||||||||||||||||||||||||
| 1958 | Returns : boolean | ||||||||||||||||||||||||||||||||||||||||||
| 1959 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1960 | Status : OPTIONAL; MAY BE IMPLEMENTED BY ADAPTORS | ||||||||||||||||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||||||||||||||||
| 1962 | Override this method and return true if this adaptor supports the | ||||||||||||||||||||||||||||||||||||||||||
| 1963 | _add_SeqFeature() and _get_SeqFeatures() methods, which are used for | ||||||||||||||||||||||||||||||||||||||||||
| 1964 | storing feature parent/child relationships in a normalized | ||||||||||||||||||||||||||||||||||||||||||
| 1965 | fashion. Default is false (parent/child relationships are stored in | ||||||||||||||||||||||||||||||||||||||||||
| 1966 | denormalized form in each feature). | ||||||||||||||||||||||||||||||||||||||||||
| 1967 | |||||||||||||||||||||||||||||||||||||||||||
| 1968 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1969 | |||||||||||||||||||||||||||||||||||||||||||
| 1970 | # return true here if the storage engine is prepared to store parent/child | ||||||||||||||||||||||||||||||||||||||||||
| 1971 | # relationships using _add_SeqFeature and return them using _fetch_SeqFeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1972 | 0 | ▶ | sub can_store_parentage { return; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_store_parentage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1973 | |||||||||||||||||||||||||||||||||||||||||||
| 1974 | =head2 _add_SeqFeature | ||||||||||||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||||||||||||
| 1976 | Title : _add_SeqFeature | ||||||||||||||||||||||||||||||||||||||||||
| 1977 | Usage : $count = $db->_add_SeqFeature($parent,@children) | ||||||||||||||||||||||||||||||||||||||||||
| 1978 | Function: store a parent/child relationship between $parent and @children | ||||||||||||||||||||||||||||||||||||||||||
| 1979 | Returns : number of children successfully stored | ||||||||||||||||||||||||||||||||||||||||||
| 1980 | Args : parent feature and one or more children | ||||||||||||||||||||||||||||||||||||||||||
| 1981 | Status : OPTIONAL; MAY BE IMPLEMENTED BY ADAPTORS | ||||||||||||||||||||||||||||||||||||||||||
| 1982 | |||||||||||||||||||||||||||||||||||||||||||
| 1983 | If can_store_parentage() returns true, then some store-aware features | ||||||||||||||||||||||||||||||||||||||||||
| 1984 | (e.g. Bio::DB::SeqFeature) will invoke this method to store | ||||||||||||||||||||||||||||||||||||||||||
| 1985 | feature/subfeature relationships in a normalized table. | ||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||
| 1987 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1988 | |||||||||||||||||||||||||||||||||||||||||||
| 1989 | 0 | ▶ | sub _add_SeqFeature { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_SeqFeature: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1990 | |||||||||||||||||||||||||||||||||||||||||||
| 1991 | =head2 _fetch_SeqFeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||||||||||||
| 1993 | Title : _fetch_SeqFeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1994 | Usage : @children = $db->_fetch_SeqFeatures($parent_feature) | ||||||||||||||||||||||||||||||||||||||||||
| 1995 | Function: return the immediate subfeatures of the indicated feature | ||||||||||||||||||||||||||||||||||||||||||
| 1996 | Returns : list of subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1997 | Args : the parent feature | ||||||||||||||||||||||||||||||||||||||||||
| 1998 | Status : OPTIONAL; MAY BE IMPLEMENTED BY ADAPTORS | ||||||||||||||||||||||||||||||||||||||||||
| 1999 | |||||||||||||||||||||||||||||||||||||||||||
| 2000 | If can_store_parentage() returns true, then some store-aware features | ||||||||||||||||||||||||||||||||||||||||||
| 2001 | (e.g. Bio::DB::SeqFeature) will invoke this method to retrieve | ||||||||||||||||||||||||||||||||||||||||||
| 2002 | feature/subfeature relationships from the database. | ||||||||||||||||||||||||||||||||||||||||||
| 2003 | |||||||||||||||||||||||||||||||||||||||||||
| 2004 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||||||||||||||||
| 2006 | # _get_SeqFeatures($parent,@list_of_child_types) | ||||||||||||||||||||||||||||||||||||||||||
| 2007 | 0 | ▶ | sub _fetch_SeqFeatures {shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_SeqFeatures: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2008 | |||||||||||||||||||||||||||||||||||||||||||
| 2009 | =head2 _insert_sequence | ||||||||||||||||||||||||||||||||||||||||||
| 2010 | |||||||||||||||||||||||||||||||||||||||||||
| 2011 | Title : _insert_sequence | ||||||||||||||||||||||||||||||||||||||||||
| 2012 | Usage : $success = $db->_insert_sequence($seqid,$sequence_string,$offset) | ||||||||||||||||||||||||||||||||||||||||||
| 2013 | Function: Inserts sequence data into the database at the indicated offset | ||||||||||||||||||||||||||||||||||||||||||
| 2014 | Returns : true if successful | ||||||||||||||||||||||||||||||||||||||||||
| 2015 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 2016 | Status : ABSTRACT METHOD; MUST BE IMPLEMENTED BY ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 2017 | |||||||||||||||||||||||||||||||||||||||||||
| 2018 | This is the back end for insert_sequence(). Adaptors must implement | ||||||||||||||||||||||||||||||||||||||||||
| 2019 | this method in order to store and retrieve nucleotide or protein | ||||||||||||||||||||||||||||||||||||||||||
| 2020 | sequence. | ||||||||||||||||||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||||||||||||||||
| 2022 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2023 | |||||||||||||||||||||||||||||||||||||||||||
| 2024 | 0 | ▶ | sub _insert_sequence { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_insert_sequence: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2025 | |||||||||||||||||||||||||||||||||||||||||||
| 2026 | # _fetch_sequence() is similar to old dna() method | ||||||||||||||||||||||||||||||||||||||||||
| 2027 | |||||||||||||||||||||||||||||||||||||||||||
| 2028 | =head2 _fetch_sequence | ||||||||||||||||||||||||||||||||||||||||||
| 2029 | |||||||||||||||||||||||||||||||||||||||||||
| 2030 | Title : _fetch_sequence | ||||||||||||||||||||||||||||||||||||||||||
| 2031 | Usage : $sequence = $db->_fetch_sequence(-seq_id=>$seqid,-start=>$start,-end=>$end) | ||||||||||||||||||||||||||||||||||||||||||
| 2032 | Function: Fetch the indicated subsequence from the database | ||||||||||||||||||||||||||||||||||||||||||
| 2033 | Returns : The sequence string (not a Bio::PrimarySeq object!) | ||||||||||||||||||||||||||||||||||||||||||
| 2034 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 2035 | Status : ABSTRACT METHOD; MUST BE IMPLEMENTED BY ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 2036 | |||||||||||||||||||||||||||||||||||||||||||
| 2037 | This is the back end for fetch_sequence(). Adaptors must implement | ||||||||||||||||||||||||||||||||||||||||||
| 2038 | this method in order to store and retrieve nucleotide or protein | ||||||||||||||||||||||||||||||||||||||||||
| 2039 | sequence. | ||||||||||||||||||||||||||||||||||||||||||
| 2040 | |||||||||||||||||||||||||||||||||||||||||||
| 2041 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2042 | |||||||||||||||||||||||||||||||||||||||||||
| 2043 | 0 | ▶ | sub _fetch_sequence { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_sequence: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2044 | |||||||||||||||||||||||||||||||||||||||||||
| 2045 | sub seq { | ||||||||||||||||||||||||||||||||||||||||||
| 2046 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seq: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2047 | 0 | my ($seq_id,$start,$end) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 2048 | 0 | ▶ | if (my $a = $self->dna_accessor) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2049 | 0 | ▶ | return $a->can('seq') ? $a->seq($seq_id,$start,$end) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2050 | :$a->can('fetch_sequence')? $a->fetch_sequence($seq_id,$start,$end) | ||||||||||||||||||||||||||||||||||||||||||
| 2051 | : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 2052 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2053 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 2054 | 0 | return $self->_fetch_sequence($seq_id,$start,$end); | |||||||||||||||||||||||||||||||||||||||||
| 2055 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2056 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2057 | |||||||||||||||||||||||||||||||||||||||||||
| 2058 | =head2 _seq_ids | ||||||||||||||||||||||||||||||||||||||||||
| 2059 | |||||||||||||||||||||||||||||||||||||||||||
| 2060 | Title : _seq_ids | ||||||||||||||||||||||||||||||||||||||||||
| 2061 | Usage : @ids = $db->_seq_ids() | ||||||||||||||||||||||||||||||||||||||||||
| 2062 | Function: Return all sequence IDs contained in database | ||||||||||||||||||||||||||||||||||||||||||
| 2063 | Returns : list of sequence Ids | ||||||||||||||||||||||||||||||||||||||||||
| 2064 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 2065 | Status : TO BE IMPLEMENTED BY ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 2066 | |||||||||||||||||||||||||||||||||||||||||||
| 2067 | This method is invoked by seq_ids() to return all sequence IDs | ||||||||||||||||||||||||||||||||||||||||||
| 2068 | (coordinate systems) known to the database. | ||||||||||||||||||||||||||||||||||||||||||
| 2069 | |||||||||||||||||||||||||||||||||||||||||||
| 2070 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2071 | |||||||||||||||||||||||||||||||||||||||||||
| 2072 | 0 | ▶ | sub _seq_ids { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_seq_ids: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2073 | |||||||||||||||||||||||||||||||||||||||||||
| 2074 | =head2 _start_bulk_update,_finish_bulk_update | ||||||||||||||||||||||||||||||||||||||||||
| 2075 | |||||||||||||||||||||||||||||||||||||||||||
| 2076 | Title : _start_bulk_update, _finish_bulk_update | ||||||||||||||||||||||||||||||||||||||||||
| 2077 | Usage : $db->_start_bulk_update | ||||||||||||||||||||||||||||||||||||||||||
| 2078 | $db->_finish_bulk_update | ||||||||||||||||||||||||||||||||||||||||||
| 2079 | Function: Activate optimizations for large number of insertions/updates | ||||||||||||||||||||||||||||||||||||||||||
| 2080 | Returns : nothing | ||||||||||||||||||||||||||||||||||||||||||
| 2081 | Args : nothing | ||||||||||||||||||||||||||||||||||||||||||
| 2082 | Status : OPTIONAL; MAY BE IMPLEMENTED BY ADAPTOR | ||||||||||||||||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||||||||||||||||
| 2084 | These are the backends for start_bulk_update() and | ||||||||||||||||||||||||||||||||||||||||||
| 2085 | finish_bulk_update(). The default behavior of both methods is to do | ||||||||||||||||||||||||||||||||||||||||||
| 2086 | nothing. | ||||||||||||||||||||||||||||||||||||||||||
| 2087 | |||||||||||||||||||||||||||||||||||||||||||
| 2088 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2089 | |||||||||||||||||||||||||||||||||||||||||||
| 2090 | # Optional flags to change behavior to optimize bulk updating. | ||||||||||||||||||||||||||||||||||||||||||
| 2091 | ▶ | sub _start_bulk_update { } | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start_bulk_update: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2092 | ▶ | sub _finish_bulk_update { } | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish_bulk_update: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||||||||||||||||
| 2094 | |||||||||||||||||||||||||||||||||||||||||||
| 2095 | # for full TIE() interface - not necessary to implement in most cases | ||||||||||||||||||||||||||||||||||||||||||
| 2096 | |||||||||||||||||||||||||||||||||||||||||||
| 2097 | =head2 Optional methods needed to implement full TIEHASH interface | ||||||||||||||||||||||||||||||||||||||||||
| 2098 | |||||||||||||||||||||||||||||||||||||||||||
| 2099 | The core TIEHASH interface will work if just the _store() and _fetch() | ||||||||||||||||||||||||||||||||||||||||||
| 2100 | methods are implemented. To support the full TIEHASH interface, | ||||||||||||||||||||||||||||||||||||||||||
| 2101 | including support for keys(), each(), and exists(), the following | ||||||||||||||||||||||||||||||||||||||||||
| 2102 | methods should be implemented: | ||||||||||||||||||||||||||||||||||||||||||
| 2103 | |||||||||||||||||||||||||||||||||||||||||||
| 2104 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 2105 | |||||||||||||||||||||||||||||||||||||||||||
| 2106 | =item $id = $db-E<gt>_firstid() | ||||||||||||||||||||||||||||||||||||||||||
| 2107 | |||||||||||||||||||||||||||||||||||||||||||
| 2108 | Return the first primary ID in the database. Needed for the each() | ||||||||||||||||||||||||||||||||||||||||||
| 2109 | function. | ||||||||||||||||||||||||||||||||||||||||||
| 2110 | |||||||||||||||||||||||||||||||||||||||||||
| 2111 | =item $next_id = $db-E<gt>_nextid($id) | ||||||||||||||||||||||||||||||||||||||||||
| 2112 | |||||||||||||||||||||||||||||||||||||||||||
| 2113 | Given a primary ID, return the next primary ID in the series. Needed | ||||||||||||||||||||||||||||||||||||||||||
| 2114 | for the each() function. | ||||||||||||||||||||||||||||||||||||||||||
| 2115 | |||||||||||||||||||||||||||||||||||||||||||
| 2116 | =item $boolean = $db-E<gt>_existsid($id) | ||||||||||||||||||||||||||||||||||||||||||
| 2117 | |||||||||||||||||||||||||||||||||||||||||||
| 2118 | Returns true if the indicated primary ID is in the database. Needed | ||||||||||||||||||||||||||||||||||||||||||
| 2119 | for the exists() function. | ||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||
| 2121 | =item $db-E<gt>_deleteid($id) | ||||||||||||||||||||||||||||||||||||||||||
| 2122 | |||||||||||||||||||||||||||||||||||||||||||
| 2123 | Delete the feature corresponding to the given primary ID. Needed for | ||||||||||||||||||||||||||||||||||||||||||
| 2124 | delete(). | ||||||||||||||||||||||||||||||||||||||||||
| 2125 | |||||||||||||||||||||||||||||||||||||||||||
| 2126 | =item $db-E<gt>_clearall() | ||||||||||||||||||||||||||||||||||||||||||
| 2127 | |||||||||||||||||||||||||||||||||||||||||||
| 2128 | Empty the database. Needed for %tied_hash = (). | ||||||||||||||||||||||||||||||||||||||||||
| 2129 | |||||||||||||||||||||||||||||||||||||||||||
| 2130 | =item $count = $db-E<gt>_featurecount() | ||||||||||||||||||||||||||||||||||||||||||
| 2131 | |||||||||||||||||||||||||||||||||||||||||||
| 2132 | Return the number of features in the database. Needed for scalar | ||||||||||||||||||||||||||||||||||||||||||
| 2133 | %tied_hash. | ||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||
| 2135 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||||||||||||||||
| 2137 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||
| 2139 | 0 | ▶ | sub _firstid { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_firstid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2140 | 0 | ▶ | sub _nextid { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_nextid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2141 | 0 | ▶ | sub _existsid { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_existsid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2142 | 0 | ▶ | sub _deleteid { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deleteid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2143 | 0 | ▶ | sub _clearall { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clearall: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2144 | 0 | ▶ | sub _featurecount { shift->throw_not_implemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_featurecount: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2145 | |||||||||||||||||||||||||||||||||||||||||||
| 2146 | |||||||||||||||||||||||||||||||||||||||||||
| 2147 | =head1 Internal Methods | ||||||||||||||||||||||||||||||||||||||||||
| 2148 | |||||||||||||||||||||||||||||||||||||||||||
| 2149 | These methods are internal to Bio::DB::SeqFeature::Store and adaptors. | ||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||
| 2151 | =head2 new_instance | ||||||||||||||||||||||||||||||||||||||||||
| 2152 | |||||||||||||||||||||||||||||||||||||||||||
| 2153 | Title : new_instance | ||||||||||||||||||||||||||||||||||||||||||
| 2154 | Usage : $db = $db->new_instance() | ||||||||||||||||||||||||||||||||||||||||||
| 2155 | Function: class constructor | ||||||||||||||||||||||||||||||||||||||||||
| 2156 | Returns : A descendent of Bio::DB::SeqFeature::Store | ||||||||||||||||||||||||||||||||||||||||||
| 2157 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 2158 | Status : internal | ||||||||||||||||||||||||||||||||||||||||||
| 2159 | |||||||||||||||||||||||||||||||||||||||||||
| 2160 | This method is called internally by new() to create a new | ||||||||||||||||||||||||||||||||||||||||||
| 2161 | uninitialized instance of Bio::DB::SeqFeature::Store. It is used | ||||||||||||||||||||||||||||||||||||||||||
| 2162 | internally and should not be called by application software. | ||||||||||||||||||||||||||||||||||||||||||
| 2163 | |||||||||||||||||||||||||||||||||||||||||||
| 2164 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2165 | |||||||||||||||||||||||||||||||||||||||||||
| 2166 | sub new_instance { | ||||||||||||||||||||||||||||||||||||||||||
| 2167 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_instance: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | ▶ | return bless {},ref($class) || $class; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||
| 2169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||||||||||||||||
| 2171 | =head2 init | ||||||||||||||||||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||||||||||||||||
| 2173 | Title : init | ||||||||||||||||||||||||||||||||||||||||||
| 2174 | Usage : $db->init(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 2175 | Function: initialize object | ||||||||||||||||||||||||||||||||||||||||||
| 2176 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 2177 | Args : Arguments passed to new() | ||||||||||||||||||||||||||||||||||||||||||
| 2178 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||||||||||||||||
| 2180 | This method is called internally by new() to initialize a | ||||||||||||||||||||||||||||||||||||||||||
| 2181 | newly-created object using the arguments passed to new(). It is to be | ||||||||||||||||||||||||||||||||||||||||||
| 2182 | overridden by Bio::DB::SeqFeature::Store adaptors. | ||||||||||||||||||||||||||||||||||||||||||
| 2183 | |||||||||||||||||||||||||||||||||||||||||||
| 2184 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2185 | |||||||||||||||||||||||||||||||||||||||||||
| 2186 | sub init { | ||||||||||||||||||||||||||||||||||||||||||
| 2187 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2188 | 0 | $self->default_settings(); | |||||||||||||||||||||||||||||||||||||||||
| 2189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||||||||||||||||
| 2191 | =head2 default_settings | ||||||||||||||||||||||||||||||||||||||||||
| 2192 | |||||||||||||||||||||||||||||||||||||||||||
| 2193 | Title : default_settings | ||||||||||||||||||||||||||||||||||||||||||
| 2194 | Usage : $db->default_settings() | ||||||||||||||||||||||||||||||||||||||||||
| 2195 | Function: set up default settings for the adaptor | ||||||||||||||||||||||||||||||||||||||||||
| 2196 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 2197 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 2198 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2199 | |||||||||||||||||||||||||||||||||||||||||||
| 2200 | This method is may be overridden by adaptors. It is responsible for | ||||||||||||||||||||||||||||||||||||||||||
| 2201 | setting up object default settings. | ||||||||||||||||||||||||||||||||||||||||||
| 2202 | |||||||||||||||||||||||||||||||||||||||||||
| 2203 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2204 | |||||||||||||||||||||||||||||||||||||||||||
| 2205 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 2206 | # default settings -- set up whatever are the proper default settings | ||||||||||||||||||||||||||||||||||||||||||
| 2207 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2208 | sub default_settings { | ||||||||||||||||||||||||||||||||||||||||||
| 2209 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_settings: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2210 | 0 | $self->serializer($self->default_serializer); | |||||||||||||||||||||||||||||||||||||||||
| 2211 | 0 | $self->index_subfeatures(1); | |||||||||||||||||||||||||||||||||||||||||
| 2212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2213 | |||||||||||||||||||||||||||||||||||||||||||
| 2214 | =head2 default_serializer | ||||||||||||||||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||||||||||||||||
| 2216 | Title : default_serializer | ||||||||||||||||||||||||||||||||||||||||||
| 2217 | Usage : $serializer = $db->default_serializer | ||||||||||||||||||||||||||||||||||||||||||
| 2218 | Function: finds an available serializer | ||||||||||||||||||||||||||||||||||||||||||
| 2219 | Returns : the name of an available serializer | ||||||||||||||||||||||||||||||||||||||||||
| 2220 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 2221 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2222 | |||||||||||||||||||||||||||||||||||||||||||
| 2223 | This method returns the name of an available serializer module. | ||||||||||||||||||||||||||||||||||||||||||
| 2224 | |||||||||||||||||||||||||||||||||||||||||||
| 2225 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2226 | |||||||||||||||||||||||||||||||||||||||||||
| 2227 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 2228 | # choose a serializer | ||||||||||||||||||||||||||||||||||||||||||
| 2229 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2230 | sub default_serializer { | ||||||||||||||||||||||||||||||||||||||||||
| 2231 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_serializer: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2232 | # try Storable | ||||||||||||||||||||||||||||||||||||||||||
| 2233 | 0 | ▶ | eval "require Storable; 1" and return 'Storable'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2234 | 0 | ▶ | eval "require Data::Dumper; 1" and return 'Data::Dumper'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2235 | 0 | croak "Unable to load either Storable or Data::Dumper. Please provide a serializer using -serializer"; | |||||||||||||||||||||||||||||||||||||||||
| 2236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||
| 2238 | =head2 setting | ||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||
| 2240 | Title : setting | ||||||||||||||||||||||||||||||||||||||||||
| 2241 | Usage : $value = $db->setting('setting_name' [=> $new_value]) | ||||||||||||||||||||||||||||||||||||||||||
| 2242 | Function: get/set the value of a setting | ||||||||||||||||||||||||||||||||||||||||||
| 2243 | Returns : the value of the current setting | ||||||||||||||||||||||||||||||||||||||||||
| 2244 | Args : the name of the setting and optionally a new value for the setting | ||||||||||||||||||||||||||||||||||||||||||
| 2245 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2246 | |||||||||||||||||||||||||||||||||||||||||||
| 2247 | This is a low-level procedure for persistently storing database | ||||||||||||||||||||||||||||||||||||||||||
| 2248 | settings. It can be overridden by adaptors. | ||||||||||||||||||||||||||||||||||||||||||
| 2249 | |||||||||||||||||||||||||||||||||||||||||||
| 2250 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||||||||||||||||
| 2252 | # persistent settings | ||||||||||||||||||||||||||||||||||||||||||
| 2253 | # by default we store in the object | ||||||||||||||||||||||||||||||||||||||||||
| 2254 | sub setting { | ||||||||||||||||||||||||||||||||||||||||||
| 2255 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setting: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2256 | 0 | my $variable_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2257 | 0 | my $d = $self->{setting}{$variable_name}; | |||||||||||||||||||||||||||||||||||||||||
| 2258 | 0 | ▶ | $self->{setting}{$variable_name} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2259 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 2260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2261 | |||||||||||||||||||||||||||||||||||||||||||
| 2262 | =head2 subfeatures_are_indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||||||||||||||||
| 2264 | Title : subfeatures_are_indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2265 | Usage : $flag = $db->subfeatures_are_indexed([$new_value]) | ||||||||||||||||||||||||||||||||||||||||||
| 2266 | Function: flag whether subfeatures are indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2267 | Returns : a flag indicating that all subfeatures are indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2268 | Args : (optional) new value of the flag | ||||||||||||||||||||||||||||||||||||||||||
| 2269 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2270 | |||||||||||||||||||||||||||||||||||||||||||
| 2271 | This method is used internally by the Bio::DB::SeqFeature class to | ||||||||||||||||||||||||||||||||||||||||||
| 2272 | optimize some of its operations. It returns true if all of the | ||||||||||||||||||||||||||||||||||||||||||
| 2273 | subfeatures in the database are indexed; it returns false if at least | ||||||||||||||||||||||||||||||||||||||||||
| 2274 | one of the subfeatures is not indexed. Do not attempt to change the | ||||||||||||||||||||||||||||||||||||||||||
| 2275 | value of this setting unless you are writing an adaptor. | ||||||||||||||||||||||||||||||||||||||||||
| 2276 | |||||||||||||||||||||||||||||||||||||||||||
| 2277 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2278 | |||||||||||||||||||||||||||||||||||||||||||
| 2279 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 2280 | # whether subfeatures are all indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2281 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2282 | sub subfeatures_are_indexed { | ||||||||||||||||||||||||||||||||||||||||||
| 2283 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subfeatures_are_indexed: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2284 | 0 | my $d = $self->setting('subfeatures_are_indexed'); | |||||||||||||||||||||||||||||||||||||||||
| 2285 | 0 | ▶ | $self->setting(subfeatures_are_indexed => shift) if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2286 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 2287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2288 | |||||||||||||||||||||||||||||||||||||||||||
| 2289 | =head2 subfeature_types_are_indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2290 | |||||||||||||||||||||||||||||||||||||||||||
| 2291 | Title : subfeature_types_are_indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2292 | Usage : $flag = $db->subfeature_types_are_indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2293 | Function: whether subfeatures are indexed by type | ||||||||||||||||||||||||||||||||||||||||||
| 2294 | Returns : a flag indicating that all subfeatures are indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2295 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 2296 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2297 | |||||||||||||||||||||||||||||||||||||||||||
| 2298 | This method returns true if subfeature types are indexed. Default is | ||||||||||||||||||||||||||||||||||||||||||
| 2299 | to return the value of subfeatures_are_indexed(). | ||||||||||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||||||||||
| 2301 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2302 | |||||||||||||||||||||||||||||||||||||||||||
| 2303 | sub subfeature_types_are_indexed { | ||||||||||||||||||||||||||||||||||||||||||
| 2304 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subfeature_types_are_indexed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2305 | 0 | return $self->subfeatures_are_indexed; | |||||||||||||||||||||||||||||||||||||||||
| 2306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2307 | |||||||||||||||||||||||||||||||||||||||||||
| 2308 | =head2 subfeature_locations_are_indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2309 | |||||||||||||||||||||||||||||||||||||||||||
| 2310 | Title : subfeature_locations_are_indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2311 | Usage : $flag = $db->subfeature_locations_are_indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2312 | Function: whether subfeatures are indexed by type | ||||||||||||||||||||||||||||||||||||||||||
| 2313 | Returns : a flag indicating that all subfeatures are indexed | ||||||||||||||||||||||||||||||||||||||||||
| 2314 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 2315 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2316 | |||||||||||||||||||||||||||||||||||||||||||
| 2317 | This method returns true if subfeature locations are indexed. Default is | ||||||||||||||||||||||||||||||||||||||||||
| 2318 | to return the value of subfeatures_are_indexed(). | ||||||||||||||||||||||||||||||||||||||||||
| 2319 | |||||||||||||||||||||||||||||||||||||||||||
| 2320 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2321 | |||||||||||||||||||||||||||||||||||||||||||
| 2322 | sub subfeature_locations_are_indexed { | ||||||||||||||||||||||||||||||||||||||||||
| 2323 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subfeature_locations_are_indexed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2324 | 0 | return $self->subfeatures_are_indexed; | |||||||||||||||||||||||||||||||||||||||||
| 2325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2326 | |||||||||||||||||||||||||||||||||||||||||||
| 2327 | =head2 setup_segment_args | ||||||||||||||||||||||||||||||||||||||||||
| 2328 | |||||||||||||||||||||||||||||||||||||||||||
| 2329 | Title : setup_segment_args | ||||||||||||||||||||||||||||||||||||||||||
| 2330 | Usage : @args = $db->setup_segment_args(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 2331 | Function: munge the arguments to the segment() call | ||||||||||||||||||||||||||||||||||||||||||
| 2332 | Returns : munged arguments | ||||||||||||||||||||||||||||||||||||||||||
| 2333 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 2334 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2335 | |||||||||||||||||||||||||||||||||||||||||||
| 2336 | This method is used internally by segment() to translate positional | ||||||||||||||||||||||||||||||||||||||||||
| 2337 | arguments into named argument=E<gt>value pairs. | ||||||||||||||||||||||||||||||||||||||||||
| 2338 | |||||||||||||||||||||||||||||||||||||||||||
| 2339 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2340 | |||||||||||||||||||||||||||||||||||||||||||
| 2341 | sub setup_segment_args { | ||||||||||||||||||||||||||||||||||||||||||
| 2342 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_segment_args: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2343 | 0 | ▶ | return @_ if defined $_[0] && $_[0] =~ /^-/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[0] and $_[0] =~ /^-/
MC/DC0%0/2
defined $_[0] and $_[0] =~ /^-/
defined $_[0]
$_[0] =~ /^-/
Truth table0%0/3
A and B
A= defined $_[0]B= $_[0] =~ /^-/
| |||||||||||||||||||||||||||||||||||||||||||
| 2344 | 0 | ▶ | return (-name=>$_[0],-start=>$_[1],-end=>$_[2]) if @_ == 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2345 | 0 | ▶ | return (-class=>$_[0],-name=>$_[1]) if @_ == 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2346 | 0 | ▶ | return (-name=>$_[0]) if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2347 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 2348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2349 | |||||||||||||||||||||||||||||||||||||||||||
| 2350 | =head2 store_and_cache | ||||||||||||||||||||||||||||||||||||||||||
| 2351 | |||||||||||||||||||||||||||||||||||||||||||
| 2352 | Title : store_and_cache | ||||||||||||||||||||||||||||||||||||||||||
| 2353 | Usage : $success = $db->store_and_cache(@features) | ||||||||||||||||||||||||||||||||||||||||||
| 2354 | Function: store features into database and update cache | ||||||||||||||||||||||||||||||||||||||||||
| 2355 | Returns : number of features stored | ||||||||||||||||||||||||||||||||||||||||||
| 2356 | Args : index the features? (0 or 1) and list of features | ||||||||||||||||||||||||||||||||||||||||||
| 2357 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2358 | |||||||||||||||||||||||||||||||||||||||||||
| 2359 | This private method stores the list of Bio::SeqFeatureI objects into | ||||||||||||||||||||||||||||||||||||||||||
| 2360 | the database and caches them in memory for retrieval. | ||||||||||||||||||||||||||||||||||||||||||
| 2361 | |||||||||||||||||||||||||||||||||||||||||||
| 2362 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2363 | |||||||||||||||||||||||||||||||||||||||||||
| 2364 | sub store_and_cache { | ||||||||||||||||||||||||||||||||||||||||||
| 2365 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
store_and_cache: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2366 | 0 | my $indexit = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2367 | 0 | my $result = $self->_store($indexit,@_); | |||||||||||||||||||||||||||||||||||||||||
| 2368 | 0 | ▶ | if (my $cache = $self->cache) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2369 | 0 | for my $obj (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 2370 | 0 | ▶ | defined (my $id = eval {$obj->primary_id}) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2371 | 0 | $cache->store($id,$obj); | |||||||||||||||||||||||||||||||||||||||||
| 2372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2374 | 0 | $result; | |||||||||||||||||||||||||||||||||||||||||
| 2375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2376 | |||||||||||||||||||||||||||||||||||||||||||
| 2377 | =head2 init_cache | ||||||||||||||||||||||||||||||||||||||||||
| 2378 | |||||||||||||||||||||||||||||||||||||||||||
| 2379 | Title : init_cache | ||||||||||||||||||||||||||||||||||||||||||
| 2380 | Usage : $db->init_cache($size) | ||||||||||||||||||||||||||||||||||||||||||
| 2381 | Function: initialize the in-memory feature cache | ||||||||||||||||||||||||||||||||||||||||||
| 2382 | Returns : the Tie::Cacher object | ||||||||||||||||||||||||||||||||||||||||||
| 2383 | Args : desired size of the cache | ||||||||||||||||||||||||||||||||||||||||||
| 2384 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2385 | |||||||||||||||||||||||||||||||||||||||||||
| 2386 | This method is used internally by new() to create the Tie::Cacher | ||||||||||||||||||||||||||||||||||||||||||
| 2387 | instance used for the in-memory feature cache. | ||||||||||||||||||||||||||||||||||||||||||
| 2388 | |||||||||||||||||||||||||||||||||||||||||||
| 2389 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2390 | |||||||||||||||||||||||||||||||||||||||||||
| 2391 | sub init_cache { | ||||||||||||||||||||||||||||||||||||||||||
| 2392 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_cache: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2393 | 0 | my $cache_size = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2394 | 0 | ▶ | $cache_size = 5000 if $cache_size == 1; # in case somebody treats it as a flag | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2395 | 0 | ▶ | $self->{cache} = Tie::Cacher->new($cache_size) or $self->throw("Couldn't tie cache: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2397 | |||||||||||||||||||||||||||||||||||||||||||
| 2398 | =head2 cache | ||||||||||||||||||||||||||||||||||||||||||
| 2399 | |||||||||||||||||||||||||||||||||||||||||||
| 2400 | Title : cache | ||||||||||||||||||||||||||||||||||||||||||
| 2401 | Usage : $cache = $db->cache | ||||||||||||||||||||||||||||||||||||||||||
| 2402 | Function: return the cache object | ||||||||||||||||||||||||||||||||||||||||||
| 2403 | Returns : the Tie::Cacher object | ||||||||||||||||||||||||||||||||||||||||||
| 2404 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 2405 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2406 | |||||||||||||||||||||||||||||||||||||||||||
| 2407 | This method returns the Tie::Cacher object used for the in-memory | ||||||||||||||||||||||||||||||||||||||||||
| 2408 | feature cache. | ||||||||||||||||||||||||||||||||||||||||||
| 2409 | |||||||||||||||||||||||||||||||||||||||||||
| 2410 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2411 | |||||||||||||||||||||||||||||||||||||||||||
| 2412 | 0 | ▶ | sub cache { shift->{cache} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||||||||||||||||
| 2414 | =head2 load_class | ||||||||||||||||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||||||||||||||||
| 2416 | Title : load_class | ||||||||||||||||||||||||||||||||||||||||||
| 2417 | Usage : $db->load_class($blessed_object) | ||||||||||||||||||||||||||||||||||||||||||
| 2418 | Function: loads the module corresponding to a blessed object | ||||||||||||||||||||||||||||||||||||||||||
| 2419 | Returns : empty | ||||||||||||||||||||||||||||||||||||||||||
| 2420 | Args : a blessed object | ||||||||||||||||||||||||||||||||||||||||||
| 2421 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2422 | |||||||||||||||||||||||||||||||||||||||||||
| 2423 | This method is used by thaw() to load the code for a blessed | ||||||||||||||||||||||||||||||||||||||||||
| 2424 | object. This ensures that all the object's methods are available. | ||||||||||||||||||||||||||||||||||||||||||
| 2425 | |||||||||||||||||||||||||||||||||||||||||||
| 2426 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2427 | |||||||||||||||||||||||||||||||||||||||||||
| 2428 | sub load_class { | ||||||||||||||||||||||||||||||||||||||||||
| 2429 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_class: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2430 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2431 | 0 | ▶ | return unless defined $obj; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2432 | 0 | ▶ | return if $self->{class_loaded}{ref $obj}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2433 | 0 | ▶ | unless ($obj && $obj->can('primary_id')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$obj and $obj->can("primary_id")
MC/DC0%0/2
$obj and $obj->can("primary_id")
$obj
$obj->can("primary_id")
Truth table0%0/3
A and B
A= $objB= $obj->can("primary_id")
| |||||||||||||||||||||||||||||||||||||||||||
| 2434 | 0 | my $class = ref $obj; | |||||||||||||||||||||||||||||||||||||||||
| 2435 | 0 | eval "require $class"; | |||||||||||||||||||||||||||||||||||||||||
| 2436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2438 | |||||||||||||||||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||||||||||||||||
| 2440 | #################################### Internal methods #################### | ||||||||||||||||||||||||||||||||||||||||||
| 2441 | |||||||||||||||||||||||||||||||||||||||||||
| 2442 | =head2 freeze | ||||||||||||||||||||||||||||||||||||||||||
| 2443 | |||||||||||||||||||||||||||||||||||||||||||
| 2444 | Title : freeze | ||||||||||||||||||||||||||||||||||||||||||
| 2445 | Usage : $serialized_object = $db->freeze($feature) | ||||||||||||||||||||||||||||||||||||||||||
| 2446 | Function: serialize a feature object into a string | ||||||||||||||||||||||||||||||||||||||||||
| 2447 | Returns : serialized feature object | ||||||||||||||||||||||||||||||||||||||||||
| 2448 | Args : a seqfeature object | ||||||||||||||||||||||||||||||||||||||||||
| 2449 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2450 | |||||||||||||||||||||||||||||||||||||||||||
| 2451 | This method converts a Bio::SeqFeatureI object into a serialized form | ||||||||||||||||||||||||||||||||||||||||||
| 2452 | suitable for storage into a database. The feature's primary ID is set | ||||||||||||||||||||||||||||||||||||||||||
| 2453 | to undef before it is serialized. This avoids any potential mismatch | ||||||||||||||||||||||||||||||||||||||||||
| 2454 | between the primary ID used as the database key and the primary ID | ||||||||||||||||||||||||||||||||||||||||||
| 2455 | stored in the serialized object. | ||||||||||||||||||||||||||||||||||||||||||
| 2456 | |||||||||||||||||||||||||||||||||||||||||||
| 2457 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2458 | |||||||||||||||||||||||||||||||||||||||||||
| 2459 | sub freeze { | ||||||||||||||||||||||||||||||||||||||||||
| 2460 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeze: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2461 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2462 | |||||||||||||||||||||||||||||||||||||||||||
| 2463 | # Bio::SeqFeature::Generic contains cleanup methods, so we need to | ||||||||||||||||||||||||||||||||||||||||||
| 2464 | # localize the methods to undef temporarily so that we can serialize | ||||||||||||||||||||||||||||||||||||||||||
| 2465 | 0 | ▶ | local $obj->{'_root_cleanup_methods'} if exists $obj->{'_root_cleanup_methods'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2466 | |||||||||||||||||||||||||||||||||||||||||||
| 2467 | 0 | my ($id,$store); | |||||||||||||||||||||||||||||||||||||||||
| 2468 | 0 | $id = $obj->primary_id(); | |||||||||||||||||||||||||||||||||||||||||
| 2469 | 0 | $obj->primary_id(undef); # don't want primary ID to be stored in object | |||||||||||||||||||||||||||||||||||||||||
| 2470 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 2471 | 0 | $store = $obj->object_store; | |||||||||||||||||||||||||||||||||||||||||
| 2472 | 0 | $obj->object_store(undef); # don't want a copy of the store in the object | |||||||||||||||||||||||||||||||||||||||||
| 2473 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 2474 | 0 | my $serializer = $self->serializer; | |||||||||||||||||||||||||||||||||||||||||
| 2475 | 0 | my $data; | |||||||||||||||||||||||||||||||||||||||||
| 2476 | 0 | ▶ | if ($serializer eq 'Data::Dumper') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2477 | 0 | my $d = Data::Dumper->new([$obj]); | |||||||||||||||||||||||||||||||||||||||||
| 2478 | 0 | $d->Terse(1); | |||||||||||||||||||||||||||||||||||||||||
| 2479 | 0 | $d->Deepcopy(1); | |||||||||||||||||||||||||||||||||||||||||
| 2480 | 0 | $d->Deparse(1); | |||||||||||||||||||||||||||||||||||||||||
| 2481 | 0 | $data = $d->Dump; | |||||||||||||||||||||||||||||||||||||||||
| 2482 | } elsif ($serializer eq 'Storable') { | ||||||||||||||||||||||||||||||||||||||||||
| 2483 | 0 | local $Storable::forgive_me = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2484 | 0 | local $Storable::Deparse = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2485 | 0 | $data = Storable::nfreeze($obj); | |||||||||||||||||||||||||||||||||||||||||
| 2486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2487 | |||||||||||||||||||||||||||||||||||||||||||
| 2488 | 0 | $obj->primary_id($id); # restore to original state | |||||||||||||||||||||||||||||||||||||||||
| 2489 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 2490 | 0 | $obj->object_store($store); | |||||||||||||||||||||||||||||||||||||||||
| 2491 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 2492 | |||||||||||||||||||||||||||||||||||||||||||
| 2493 | 0 | ▶ | $data = compress($data) if $self->do_compress; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2494 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 2495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2496 | |||||||||||||||||||||||||||||||||||||||||||
| 2497 | =head2 thaw | ||||||||||||||||||||||||||||||||||||||||||
| 2498 | |||||||||||||||||||||||||||||||||||||||||||
| 2499 | Title : thaw | ||||||||||||||||||||||||||||||||||||||||||
| 2500 | Usage : $feature = $db->thaw($serialized_object,$primary_id) | ||||||||||||||||||||||||||||||||||||||||||
| 2501 | Function: unserialize a string into a feature object | ||||||||||||||||||||||||||||||||||||||||||
| 2502 | Returns : Bio::SeqFeatureI object | ||||||||||||||||||||||||||||||||||||||||||
| 2503 | Args : serialized form of object from freeze() and primary_id of object | ||||||||||||||||||||||||||||||||||||||||||
| 2504 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2505 | |||||||||||||||||||||||||||||||||||||||||||
| 2506 | This method is the reverse of the freeze(). The supplied primary_id | ||||||||||||||||||||||||||||||||||||||||||
| 2507 | becomes the primary_id() of the returned Bio::SeqFeatureI object. This | ||||||||||||||||||||||||||||||||||||||||||
| 2508 | implementation checks for a deserialized object in the cache before it | ||||||||||||||||||||||||||||||||||||||||||
| 2509 | calls thaw_object() to do the actual deserialization. | ||||||||||||||||||||||||||||||||||||||||||
| 2510 | |||||||||||||||||||||||||||||||||||||||||||
| 2511 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2512 | |||||||||||||||||||||||||||||||||||||||||||
| 2513 | sub thaw { | ||||||||||||||||||||||||||||||||||||||||||
| 2514 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
thaw: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2515 | 0 | my ($obj,$primary_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 2516 | |||||||||||||||||||||||||||||||||||||||||||
| 2517 | 0 | ▶ | if (my $cache = $self->cache) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2518 | 0 | ▶ | return $cache->fetch($primary_id) if $cache->exists($primary_id); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2519 | 0 | ▶ | my $object = $self->thaw_object($obj,$primary_id) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2520 | 0 | $cache->store($primary_id,$object); | |||||||||||||||||||||||||||||||||||||||||
| 2521 | 0 | return $object; | |||||||||||||||||||||||||||||||||||||||||
| 2522 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2523 | 0 | return $self->thaw_object($obj,$primary_id); | |||||||||||||||||||||||||||||||||||||||||
| 2524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2525 | |||||||||||||||||||||||||||||||||||||||||||
| 2526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2527 | |||||||||||||||||||||||||||||||||||||||||||
| 2528 | =head2 thaw_object | ||||||||||||||||||||||||||||||||||||||||||
| 2529 | |||||||||||||||||||||||||||||||||||||||||||
| 2530 | Title : thaw_object | ||||||||||||||||||||||||||||||||||||||||||
| 2531 | Usage : $feature = $db->thaw_object($serialized_object,$primary_id) | ||||||||||||||||||||||||||||||||||||||||||
| 2532 | Function: unserialize a string into a feature object | ||||||||||||||||||||||||||||||||||||||||||
| 2533 | Returns : Bio::SeqFeatureI object | ||||||||||||||||||||||||||||||||||||||||||
| 2534 | Args : serialized form of object from freeze() and primary_id of object | ||||||||||||||||||||||||||||||||||||||||||
| 2535 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2536 | |||||||||||||||||||||||||||||||||||||||||||
| 2537 | After thaw() checks the cache and comes up empty, this method is | ||||||||||||||||||||||||||||||||||||||||||
| 2538 | invoked to thaw the object. | ||||||||||||||||||||||||||||||||||||||||||
| 2539 | |||||||||||||||||||||||||||||||||||||||||||
| 2540 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2541 | |||||||||||||||||||||||||||||||||||||||||||
| 2542 | sub thaw_object { | ||||||||||||||||||||||||||||||||||||||||||
| 2543 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
thaw_object: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2544 | 0 | my ($obj,$primary_id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 2545 | |||||||||||||||||||||||||||||||||||||||||||
| 2546 | 0 | my $serializer = $self->serializer; | |||||||||||||||||||||||||||||||||||||||||
| 2547 | 0 | my $object; | |||||||||||||||||||||||||||||||||||||||||
| 2548 | |||||||||||||||||||||||||||||||||||||||||||
| 2549 | 0 | ▶ | $obj = uncompress($obj) if $self->do_compress; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2550 | |||||||||||||||||||||||||||||||||||||||||||
| 2551 | 0 | ▶ | if ($serializer eq 'Data::Dumper') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2552 | 0 | $object = eval $obj; | |||||||||||||||||||||||||||||||||||||||||
| 2553 | } elsif ($serializer eq 'Storable') { | ||||||||||||||||||||||||||||||||||||||||||
| 2554 | 0 | local $Storable::forgive_me = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2555 | 0 | local $Storable::Eval = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2556 | 0 | $object = Storable::thaw($obj); | |||||||||||||||||||||||||||||||||||||||||
| 2557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2558 | |||||||||||||||||||||||||||||||||||||||||||
| 2559 | # remember the primary ID of this object as well as the | ||||||||||||||||||||||||||||||||||||||||||
| 2560 | # identity of the store, so that we can do lazy loading; | ||||||||||||||||||||||||||||||||||||||||||
| 2561 | # both of these are wrapped in an eval because not all | ||||||||||||||||||||||||||||||||||||||||||
| 2562 | # bioseqfeatures support them (or want to) | ||||||||||||||||||||||||||||||||||||||||||
| 2563 | 0 | $self->load_class($object); | |||||||||||||||||||||||||||||||||||||||||
| 2564 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 2565 | 0 | $object->primary_id($primary_id); | |||||||||||||||||||||||||||||||||||||||||
| 2566 | 0 | $object->object_store($self); | |||||||||||||||||||||||||||||||||||||||||
| 2567 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 2568 | 0 | $object; | |||||||||||||||||||||||||||||||||||||||||
| 2569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2570 | |||||||||||||||||||||||||||||||||||||||||||
| 2571 | =head2 feature_names | ||||||||||||||||||||||||||||||||||||||||||
| 2572 | |||||||||||||||||||||||||||||||||||||||||||
| 2573 | Title : feature_names | ||||||||||||||||||||||||||||||||||||||||||
| 2574 | Usage : ($names,$aliases) = $db->feature_names($feature) | ||||||||||||||||||||||||||||||||||||||||||
| 2575 | Function: get names and aliases for a feature | ||||||||||||||||||||||||||||||||||||||||||
| 2576 | Returns : an array of names and an array of aliases | ||||||||||||||||||||||||||||||||||||||||||
| 2577 | Args : a Bio::SeqFeatureI object | ||||||||||||||||||||||||||||||||||||||||||
| 2578 | Status : private | ||||||||||||||||||||||||||||||||||||||||||
| 2579 | |||||||||||||||||||||||||||||||||||||||||||
| 2580 | This is an internal utility function which, given a Bio::SeqFeatureI | ||||||||||||||||||||||||||||||||||||||||||
| 2581 | object, returns two array refs. The first is a list of official names | ||||||||||||||||||||||||||||||||||||||||||
| 2582 | for the feature, and the second is a list of aliases. This is slightly | ||||||||||||||||||||||||||||||||||||||||||
| 2583 | skewed towards GFF3 usage, so the official names are the | ||||||||||||||||||||||||||||||||||||||||||
| 2584 | display_name(), plus all tag values named 'Name', plus all tag values | ||||||||||||||||||||||||||||||||||||||||||
| 2585 | named 'ID'. The aliases are all tag values named 'Alias'. | ||||||||||||||||||||||||||||||||||||||||||
| 2586 | |||||||||||||||||||||||||||||||||||||||||||
| 2587 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2588 | |||||||||||||||||||||||||||||||||||||||||||
| 2589 | sub feature_names { | ||||||||||||||||||||||||||||||||||||||||||
| 2590 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feature_names: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2591 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2592 | |||||||||||||||||||||||||||||||||||||||||||
| 2593 | 0 | my $primary_id = $obj->primary_id; | |||||||||||||||||||||||||||||||||||||||||
| 2594 | 0 | my @names; | |||||||||||||||||||||||||||||||||||||||||
| 2595 | 0 | ▶ | push @names,$obj->display_name if defined $obj->display_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2596 | 0 | ▶ | push @names,$obj->get_tag_values('Name') if $obj->has_tag('Name'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2597 | 0 | ▶ | push @names,$obj->get_tag_values('ID') if $obj->has_tag('ID'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2598 | |||||||||||||||||||||||||||||||||||||||||||
| 2599 | # don't think this is desired behavior | ||||||||||||||||||||||||||||||||||||||||||
| 2600 | # @names = grep {defined $_ && $_ ne $primary_id} @names; | ||||||||||||||||||||||||||||||||||||||||||
| 2601 | |||||||||||||||||||||||||||||||||||||||||||
| 2602 | 0 | ▶ | my @aliases = grep {defined} $obj->get_tag_values('Alias') if $obj->has_tag('Alias'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2603 | |||||||||||||||||||||||||||||||||||||||||||
| 2604 | 0 | return (\@names,\@aliases); | |||||||||||||||||||||||||||||||||||||||||
| 2605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2606 | |||||||||||||||||||||||||||||||||||||||||||
| 2607 | =head2 feature_summary | ||||||||||||||||||||||||||||||||||||||||||
| 2608 | |||||||||||||||||||||||||||||||||||||||||||
| 2609 | Title : feature_summary | ||||||||||||||||||||||||||||||||||||||||||
| 2610 | Usage : $summary = $db->feature_summary(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 2611 | Function: returns a coverage summary across indicated region/type | ||||||||||||||||||||||||||||||||||||||||||
| 2612 | Returns : a Bio::SeqFeatureI object containing the "coverage" tag | ||||||||||||||||||||||||||||||||||||||||||
| 2613 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 2614 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 2615 | |||||||||||||||||||||||||||||||||||||||||||
| 2616 | This method is used to get coverage density information across a | ||||||||||||||||||||||||||||||||||||||||||
| 2617 | region of interest. You provide it with a region of interest, optional | ||||||||||||||||||||||||||||||||||||||||||
| 2618 | a list of feature types, and a count of the number of bins over which | ||||||||||||||||||||||||||||||||||||||||||
| 2619 | you want to calculate the coverage density. An object is returned | ||||||||||||||||||||||||||||||||||||||||||
| 2620 | corresponding to the requested region. It contains a tag called | ||||||||||||||||||||||||||||||||||||||||||
| 2621 | "coverage" that will return an array ref of "bins" length. Each | ||||||||||||||||||||||||||||||||||||||||||
| 2622 | element of the array describes the number of features that overlap the | ||||||||||||||||||||||||||||||||||||||||||
| 2623 | bin at this position. | ||||||||||||||||||||||||||||||||||||||||||
| 2624 | |||||||||||||||||||||||||||||||||||||||||||
| 2625 | Arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 2626 | |||||||||||||||||||||||||||||||||||||||||||
| 2627 | Argument Description | ||||||||||||||||||||||||||||||||||||||||||
| 2628 | -------- ----------- | ||||||||||||||||||||||||||||||||||||||||||
| 2629 | |||||||||||||||||||||||||||||||||||||||||||
| 2630 | -seq_id Sequence ID for the region | ||||||||||||||||||||||||||||||||||||||||||
| 2631 | -start Start of region | ||||||||||||||||||||||||||||||||||||||||||
| 2632 | -end End of region | ||||||||||||||||||||||||||||||||||||||||||
| 2633 | -type/-types Feature type of interest or array ref of types | ||||||||||||||||||||||||||||||||||||||||||
| 2634 | -bins Number of bins across region. Defaults to 1000. | ||||||||||||||||||||||||||||||||||||||||||
| 2635 | -iterator Return an iterator across the region | ||||||||||||||||||||||||||||||||||||||||||
| 2636 | |||||||||||||||||||||||||||||||||||||||||||
| 2637 | Note that this method uses an approximate algorithm that is only | ||||||||||||||||||||||||||||||||||||||||||
| 2638 | accurate to 500 bp, so when dealing with bins that are smaller than | ||||||||||||||||||||||||||||||||||||||||||
| 2639 | 1000 bp, you may see some shifting of counts between adjacent bins. | ||||||||||||||||||||||||||||||||||||||||||
| 2640 | |||||||||||||||||||||||||||||||||||||||||||
| 2641 | Although an -iterator option is provided, the method only ever returns | ||||||||||||||||||||||||||||||||||||||||||
| 2642 | a single feature, so this is fairly useless. | ||||||||||||||||||||||||||||||||||||||||||
| 2643 | |||||||||||||||||||||||||||||||||||||||||||
| 2644 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2645 | |||||||||||||||||||||||||||||||||||||||||||
| 2646 | |||||||||||||||||||||||||||||||||||||||||||
| 2647 | sub feature_summary { | ||||||||||||||||||||||||||||||||||||||||||
| 2648 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feature_summary: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2649 | 0 | my ($seq_name,$start,$end,$types,$bins,$iterator) = | |||||||||||||||||||||||||||||||||||||||||
| 2650 | rearrange([['SEQID','SEQ_ID','REF'],'START',['STOP','END'], | ||||||||||||||||||||||||||||||||||||||||||
| 2651 | ['TYPES','TYPE','PRIMARY_TAG'], | ||||||||||||||||||||||||||||||||||||||||||
| 2652 | 'BINS', | ||||||||||||||||||||||||||||||||||||||||||
| 2653 | 'ITERATOR', | ||||||||||||||||||||||||||||||||||||||||||
| 2654 | ],@_); | ||||||||||||||||||||||||||||||||||||||||||
| 2655 | 0 | ▶ | my ($coverage,$tag) = $self->coverage_array(-seqid=> $seq_name, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2656 | -start=> $start, | ||||||||||||||||||||||||||||||||||||||||||
| 2657 | -end => $end, | ||||||||||||||||||||||||||||||||||||||||||
| 2658 | -type => $types, | ||||||||||||||||||||||||||||||||||||||||||
| 2659 | -bins => $bins) or return; | ||||||||||||||||||||||||||||||||||||||||||
| 2660 | 0 | my $score = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2661 | 0 | for (@$coverage) { $score += $_ } | |||||||||||||||||||||||||||||||||||||||||
| 2662 | 0 | $score /= @$coverage; | |||||||||||||||||||||||||||||||||||||||||
| 2663 | |||||||||||||||||||||||||||||||||||||||||||
| 2664 | 0 | my $feature = Bio::SeqFeature::Lite->new(-seq_id => $seq_name, | |||||||||||||||||||||||||||||||||||||||||
| 2665 | -start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 2666 | -end => $end, | ||||||||||||||||||||||||||||||||||||||||||
| 2667 | -type => $tag, | ||||||||||||||||||||||||||||||||||||||||||
| 2668 | -score => $score, | ||||||||||||||||||||||||||||||||||||||||||
| 2669 | -attributes => | ||||||||||||||||||||||||||||||||||||||||||
| 2670 | { coverage => [$coverage] }); | ||||||||||||||||||||||||||||||||||||||||||
| 2671 | 0 | ▶ | return $iterator | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2672 | ? Bio::DB::SeqFeature::Store::FeatureIterator->new($feature) | ||||||||||||||||||||||||||||||||||||||||||
| 2673 | : $feature; | ||||||||||||||||||||||||||||||||||||||||||
| 2674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2675 | |||||||||||||||||||||||||||||||||||||||||||
| 2676 | =head2 coverage_array | ||||||||||||||||||||||||||||||||||||||||||
| 2677 | |||||||||||||||||||||||||||||||||||||||||||
| 2678 | Title : coverage_array | ||||||||||||||||||||||||||||||||||||||||||
| 2679 | Usage : $arrayref = $db->coverage_array(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 2680 | Function: returns a coverage summary across indicated region/type | ||||||||||||||||||||||||||||||||||||||||||
| 2681 | Returns : an array reference | ||||||||||||||||||||||||||||||||||||||||||
| 2682 | Args : see below | ||||||||||||||||||||||||||||||||||||||||||
| 2683 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 2684 | |||||||||||||||||||||||||||||||||||||||||||
| 2685 | This method is used to get coverage density information across a | ||||||||||||||||||||||||||||||||||||||||||
| 2686 | region of interest. The arguments are identical to feature_summary, | ||||||||||||||||||||||||||||||||||||||||||
| 2687 | except that instead of returning a Bio::SeqFeatureI object, it returns | ||||||||||||||||||||||||||||||||||||||||||
| 2688 | an array reference of the desired number of bins. The value of each | ||||||||||||||||||||||||||||||||||||||||||
| 2689 | element corresponds to the number of features in the bin. | ||||||||||||||||||||||||||||||||||||||||||
| 2690 | |||||||||||||||||||||||||||||||||||||||||||
| 2691 | Arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 2692 | |||||||||||||||||||||||||||||||||||||||||||
| 2693 | Argument Description | ||||||||||||||||||||||||||||||||||||||||||
| 2694 | -------- ----------- | ||||||||||||||||||||||||||||||||||||||||||
| 2695 | |||||||||||||||||||||||||||||||||||||||||||
| 2696 | -seq_id Sequence ID for the region | ||||||||||||||||||||||||||||||||||||||||||
| 2697 | -start Start of region | ||||||||||||||||||||||||||||||||||||||||||
| 2698 | -end End of region | ||||||||||||||||||||||||||||||||||||||||||
| 2699 | -type/-types Feature type of interest or array ref of types | ||||||||||||||||||||||||||||||||||||||||||
| 2700 | -bins Number of bins across region. Defaults to 1000. | ||||||||||||||||||||||||||||||||||||||||||
| 2701 | |||||||||||||||||||||||||||||||||||||||||||
| 2702 | Note that this method uses an approximate algorithm that is only | ||||||||||||||||||||||||||||||||||||||||||
| 2703 | accurate to 500 bp, so when dealing with bins that are smaller than | ||||||||||||||||||||||||||||||||||||||||||
| 2704 | 1000 bp, you may see some shifting of counts between adjacent bins. | ||||||||||||||||||||||||||||||||||||||||||
| 2705 | |||||||||||||||||||||||||||||||||||||||||||
| 2706 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2707 | |||||||||||||||||||||||||||||||||||||||||||
| 2708 | sub coverage_array { | ||||||||||||||||||||||||||||||||||||||||||
| 2709 | 0 | ▶ | shift->throw_not_implemented; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage_array: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2710 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2711 | |||||||||||||||||||||||||||||||||||||||||||
| 2712 | |||||||||||||||||||||||||||||||||||||||||||
| 2713 | package Bio::DB::SeqFeature::Store::FeatureIterator; | ||||||||||||||||||||||||||||||||||||||||||
| 2714 | 10 | $Bio::DB::SeqFeature::Store::FeatureIterator::VERSION = '1.7.3'; | |||||||||||||||||||||||||||||||||||||||||
| 2715 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 2716 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2717 | 0 | my @features = @_; | |||||||||||||||||||||||||||||||||||||||||
| 2718 | 0 | ▶ | return bless \@features,ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 2719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2720 | sub next_seq { | ||||||||||||||||||||||||||||||||||||||||||
| 2721 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_seq: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2722 | 0 | ▶ | return unless @$self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2723 | 0 | return shift @$self; | |||||||||||||||||||||||||||||||||||||||||
| 2724 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2725 | |||||||||||||||||||||||||||||||||||||||||||
| 2726 | ▶ | sub begin_work { }# noop | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
begin_work: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2727 | ▶ | sub commit { }# noop | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
commit: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2728 | ▶ | sub rollback { }# noop | |||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rollback: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2729 | |||||||||||||||||||||||||||||||||||||||||||
| 2730 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 2731 | |||||||||||||||||||||||||||||||||||||||||||
| 2732 | __END__ | ||||||||||||||||||||||||||||||||||||||||||