| 1 | package Bio::DB::SeqFeature::Store::DBI::MariaDB; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Bio::DB::SeqFeature::Store::DBI::MariaDB::VERSION = '1.7.5'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | Bio::DB::SeqFeature::Store::DBI::MariaDB -- MariaDB implementation of Bio::DB::SeqFeature::Store | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | use Bio::DB::SeqFeature::Store; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # Open the sequence database | ||||||||||||||||||||||||||||||||||||||||||
| 12 | my $db = Bio::DB::SeqFeature::Store->new(-adaptor => 'DBI::MariaDB', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | -dsn => 'dbi:MariaDB:test'); | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | # get a feature from somewhere | ||||||||||||||||||||||||||||||||||||||||||
| 16 | my $feature = Bio::SeqFeature::Generic->new(...); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # store it | ||||||||||||||||||||||||||||||||||||||||||
| 19 | $db->store($feature) or die "Couldn't store!"; | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | # primary ID of the feature is changed to indicate its primary ID | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # in the database... | ||||||||||||||||||||||||||||||||||||||||||
| 23 | my $id = $feature->primary_id; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | # get the feature back out | ||||||||||||||||||||||||||||||||||||||||||
| 26 | my $f = $db->fetch($id); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # change the feature and update it | ||||||||||||||||||||||||||||||||||||||||||
| 29 | $f->start(100); | ||||||||||||||||||||||||||||||||||||||||||
| 30 | $f->update($f) or die "Couldn't update!"; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | # searching... | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # ...by id | ||||||||||||||||||||||||||||||||||||||||||
| 34 | my @features = $db->fetch_many(@list_of_ids); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # ...by name | ||||||||||||||||||||||||||||||||||||||||||
| 37 | @features = $db->get_features_by_name('ZK909'); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | # ...by alias | ||||||||||||||||||||||||||||||||||||||||||
| 40 | @features = $db->get_features_by_alias('sma-3'); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # ...by type | ||||||||||||||||||||||||||||||||||||||||||
| 43 | @features = $db->get_features_by_name('gene'); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # ...by location | ||||||||||||||||||||||||||||||||||||||||||
| 46 | @features = $db->get_features_by_location(-seq_id=>'Chr1',-start=>4000,-end=>600000); | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | # ...by attribute | ||||||||||||||||||||||||||||||||||||||||||
| 49 | @features = $db->get_features_by_attribute({description => 'protein kinase'}) | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # ...by the GFF "Note" field | ||||||||||||||||||||||||||||||||||||||||||
| 52 | @result_list = $db->search_notes('kinase'); | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | # ...by arbitrary combinations of selectors | ||||||||||||||||||||||||||||||||||||||||||
| 55 | @features = $db->features(-name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | -type => $types, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | -seq_id => $seqid, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | -start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | -end => $end, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | -attributes => $attributes); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | # ...using an iterator | ||||||||||||||||||||||||||||||||||||||||||
| 63 | my $iterator = $db->get_seq_stream(-name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | -type => $types, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | -seq_id => $seqid, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | -start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | -end => $end, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | -attributes => $attributes); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | while (my $feature = $iterator->next_seq) { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | # do something with the feature | ||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | # ...limiting the search to a particular region | ||||||||||||||||||||||||||||||||||||||||||
| 75 | my $segment = $db->segment('Chr1',5000=>6000); | ||||||||||||||||||||||||||||||||||||||||||
| 76 | my @features = $segment->features(-type=>['mRNA','match']); | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | # getting & storing sequence information | ||||||||||||||||||||||||||||||||||||||||||
| 79 | # Warning: this returns a string, and not a PrimarySeq object | ||||||||||||||||||||||||||||||||||||||||||
| 80 | $db->insert_sequence('Chr1','GATCCCCCGGGATTCCAAAA...'); | ||||||||||||||||||||||||||||||||||||||||||
| 81 | my $sequence = $db->fetch_sequence('Chr1',5000=>6000); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | # what feature types are defined in the database? | ||||||||||||||||||||||||||||||||||||||||||
| 84 | my @types = $db->types; | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | # create a new feature in the database | ||||||||||||||||||||||||||||||||||||||||||
| 87 | my $feature = $db->new_feature(-primary_tag => 'mRNA', | ||||||||||||||||||||||||||||||||||||||||||
| 88 | -seq_id => 'chr3', | ||||||||||||||||||||||||||||||||||||||||||
| 89 | -start => 10000, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | -end => 11000); | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | Bio::DB::SeqFeature::Store::MariaDB is the MariaDB adaptor for | ||||||||||||||||||||||||||||||||||||||||||
| 95 | Bio::DB::SeqFeature::Store. You will not create it directly, but | ||||||||||||||||||||||||||||||||||||||||||
| 96 | instead use Bio::DB::SeqFeature::Store-E<gt>new() to do so. | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | See L<Bio::DB::SeqFeature::Store> for complete usage instructions. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | =head2 Using the MariaDB adaptor | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | Before you can use the adaptor, you must use the mariadb-admin tool to | ||||||||||||||||||||||||||||||||||||||||||
| 103 | create a database and establish a user account with write | ||||||||||||||||||||||||||||||||||||||||||
| 104 | permission. In order to use "fast" loading, the user account must have | ||||||||||||||||||||||||||||||||||||||||||
| 105 | "file" privileges. | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | To establish a connection to the database, call | ||||||||||||||||||||||||||||||||||||||||||
| 108 | Bio::DB::SeqFeature::Store-E<gt>new(-adaptor=E<gt>'DBI::MariaDB',@more_args). The | ||||||||||||||||||||||||||||||||||||||||||
| 109 | additional arguments are as follows: | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | Argument name Description | ||||||||||||||||||||||||||||||||||||||||||
| 112 | ------------- ----------- | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | -dsn The database name. You can abbreviate | ||||||||||||||||||||||||||||||||||||||||||
| 115 | "dbi:mariadb:foo" as "foo" if you wish. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | -user Username for authentication. | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | -pass Password for authentication. | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | -namespace A prefix to attach to each table. This allows you | ||||||||||||||||||||||||||||||||||||||||||
| 122 | to have several virtual databases in the same | ||||||||||||||||||||||||||||||||||||||||||
| 123 | physical database. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | -temp Boolean flag. If true, a temporary database | ||||||||||||||||||||||||||||||||||||||||||
| 126 | will be created and destroyed as soon as | ||||||||||||||||||||||||||||||||||||||||||
| 127 | the Store object goes out of scope. (synonym -temporary) | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | -autoindex Boolean flag. If true, features in the database will be | ||||||||||||||||||||||||||||||||||||||||||
| 130 | reindexed every time they change. This is the default. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | -tmpdir Directory in which to place temporary files during "fast" loading. | ||||||||||||||||||||||||||||||||||||||||||
| 134 | Defaults to File::Spec->tmpdir(). (synonyms -dump_dir, -dumpdir, -tmp) | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | -dbi_options A hashref to pass to DBI->connect's 4th argument, the "attributes." | ||||||||||||||||||||||||||||||||||||||||||
| 137 | (synonyms -options, -dbi_attr) | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | -write Pass true to open database for writing or updating. | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | If successful, a new instance of | ||||||||||||||||||||||||||||||||||||||||||
| 142 | Bio::DB::SeqFeature::Store::DBI::MariaDB will be returned. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | In addition to the standard methods supported by all well-behaved | ||||||||||||||||||||||||||||||||||||||||||
| 145 | Bio::DB::SeqFeature::Store databases, several following | ||||||||||||||||||||||||||||||||||||||||||
| 146 | adaptor-specific methods are provided. These are described in the next | ||||||||||||||||||||||||||||||||||||||||||
| 147 | sections. | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | use base 'Bio::DB::SeqFeature::Store'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | use Bio::DB::SeqFeature::Store::DBI::Iterator; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | use DBI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | ▶ | use Memoize; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | use Cwd 'abs_path'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | use Bio::DB::GFF::Util::Rearrange 'rearrange'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | ▶ | use Bio::SeqFeature::Lite; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | use Carp 'carp','cluck','croak'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | use constant DEBUG=>0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | # from the MariaDB documentation... | ||||||||||||||||||||||||||||||||||||||||||
| 165 | # WARNING: if your sequence uses coordinates greater than 2 GB, you are out of luck! | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | use constant MAX_INT => 2_147_483_647; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | ▶ | use constant MIN_INT => -2_147_483_648; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | ▶ | use constant MAX_BIN => 1_000_000_000; # size of largest feature = 1 Gb | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | use constant MIN_BIN => 1000; # smallest bin we'll make - on a 100 Mb chromosome, there'll be 100,000 of these | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | ▶ | use constant SUMMARY_BIN_SIZE => 1000; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | # tier 0 == 1000 bp bins | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # tier 1 == 10,000 bp bins | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # etc. | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | memoize('_typeid'); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | memoize('_locationid'); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | memoize('_attributeid'); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | memoize('dump_path'); | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # object initialization | ||||||||||||||||||||||||||||||||||||||||||
| 183 | # | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my ($dsn, | |||||||||||||||||||||||||||||||||||||||||
| 187 | $is_temporary, | ||||||||||||||||||||||||||||||||||||||||||
| 188 | $autoindex, | ||||||||||||||||||||||||||||||||||||||||||
| 189 | $namespace, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | $dump_dir, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | $user, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | $pass, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | $dbi_options, | ||||||||||||||||||||||||||||||||||||||||||
| 194 | $writeable, | ||||||||||||||||||||||||||||||||||||||||||
| 195 | $create, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | ) = rearrange(['DSN', | ||||||||||||||||||||||||||||||||||||||||||
| 197 | ['TEMP','TEMPORARY'], | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 'AUTOINDEX', | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 'NAMESPACE', | ||||||||||||||||||||||||||||||||||||||||||
| 200 | ['DUMP_DIR','DUMPDIR','TMP','TMPDIR'], | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 'USER', | ||||||||||||||||||||||||||||||||||||||||||
| 202 | ['PASS','PASSWD','PASSWORD'], | ||||||||||||||||||||||||||||||||||||||||||
| 203 | ['OPTIONS','DBI_OPTIONS','DBI_ATTR'], | ||||||||||||||||||||||||||||||||||||||||||
| 204 | ['WRITE','WRITEABLE'], | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 'CREATE', | ||||||||||||||||||||||||||||||||||||||||||
| 206 | ],@_); | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $dbi_options ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dbi_options ||= {}
MC/DC0%0/1
$dbi_options ||= {}
$dbi_options
Truth table0%0/2
A
A= $dbi_options
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $writeable = 1 if $is_temporary or $dump_dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$is_temporary or $dump_dir
MC/DC0%0/2
$is_temporary or $dump_dir
$is_temporary
$dump_dir
Truth table0%0/3
A or B
A= $is_temporaryB= $dump_dir
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | $dsn or $self->throw("Usage: ".__PACKAGE__."->init(-dsn => \$dbh || \$dsn)"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $dbh; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if (ref $dsn) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $dbh = $dsn; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $dsn = "dbi:MariaDB:$dsn" unless $dsn =~ /^dbi:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | $dbh = DBI->connect($dsn,$user,$pass,$dbi_options) or $self->throw($DBI::errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $dbh->{mariadb_auto_reconnect} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $self->{dbh} = $dbh; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->{is_temp} = $is_temporary; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $self->{namespace} = $namespace; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $self->{writeable} = $writeable; | |||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->default_settings; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $self->autoindex($autoindex) if defined $autoindex; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | $self->dumpdir($dump_dir) if $dump_dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if ($self->is_temp) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $self->init_tmp_database(); | |||||||||||||||||||||||||||||||||||||||||
| 230 | } elsif ($create) { | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $self->init_database('erase'); | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub writeable { shift->{writeable} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
writeable: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub can_store_parentage { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_store_parentage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub table_definitions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_definitions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 241 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | feature => <<END, | |||||||||||||||||||||||||||||||||||||||||
| 243 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 244 | id int(10) auto_increment primary key, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | typeid int(10) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 246 | seqid int(10), | ||||||||||||||||||||||||||||||||||||||||||
| 247 | start int, | ||||||||||||||||||||||||||||||||||||||||||
| 248 | end int, | ||||||||||||||||||||||||||||||||||||||||||
| 249 | strand tinyint default 0, | ||||||||||||||||||||||||||||||||||||||||||
| 250 | tier tinyint, | ||||||||||||||||||||||||||||||||||||||||||
| 251 | bin int, | ||||||||||||||||||||||||||||||||||||||||||
| 252 | indexed tinyint default 1, | ||||||||||||||||||||||||||||||||||||||||||
| 253 | object MEDIUMBLOB not null, | ||||||||||||||||||||||||||||||||||||||||||
| 254 | index(seqid,tier,bin,typeid), | ||||||||||||||||||||||||||||||||||||||||||
| 255 | index(typeid) | ||||||||||||||||||||||||||||||||||||||||||
| 256 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 257 | END | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | locationlist => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 260 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 261 | id int(10) auto_increment primary key, | ||||||||||||||||||||||||||||||||||||||||||
| 262 | seqname varchar(255) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | index(seqname) | ||||||||||||||||||||||||||||||||||||||||||
| 264 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 265 | END | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | typelist => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 268 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 269 | id int(10) auto_increment primary key, | ||||||||||||||||||||||||||||||||||||||||||
| 270 | tag varchar(255) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 271 | index(tag) | ||||||||||||||||||||||||||||||||||||||||||
| 272 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 273 | END | ||||||||||||||||||||||||||||||||||||||||||
| 274 | name => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 275 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 276 | id int(10) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 277 | name varchar(255) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 278 | display_name tinyint default 0, | ||||||||||||||||||||||||||||||||||||||||||
| 279 | index(id), | ||||||||||||||||||||||||||||||||||||||||||
| 280 | index(name) | ||||||||||||||||||||||||||||||||||||||||||
| 281 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 282 | END | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | attribute => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 285 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 286 | id int(10) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 287 | attribute_id int(10) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 288 | attribute_value text, | ||||||||||||||||||||||||||||||||||||||||||
| 289 | index(id), | ||||||||||||||||||||||||||||||||||||||||||
| 290 | index(attribute_id,attribute_value(10)) | ||||||||||||||||||||||||||||||||||||||||||
| 291 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 292 | END | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | attributelist => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 296 | id int(10) auto_increment primary key, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | tag varchar(255) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | index(tag) | ||||||||||||||||||||||||||||||||||||||||||
| 299 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 300 | END | ||||||||||||||||||||||||||||||||||||||||||
| 301 | parent2child => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 302 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 303 | id int(10) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 304 | child int(10) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 305 | unique index(id,child) | ||||||||||||||||||||||||||||||||||||||||||
| 306 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 307 | END | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | meta => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 310 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 311 | name varchar(128) primary key, | ||||||||||||||||||||||||||||||||||||||||||
| 312 | value varchar(128) not null | ||||||||||||||||||||||||||||||||||||||||||
| 313 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 314 | END | ||||||||||||||||||||||||||||||||||||||||||
| 315 | sequence => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 316 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 317 | id int(10) not null, | ||||||||||||||||||||||||||||||||||||||||||
| 318 | offset int(10) unsigned not null, | ||||||||||||||||||||||||||||||||||||||||||
| 319 | sequence longblob, | ||||||||||||||||||||||||||||||||||||||||||
| 320 | primary key(id,offset) | ||||||||||||||||||||||||||||||||||||||||||
| 321 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 322 | END | ||||||||||||||||||||||||||||||||||||||||||
| 323 | interval_stats => <<END, | ||||||||||||||||||||||||||||||||||||||||||
| 324 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 325 | typeid integer not null, | ||||||||||||||||||||||||||||||||||||||||||
| 326 | seqid integer not null, | ||||||||||||||||||||||||||||||||||||||||||
| 327 | bin integer not null, | ||||||||||||||||||||||||||||||||||||||||||
| 328 | cum_count integer not null, | ||||||||||||||||||||||||||||||||||||||||||
| 329 | primary key(typeid,seqid,bin) | ||||||||||||||||||||||||||||||||||||||||||
| 330 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 331 | END | ||||||||||||||||||||||||||||||||||||||||||
| 332 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 336 | # default settings -- will create and populate meta table if needed | ||||||||||||||||||||||||||||||||||||||||||
| 337 | # | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub default_settings { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_settings: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->maybe_create_meta(); | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $self->SUPER::default_settings; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $self->autoindex(1); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $self->dumpdir(File::Spec->tmpdir); | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 348 | # retrieve database handle | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | sub dbh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $d = $self->{dbh}; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | $self->{dbh} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $self->{dbh}{InactiveDestroy} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 360 | $self->{dbh} = $self->{dbh}->clone | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | unless $self->is_temp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 365 | # get/set directory for bulk load tables | ||||||||||||||||||||||||||||||||||||||||||
| 366 | # | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | sub dumpdir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dumpdir: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $d = $self->{dumpdir}; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $self->{dumpdir} = abs_path(shift) if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 375 | # table namespace (multiple dbs in one MariaDB db) | ||||||||||||||||||||||||||||||||||||||||||
| 376 | # | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub namespace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
namespace: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $d = $self->{namespace}; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | $self->{namespace} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 385 | # Required for Pg not MariaDB | ||||||||||||||||||||||||||||||||||||||||||
| 386 | # | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | sub remove_namespace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_namespace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 392 | # find a path that corresponds to a dump table | ||||||||||||||||||||||||||||||||||||||||||
| 393 | # | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub dump_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_path: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my $table = $self->_qualify(shift); | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | return "$self->{dumpdir}/$table.$$"; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 401 | # make a filehandle (writeable) that corresponds to a dump table | ||||||||||||||||||||||||||||||||||||||||||
| 402 | # | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | sub dump_filehandle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_filehandle: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $table = shift; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | eval "require IO::File" unless IO::File->can('new'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $path = $self->dump_path($table); | |||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | my $fh = $self->{filehandles}{$path} ||= IO::File->new(">$path"); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"filehandles"}{$path} ||= "IO::File"->new(">$path")
MC/DC0%0/2
$self->{"filehandles"}{$path} ||= "IO::File"->new(">$path")
$self->{"filehandles"}{$path}
"IO::File"->new(">$path")
Truth table0%0/3
A ||= B
A= $self->{"filehandles"}{$path}B= "IO::File"->new(">$path")
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $fh; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 413 | # find the next ID for a feature (used only during bulk loading) | ||||||||||||||||||||||||||||||||||||||||||
| 414 | # | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | sub next_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_id: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | $self->{max_id} ||= $self->max_id; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"max_id"} ||= $self->max_id
MC/DC0%0/2
$self->{"max_id"} ||= $self->max_id
$self->{"max_id"}
$self->max_id
Truth table0%0/3
A ||= B
A= $self->{"max_id"}B= $self->max_id
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return ++$self->{max_id}; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 422 | # find the maximum ID for a feature (used only during bulk loading) | ||||||||||||||||||||||||||||||||||||||||||
| 423 | # | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub max_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_id: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my $sth = $self->_prepare("SELECT max(id) from $features"); | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | $sth->execute or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my ($id) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $id; | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 434 | # wipe database clean and reinstall schema | ||||||||||||||||||||||||||||||||||||||||||
| 435 | # | ||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | sub _init_database { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_database: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $erase = shift; | |||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $tables = $self->table_definitions; | |||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | for my $t (keys %$tables) { | |||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | next if $t eq 'meta'; # don't get rid of meta data! | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $table = $self->_qualify($t); | |||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | $dbh->do("DROP table IF EXISTS $table") if $erase; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $query = "CREATE TABLE IF NOT EXISTS $table $tables->{$t}"; | |||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $self->_create_table($dbh,$query); | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | $self->subfeatures_are_indexed(1) if $erase; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | sub init_tmp_database { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_tmp_database: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my $tables = $self->table_definitions; | |||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | for my $t (keys %$tables) { | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | next if $t eq 'meta'; # done earlier | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $table = $self->_qualify($t); | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $query = "CREATE TEMPORARY TABLE $table $tables->{$t}"; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $self->_create_table($dbh,$query); | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub _create_table { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_table: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my ($dbh,$query) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | for my $q (split ';',$query) { | |||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | chomp($q); | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | next unless $q =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | $dbh->do("$q;\n") or $self->throw($dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | sub maybe_create_meta { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maybe_create_meta: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | return unless $self->writeable; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $meta = $self->_meta_table; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $tables = $self->table_definitions; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | my $temporary = $self->is_temp ? 'TEMPORARY' : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $self->dbh->do("CREATE $temporary TABLE IF NOT EXISTS $meta $tables->{meta}"); | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 489 | # use temporary tables | ||||||||||||||||||||||||||||||||||||||||||
| 490 | # | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | sub is_temp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_temp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | shift->{is_temp}; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | sub attributes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attributes: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $attributelist_table = $self->_attributelist_table; | |||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | my $a = $dbh->selectcol_arrayref("SELECT tag FROM $attributelist_table") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | or $self->throw($dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | return @$a; | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | sub _store { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_store: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | # special case for bulk updates | ||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | return $self->_dump_store(@_) if $self->{bulk_update_in_progress}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $indexed = shift; | |||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $autoindex = $self->autoindex; | |||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | local $dbh->{RaiseError} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->begin_work; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | for my $obj (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $self->replace($obj,$indexed); | |||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | $self->_update_indexes($obj) if $indexed && $autoindex; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$indexed and $autoindex
MC/DC0%0/2
$indexed and $autoindex
$indexed
$autoindex
Truth table0%0/3
A and B
A= $indexedB= $autoindex
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | warn "Transaction aborted because $@"; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $self->rollback; | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $self->commit; | |||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | # remember whether we are have ever stored a non-indexed feature | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | unless ($indexed or $self->{indexed_flag}++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$indexed or $self->{"indexed_flag"}++
MC/DC0%0/2
$indexed or $self->{"indexed_flag"}++
$indexed
$self->{"indexed_flag"}++
Truth table0%0/3
A or B
A= $indexedB= $self->{"indexed_flag"}++
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $self->subfeatures_are_indexed(0); | |||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $count; | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | # we memoize this in order to avoid making zillions of calls | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | sub autoindex { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autoindex: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | # special case for bulk update -- need to build the indexes | ||||||||||||||||||||||||||||||||||||||||||
| 547 | # at the same time we build the main feature table | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | return 1 if $self->{bulk_update_in_progress}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $d = $self->setting('autoindex'); | |||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | $self->setting(autoindex=>shift) if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | $d; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | sub _start_bulk_update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start_bulk_update: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $self->begin_work; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $self->{bulk_update_in_progress}++; | |||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | sub _finish_bulk_update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish_bulk_update: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | my $dir = $self->{dumpdir} || '.'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'dumpdir'} || '.'
MC/DC0%0/1
$self->{'dumpdir'} || '.'
$self->{'dumpdir'}
Truth table0%0/2
A
A= $self->{'dumpdir'}
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | for my $table ($self->_feature_table,$self->index_tables) { | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | my $fh = $self->dump_filehandle($table); | |||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $path = $self->dump_path($table); | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $fh->close; | |||||||||||||||||||||||||||||||||||||||||
| 569 | #print STDERR "$path\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | $dbh->do("LOAD DATA LOCAL INFILE '$path' REPLACE INTO TABLE $table FIELDS OPTIONALLY ENCLOSED BY '\\''") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | or $self->throw($dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | unlink $path; | |||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | delete $self->{bulk_update_in_progress}; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | delete $self->{ filehandles}; | |||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $self->commit; | |||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 582 | # Add a subparts to a feature. Both feature and all subparts must already be in database. | ||||||||||||||||||||||||||||||||||||||||||
| 583 | # | ||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | sub _add_SeqFeature { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_SeqFeature: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | # special purpose method for case when we are doing a bulk update | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | return $self->_dump_add_SeqFeature(@_) if $self->{bulk_update_in_progress}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my $parent = shift; | |||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my @children = @_; | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | local $dbh->{RaiseError} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my $parent2child = $self->_parent2child_table(); | |||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | my $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 600 | REPLACE INTO $parent2child (id,child) VALUES (?,?) | ||||||||||||||||||||||||||||||||||||||||||
| 601 | END | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | my $parent_id = (ref $parent ? $parent->primary_id : $parent) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | or $self->throw("$parent should have a primary_id"); | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | $self->begin_work or $self->throw($dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | for my $child (@children) { | |||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | my $child_id = ref $child ? $child->primary_id : $child; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | defined $child_id or die "no primary ID known for $child"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $sth->execute($parent_id,$child_id); | |||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | warn "Transaction aborted because $@"; | |||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | $self->rollback; | |||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||
| 620 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | $self->commit; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | $count; | |||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | sub _fetch_SeqFeatures { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_SeqFeatures: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $parent = shift; | |||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my @types = @_; | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | my $parent_id = $parent->primary_id or $self->throw("$parent should have a primary_id"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my $parent2child = $self->_parent2child_table(); | |||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | my @from = ("$features as f","$parent2child as c"); | |||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | my @where = ('f.id=c.child','c.id=?'); | |||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | my @args = $parent_id; | |||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if (@types) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | my ($from,$where,undef,@a) = $self->_types_sql(\@types,'f'); | |||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | push @from,$from if $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | push @where,$where if $where; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | push @args,@a; | |||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $from = join ', ',@from; | |||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | my $where = join ' AND ',@where; | |||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $query = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 651 | SELECT f.id,f.object | ||||||||||||||||||||||||||||||||||||||||||
| 652 | FROM $from | ||||||||||||||||||||||||||||||||||||||||||
| 653 | WHERE $where | ||||||||||||||||||||||||||||||||||||||||||
| 654 | END | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | $self->_print_query($query,@args) if DEBUG || $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | my $sth = $self->_prepare($query) or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | $sth->execute(@args) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | return $self->_sth2objs($sth); | |||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 665 | # get primary sequence between start and end | ||||||||||||||||||||||||||||||||||||||||||
| 666 | # | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | sub _fetch_sequence { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_sequence: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my ($seqid,$start,$end) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | # backward compatibility to the old days when I liked reverse complementing | ||||||||||||||||||||||||||||||||||||||||||
| 672 | # dna by specifying $start > $end | ||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $reversed; | |||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | if (defined $start && defined $end && $start > $end) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $start and defined $end and $start > $end
defined $start and defined $end
MC/DC0%0/3
defined $start and defined $end and $start > $end
defined $start
defined $end
$start > $end
Truth table0%0/4
A and B and C
A= defined $startB= defined $endC= $start > $end
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $reversed++; | |||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ($start,$end) = ($end,$start); | |||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | $start-- if defined $start; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | $end-- if defined $end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | my $id = $self->_locationid($seqid); | |||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | my $offset1 = $self->_offset_boundary($id,$start || 'left'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$start || 'left'
MC/DC0%0/1
$start || 'left'
$start
Truth table0%0/2
A
A= $start
| |||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | my $offset2 = $self->_offset_boundary($id,$end || 'right'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$end || 'right'
MC/DC0%0/1
$end || 'right'
$end
Truth table0%0/2
A
A= $end
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $sequence_table = $self->_sequence_table; | |||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my $sql = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 687 | SELECT sequence,offset | ||||||||||||||||||||||||||||||||||||||||||
| 688 | FROM $sequence_table as s | ||||||||||||||||||||||||||||||||||||||||||
| 689 | WHERE s.id=? | ||||||||||||||||||||||||||||||||||||||||||
| 690 | AND s.offset >= ? | ||||||||||||||||||||||||||||||||||||||||||
| 691 | AND s.offset <= ? | ||||||||||||||||||||||||||||||||||||||||||
| 692 | ORDER BY s.offset | ||||||||||||||||||||||||||||||||||||||||||
| 693 | END | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my $sth = $self->_prepare($sql); | |||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | my $seq = ''; | |||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | $self->_print_query($sql,$id,$offset1,$offset2) if DEBUG || $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | $sth->execute($id,$offset1,$offset2) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | while (my($frag,$offset) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | substr($frag,0,$start-$offset) = '' if defined $start && $start > $offset; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $start and $start > $offset
MC/DC0%0/2
defined $start and $start > $offset
defined $start
$start > $offset
Truth table0%0/3
A and B
A= defined $startB= $start > $offset
| |||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | $seq .= $frag; | |||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | substr($seq,$end-$start+1) = '' if defined $end && $end-$start+1 < length($seq); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $end and $end - $start + 1 < length $seq
MC/DC0%0/2
defined $end and $end - $start + 1 < length $seq
defined $end
$end - $start + 1 < length $seq
Truth table0%0/3
A and B
A= defined $endB= $end - $start + 1 < length $seq
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | if ($reversed) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | $seq = reverse $seq; | |||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | $seq =~ tr/gatcGATC/ctagCTAG/; | |||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $seq; | |||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | sub _offset_boundary { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_offset_boundary: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my ($seqid,$position) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $sequence_table = $self->_sequence_table; | |||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my $locationlist_table = $self->_locationlist_table; | |||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | my $sql; | |||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | $sql = $position eq 'left' ? "SELECT min(offset) FROM $sequence_table as s WHERE s.id=?" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 722 | :$position eq 'right' ? "SELECT max(offset) FROM $sequence_table as s WHERE s.id=?" | ||||||||||||||||||||||||||||||||||||||||||
| 723 | :"SELECT max(offset) FROM $sequence_table as s WHERE s.id=? AND offset<=?"; | ||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | my $sth = $self->_prepare($sql); | |||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | my @args = $position =~ /^-?\d+$/ ? ($seqid,$position) : ($seqid); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | $self->_print_query($sql,@args) if DEBUG || $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | $sth->execute(@args) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my $boundary = $sth->fetchall_arrayref->[0][0]; | |||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | return $boundary; | |||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 735 | # add namespace to tablename | ||||||||||||||||||||||||||||||||||||||||||
| 736 | # | ||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | sub _qualify { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_qualify: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | my $table_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my $namespace = $self->namespace; | |||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | return $table_name if (!defined $namespace || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $namespace or index($table_name, $namespace) == 0
MC/DC0%0/2
not defined $namespace or index($table_name, $namespace) == 0
not defined $namespace
index($table_name, $namespace) == 0
Truth table0%0/3
not(A) or B
A= not defined $namespaceB= index($table_name, $namespace) == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 742 | # is namespace already present in table name? | ||||||||||||||||||||||||||||||||||||||||||
| 743 | index($table_name, $namespace) == 0); | ||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | return "${namespace}_${table_name}"; | |||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 748 | # Fetch a Bio::SeqFeatureI from database using its primary_id | ||||||||||||||||||||||||||||||||||||||||||
| 749 | # | ||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | sub _fetch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | @_ or $self->throw("usage: fetch(\$primary_id)"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | my $primary_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | my $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 756 | SELECT id,object FROM $features WHERE id=? | ||||||||||||||||||||||||||||||||||||||||||
| 757 | END | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | $sth->execute($primary_id) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | my $obj = $self->_sth2obj($sth); | |||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $obj; | |||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 765 | # Efficiently fetch a series of IDs from the database | ||||||||||||||||||||||||||||||||||||||||||
| 766 | # Can pass an array or an array ref | ||||||||||||||||||||||||||||||||||||||||||
| 767 | # | ||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | sub _fetch_many { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_many: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | @_ or $self->throw('usage: fetch_many($id1,$id2,$id3...)'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | my $ids = join ',',map {ref($_) ? @$_ : $_} @_ or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | my $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 775 | SELECT id,object FROM $features WHERE id IN ($ids) | ||||||||||||||||||||||||||||||||||||||||||
| 776 | END | ||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | $sth->execute() or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | return $self->_sth2objs($sth); | |||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | ▶ | sub _features { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_features: not called CC=39 SCAR=73.5
| |||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | my ($seq_id,$start,$end,$strand, | |||||||||||||||||||||||||||||||||||||||||
| 784 | $name,$class,$allow_aliases, | ||||||||||||||||||||||||||||||||||||||||||
| 785 | $types, | ||||||||||||||||||||||||||||||||||||||||||
| 786 | $attributes, | ||||||||||||||||||||||||||||||||||||||||||
| 787 | $range_type, | ||||||||||||||||||||||||||||||||||||||||||
| 788 | $fromtable, | ||||||||||||||||||||||||||||||||||||||||||
| 789 | $iterator, | ||||||||||||||||||||||||||||||||||||||||||
| 790 | $sources, | ||||||||||||||||||||||||||||||||||||||||||
| 791 | ) = rearrange([['SEQID','SEQ_ID','REF'],'START',['STOP','END'],'STRAND', | ||||||||||||||||||||||||||||||||||||||||||
| 792 | 'NAME','CLASS','ALIASES', | ||||||||||||||||||||||||||||||||||||||||||
| 793 | ['TYPES','TYPE','PRIMARY_TAG'], | ||||||||||||||||||||||||||||||||||||||||||
| 794 | ['ATTRIBUTES','ATTRIBUTE'], | ||||||||||||||||||||||||||||||||||||||||||
| 795 | 'RANGE_TYPE', | ||||||||||||||||||||||||||||||||||||||||||
| 796 | 'FROM_TABLE', | ||||||||||||||||||||||||||||||||||||||||||
| 797 | 'ITERATOR', | ||||||||||||||||||||||||||||||||||||||||||
| 798 | ['SOURCE','SOURCES'], | ||||||||||||||||||||||||||||||||||||||||||
| 799 | ],@_); | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | my (@from,@where,@args,@group); | |||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | $range_type ||= 'overlaps'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$range_type ||= "overlaps"
MC/DC0%0/1
$range_type ||= "overlaps"
$range_type
Truth table0%0/2
A
A= $range_type
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | @from = "$features as f"; | |||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 808 | # hacky backward compatibility workaround | ||||||||||||||||||||||||||||||||||||||||||
| 809 | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | $name = "$class:$name" if defined $class && length $class > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $class and length $class > 0
MC/DC0%0/2
defined $class and length $class > 0
defined $class
length $class > 0
Truth table0%0/3
A and B
A= defined $classB= length $class > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 811 | # last argument is the join field | ||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | my ($from,$where,$group,@a) = $self->_name_sql($name,$allow_aliases,'f.id'); | |||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | ▶ | push @from,$from if $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | push @where,$where if $where; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | push @group,$group if $group; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | push @args,@a; | |||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | if (defined $seq_id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 820 | # last argument is the name of the features table | ||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | my ($from,$where,$group,@a) = $self->_location_sql($seq_id,$start,$end,$range_type,$strand,'f'); | |||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | push @from,$from if $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | ▶ | push @where,$where if $where; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | push @group,$group if $group; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | push @args,@a; | |||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | if (defined($sources)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | my @sources = ref($sources) eq 'ARRAY' ? @{$sources} : ($sources); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | if (defined($types)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | ▶ | my @types = ref($types) eq 'ARRAY' ? @{$types} : ($types); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | my @final_types; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | foreach my $type (@types) { | |||||||||||||||||||||||||||||||||||||||||
| 834 | # *** not sure what to do if user supplies both -source and -type | ||||||||||||||||||||||||||||||||||||||||||
| 835 | # where the type includes a source! | ||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | if ($type =~ /:/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | push(@final_types, $type); | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | foreach my $source (@sources) { | |||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | push(@final_types, $type.':'.$source); | |||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | $types = \@final_types; | |||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||
| 847 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | $types = [map { ':'.$_ } @sources]; | |||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | if (defined($types)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 853 | # last argument is the name of the features table | ||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | my ($from,$where,$group,@a) = $self->_types_sql($types,'f'); | |||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | push @from,$from if $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | ▶ | push @where,$where if $where; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | ▶ | push @group,$group if $group; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | push @args,@a; | |||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | if (defined $attributes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 862 | # last argument is the join field | ||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | my ($from,$where,$group,@a) = $self->_attributes_sql($attributes,'f.id'); | |||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | push @from,$from if $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | push @where,$where if $where; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | ▶ | push @group,$group if $group; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | push @args,@a; | |||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | if (defined $fromtable) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 871 | # last argument is the join field | ||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | my ($from,$where,$group,@a) = $self->_from_table_sql($fromtable,'f.id'); | |||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | push @from,$from if $from; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | push @where,$where if $where; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | ▶ | push @group,$group if $group; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | push @args,@a; | |||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | # if no other criteria are specified, then | ||||||||||||||||||||||||||||||||||||||||||
| 880 | # only fetch indexed (i.e. top level objects) | ||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | @where = 'indexed=1' unless @where; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | my $from = join ', ',@from; | |||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my $where = join ' AND ',map {"($_)"} @where; | |||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | my $group = join ', ',@group; | |||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | ▶ | $group = "GROUP BY $group" if @group; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | my $query = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 889 | SELECT f.id,f.object,f.typeid,f.seqid,f.start,f.end,f.strand | ||||||||||||||||||||||||||||||||||||||||||
| 890 | FROM $from | ||||||||||||||||||||||||||||||||||||||||||
| 891 | WHERE $where | ||||||||||||||||||||||||||||||||||||||||||
| 892 | $group | ||||||||||||||||||||||||||||||||||||||||||
| 893 | END | ||||||||||||||||||||||||||||||||||||||||||
| 894 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | ▶ | $self->_print_query($query,@args) if DEBUG || $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | ▶ | my $sth = $self->_prepare($query) or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | $sth->execute(@args) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | return $iterator ? Bio::DB::SeqFeature::Store::DBI::Iterator->new($sth,$self) : $self->_sth2objs($sth); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | ▶ | sub _aggregate_bins { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_aggregate_bins: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | my $sth = shift; | |||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | my (%types,$binsize,$binstart); | |||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | while (my ($type,$seqname,$bin,$count,$bins,$start,$end) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | $binsize ||= ($end-$start+1)/$bins; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$binsize ||= ($end - $start + 1) / $bins
MC/DC0%0/2
$binsize ||= ($end - $start + 1) / $bins
$binsize
($end - $start + 1) / $bins
Truth table0%0/3
A ||= B
A= $binsizeB= ($end - $start + 1) / $bins
| |||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | $binstart ||= int($start/$binsize); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$binstart ||= int $start / $binsize
MC/DC0%0/2
$binstart ||= int $start / $binsize
$binstart
int $start / $binsize
Truth table0%0/3
A ||= B
A= $binstartB= int $start / $binsize
| |||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | ▶ | $types{$type}{seqname} ||= $seqname; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$types{$type}{"seqname"} ||= $seqname
MC/DC0%0/2
$types{$type}{"seqname"} ||= $seqname
$types{$type}{"seqname"}
$seqname
Truth table0%0/3
A ||= B
A= $types{$type}{"seqname"}B= $seqname
| |||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | $types{$type}{min} ||= $start; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$types{$type}{"min"} ||= $start
MC/DC0%0/2
$types{$type}{"min"} ||= $start
$types{$type}{"min"}
$start
Truth table0%0/3
A ||= B
A= $types{$type}{"min"}B= $start
| |||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | ▶ | $types{$type}{max} ||= $end; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$types{$type}{"max"} ||= $end
MC/DC0%0/2
$types{$type}{"max"} ||= $end
$types{$type}{"max"}
$end
Truth table0%0/3
A ||= B
A= $types{$type}{"max"}B= $end
| |||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | ▶ | $types{$type}{bins} ||= [(0) x $bins]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$types{$type}{"bins"} ||= [(0) x $bins]
MC/DC0%0/1
$types{$type}{"bins"} ||= [(0) x $bins]
$types{$type}{"bins"}
Truth table0%0/2
A
A= $types{$type}{"bins"}
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | $types{$type}{bins}[$bin-$binstart] = $count; | |||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $types{$type}{count} += $count; | |||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | for my $type (keys %types) { | |||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | my $min = $types{$type}{min}; | |||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | my $max = $types{$type}{max}; | |||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | my $seqid= $types{$type}{seqname}; | |||||||||||||||||||||||||||||||||||||||||
| 921 | my $f = Bio::SeqFeature::Lite->new(-seq_id => $seqid, | ||||||||||||||||||||||||||||||||||||||||||
| 922 | -start => $min, | ||||||||||||||||||||||||||||||||||||||||||
| 923 | -end => $max, | ||||||||||||||||||||||||||||||||||||||||||
| 924 | -type => "$type:bins", | ||||||||||||||||||||||||||||||||||||||||||
| 925 | -score => $types{$type}{count}, | ||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | -attributes => {coverage => join ',',@{$types{$type}{bins}}}); | |||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | push @results,$f; | |||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | return @results; | |||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | ▶ | sub _name_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_name_sql: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | my ($name,$allow_aliases,$join) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | my $name_table = $self->_name_table; | |||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | my $from = "$name_table as n"; | |||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | my ($match,$string) = $self->_match_sql($name); | |||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | my $where = "n.id=$join AND n.name $match"; | |||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | ▶ | $where .= " AND n.display_name>0" unless $allow_aliases; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | return ($from,$where,'',$string); | |||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | ▶ | sub _search_attributes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_search_attributes: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | my ($search_string,$attribute_names,$limit) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | my @words = map {quotemeta($_)} split /\s+/,$search_string; | |||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | my $name_table = $self->_name_table; | |||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | my $attribute_table = $self->_attribute_table; | |||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | my $attributelist_table = $self->_attributelist_table; | |||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | my $type_table = $self->_type_table; | |||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | my $typelist_table = $self->_typelist_table; | |||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | my @tags = @$attribute_names; | |||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | my $tag_sql = join ' OR ',("al.tag=?") x @tags; | |||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | my $perl_regexp = join '|',@words; | |||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | my $sql_regexp = join ' OR ',("a.attribute_value REGEXP ?") x @words; | |||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | my $sql = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 963 | SELECT name,attribute_value,tl.tag,n.id | ||||||||||||||||||||||||||||||||||||||||||
| 964 | FROM $name_table as n,$attribute_table as a,$attributelist_table as al,$type_table as t,$typelist_table as tl | ||||||||||||||||||||||||||||||||||||||||||
| 965 | WHERE n.id=a.id | ||||||||||||||||||||||||||||||||||||||||||
| 966 | AND al.id=a.attribute_id | ||||||||||||||||||||||||||||||||||||||||||
| 967 | AND n.id=t.id | ||||||||||||||||||||||||||||||||||||||||||
| 968 | AND t.typeid=tl.id | ||||||||||||||||||||||||||||||||||||||||||
| 969 | AND n.display_name=1 | ||||||||||||||||||||||||||||||||||||||||||
| 970 | AND ($tag_sql) | ||||||||||||||||||||||||||||||||||||||||||
| 971 | AND ($sql_regexp) | ||||||||||||||||||||||||||||||||||||||||||
| 972 | END | ||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | $sql .= "LIMIT $limit" if defined $limit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | ▶ | $self->_print_query($sql,@tags,@words) if DEBUG || $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | my $sth = $self->_prepare($sql); | |||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | $sth->execute(@tags,@words) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | while (my($name,$value,$type,$id) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | my (@hits) = $value =~ /$perl_regexp/ig; | |||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | my @words_in_row = split /\b/,$value; | |||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | my $score = int(@hits * 10); | |||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | push @results,[$name,$value,$score,$type,$id]; | |||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | @results = sort {$b->[2]<=>$a->[2]} @results; | |||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | return @results; | |||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | sub _match_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match_sql: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my ($match,$string); | |||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | if ($name =~ /(?:^|[^\\])[*?]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | $name =~ s/(^|[^\\])([%_])/$1\\$2/g; | |||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | $name =~ s/(^|[^\\])\*/$1%/g; | |||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | $name =~ s/(^|[^\\])\?/$1_/g; | |||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | $match = "LIKE ?"; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | $string = $name; | |||||||||||||||||||||||||||||||||||||||||
| 1001 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | $match = "= ?"; | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | $string = $name; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | return ($match,$string); | |||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | ▶ | sub _from_table_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_from_table_sql: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | my ($from_table,$join) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | my $from = "$from_table as ft"; | |||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | my $where = "ft.id=$join"; | |||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | return ($from,$where,''); | |||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | ▶ | sub _attributes_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attributes_sql: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | my ($attributes,$join) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | my ($wf,@bind_args) = $self->_make_attribute_where('a','al',$attributes); | |||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | my ($group_by,@group_args)= $self->_make_attribute_group('a',$attributes); | |||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | my $attribute_table = $self->_attribute_table; | |||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | my $attributelist_table = $self->_attributelist_table; | |||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | my $from = "$attribute_table as a use index(attribute_id), $attributelist_table as al"; | |||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | my $where = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1029 | a.id=$join | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | AND a.attribute_id=al.id | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | AND ($wf) | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | my $group = $group_by; | |||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | my @args = (@bind_args,@group_args); | |||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | return ($from,$where,$group,@args); | |||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | sub subfeature_types_are_indexed { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subfeature_types_are_indexed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | ▶ | sub subfeature_locations_are_indexed { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subfeature_locations_are_indexed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | sub _types_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_types_sql: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | my ($types,$type_table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | my ($primary_tag,$source_tag); | |||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | ▶ | my @types = ref $types eq 'ARRAY' ? @$types : $types; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | my $typelist = $self->_typelist_table; | |||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | my $from = "$typelist AS tl"; | |||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my (@matches,@args); | |||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | for my $type (@types) { | |||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | ▶ | if (ref $type && $type->isa('Bio::DB::GFF::Typename')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $type and $type->isa("Bio::DB::GFF::Typename")
MC/DC0%0/2
ref $type and $type->isa("Bio::DB::GFF::Typename")
ref $type
$type->isa("Bio::DB::GFF::Typename")
Truth table0%0/3
A and B
A= ref $typeB= $type->isa("Bio::DB::GFF::Typename")
| |||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | $primary_tag = $type->method; | |||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | $source_tag = $type->source; | |||||||||||||||||||||||||||||||||||||||||
| 1060 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | ($primary_tag,$source_tag) = split ':',$type,2; | |||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | ▶ | if (defined $source_tag && length $source_tag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $source_tag and length $source_tag
MC/DC0%0/2
defined $source_tag and length $source_tag
defined $source_tag
length $source_tag
Truth table0%0/3
A and B
A= defined $source_tagB= length $source_tag
| |||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | if (defined $primary_tag && length($primary_tag)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $primary_tag and length $primary_tag
MC/DC0%0/2
defined $primary_tag and length $primary_tag
defined $primary_tag
length $primary_tag
Truth table0%0/3
A and B
A= defined $primary_tagB= length $primary_tag
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | push @matches,"tl.tag=?"; | |||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | push @args,"$primary_tag:$source_tag"; | |||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | push @matches,"tl.tag LIKE ?"; | |||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | push @args,"%:$source_tag"; | |||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | push @matches,"tl.tag LIKE ?"; | |||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | push @args,"$primary_tag:%"; | |||||||||||||||||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | my $matches = join ' OR ',@matches; | |||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||
| 1080 | 0 | my $where = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1081 | tl.id=$type_table.typeid | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | AND ($matches) | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | return ($from,$where,'',@args); | |||||||||||||||||||||||||||||||||||||||||
| 1086 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | ▶ | sub _location_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_location_sql: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | my ($seq_id,$start,$end,$range_type,$strand,$location) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||
| 1092 | # the additional join on the location_list table badly impacts performance | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | # so we build a copy of the table in memory | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | ▶ | my $seqid = $self->_locationid_nocreate($seq_id) || 0; # zero is an invalid primary ID, so will return empty | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_locationid_nocreate($seq_id) || 0
MC/DC0%0/1
$self->_locationid_nocreate($seq_id) || 0
$self->_locationid_nocreate($seq_id)
Truth table0%0/2
A
A= $self->_locationid_nocreate($seq_id)
| |||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | ▶ | $start = MIN_INT unless defined $start; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | ▶ | $end = MAX_INT unless defined $end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||
| 1099 | 0 | my ($bin_where,@bin_args) = $self->bin_where($start,$end,$location); | |||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | my ($range,@range_args); | |||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | ▶ | if ($range_type eq 'overlaps') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | $range = "$location.end>=? AND $location.start<=? AND ($bin_where)"; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | @range_args = ($start,$end,@bin_args); | |||||||||||||||||||||||||||||||||||||||||
| 1105 | } elsif ($range_type eq 'contains') { | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | $range = "$location.start>=? AND $location.end<=? AND ($bin_where)"; | |||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | @range_args = ($start,$end,@bin_args); | |||||||||||||||||||||||||||||||||||||||||
| 1108 | } elsif ($range_type eq 'contained_in') { | ||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | $range = "$location.start<=? AND $location.end>=?"; | |||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | @range_args = ($start,$end); | |||||||||||||||||||||||||||||||||||||||||
| 1111 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | $self->throw("range_type must be one of 'overlaps', 'contains' or 'contained_in'"); | |||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | ▶ | if (defined $strand) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | $range .= " AND strand=?"; | |||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | push @range_args,$strand; | |||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | my $where = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1121 | $location.seqid=? | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | AND $range | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | my $from = ''; | |||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | my $group = ''; | |||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | my @args = ($seqid,@range_args); | |||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | return ($from,$where,$group,@args); | |||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||
| 1132 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | # force reindexing | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | ▶ | sub reindex { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reindex: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | my $from_update_table = shift; # if present, will take ids from "update_table" | |||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | my $now; | |||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||
| 1143 | # try to bring in highres time() function | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | eval "require Time::HiRes"; | |||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | my $last_time = $self->time(); | |||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||
| 1148 | # tell _delete_index() not to bother removing the index rows corresponding | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | # to each individual feature | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | local $self->{reindexing} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | $self->begin_work; | |||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | my $update = $from_update_table; | |||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | for my $table ($self->index_tables) { | |||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | ▶ | my $query = $from_update_table ? "DELETE $table FROM $table,$update WHERE $table.id=$update.id" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1157 | : "DELETE FROM $table"; | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | $dbh->do($query); | |||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | $self->_disable_keys($dbh,$table); | |||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | my $iterator = $self->get_seq_stream(-from_table=>$from_update_table ? $update : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | ▶ | while (my $f = $iterator->next_seq) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | if (++$count %1000 == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | $now = $self->time(); | |||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | my $elapsed = sprintf(" in %5.2fs",$now - $last_time); | |||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | $last_time = $now; | |||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | print STDERR "$count features indexed$elapsed...",' 'x60; | |||||||||||||||||||||||||||||||||||||||||
| 1168 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | $self->_update_indexes($f); | |||||||||||||||||||||||||||||||||||||||||
| 1171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | for my $table ($self->index_tables) { | |||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | $self->_enable_keys($dbh,$table); | |||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | warn "Couldn't complete transaction: $@"; | |||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | $self->rollback; | |||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1180 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | $self->commit; | |||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | sub optimize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optimize: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | $self->dbh->do("ANALYZE TABLE $_") foreach $self->index_tables; | |||||||||||||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | ▶ | sub all_tables { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_tables: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | my @index_tables = $self->index_tables; | |||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | return ($features,@index_tables); | |||||||||||||||||||||||||||||||||||||||||
| 1196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | ▶ | sub index_tables { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_tables: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | return map {$self->_qualify($_)} qw(name attribute parent2child) | |||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | ▶ | sub _firstid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_firstid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | my $query = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1207 | SELECT min(id) FROM $features | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | my $sth=$self->_prepare($query); | |||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | $sth->execute(); | |||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | my ($first) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | $first; | |||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | ▶ | sub _nextid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_nextid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | my $lastkey = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | my $query = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1221 | SELECT min(id) FROM $features WHERE id>? | ||||||||||||||||||||||||||||||||||||||||||
| 1222 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | my $sth=$self->_prepare($query); | |||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | $sth->execute($lastkey); | |||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | my ($next) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | $next; | |||||||||||||||||||||||||||||||||||||||||
| 1228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | sub _existsid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_existsid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | my $query = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1235 | SELECT count(*) FROM $features WHERE id=? | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | my $sth=$self->_prepare($query); | |||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | $sth->execute($key); | |||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | my ($count) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | $count > 0; | |||||||||||||||||||||||||||||||||||||||||
| 1242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | ▶ | sub _deleteid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deleteid: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | my $parent2child = $self->_parent2child_table; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | my $query = "SELECT child FROM $parent2child WHERE id=?"; | |||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | my $sth=$self->_prepare($query); | |||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | $sth->execute($key); | |||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | my $success = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | ▶ | while (my ($cid) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1254 | # Backcheck looking for multiple parents, delete only if one is present. I'm | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | # sure there is a nice way to left join the parent2child table onto itself | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | # to get this in one query above, just haven't worked it out yet... | ||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | my $sth2 = $self->_prepare("SELECT count(id) FROM $parent2child WHERE child=?"); | |||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | $sth2->execute($cid); | |||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | my ($count) = $sth2->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | ▶ | if ($count == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | ▶ | $self->_deleteid($cid) || warn "An error occurred while removing subfeature id=$cid. Perhaps it was previously deleted?\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | for my $table ($self->all_tables) { | |||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | ▶ | $success += $dbh->do("DELETE FROM $table WHERE id=$key") || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dbh->do("DELETE FROM $table WHERE id=$key") || 0
MC/DC0%0/1
$dbh->do("DELETE FROM $table WHERE id=$key") || 0
$dbh->do("DELETE FROM $table WHERE id=$key")
Truth table0%0/2
A
A= $dbh->do("DELETE FROM $table WHERE id=$key")
| |||||||||||||||||||||||||||||||||||||||||||
| 1266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | return $success; | |||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | ▶ | sub _clearall { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clearall: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | for my $table ($self->all_tables) { | |||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | $dbh->do("DELETE FROM $table"); | |||||||||||||||||||||||||||||||||||||||||
| 1275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | ▶ | sub _featurecount { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_featurecount: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | my $query = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1283 | SELECT count(*) FROM $features | ||||||||||||||||||||||||||||||||||||||||||
| 1284 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | my $sth=$self->_prepare($query); | |||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | $sth->execute(); | |||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | my ($count) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | $count; | |||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | ▶ | sub _seq_ids { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_seq_ids: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1295 | 0 | my $location = $self->_locationlist_table; | |||||||||||||||||||||||||||||||||||||||||
| 1296 | 0 | my $sth = $self->_prepare("SELECT DISTINCT seqname FROM $location"); | |||||||||||||||||||||||||||||||||||||||||
| 1297 | 0 | ▶ | $sth->execute() or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | ▶ | while (my ($id) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | push @result,$id; | |||||||||||||||||||||||||||||||||||||||||
| 1301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | return @result; | |||||||||||||||||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | ▶ | sub setting { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setting: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1306 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1307 | 0 | my ($variable_name,$value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | my $meta = $self->_meta_table; | |||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | ▶ | if (defined $value && $self->writeable) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $self->writeable
MC/DC0%0/2
defined $value and $self->writeable
defined $value
$self->writeable
Truth table0%0/3
A and B
A= defined $valueB= $self->writeable
| |||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | my $query = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1312 | REPLACE INTO $meta (name,value) VALUES (?,?) | ||||||||||||||||||||||||||||||||||||||||||
| 1313 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | my $sth = $self->_prepare($query); | |||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | ▶ | $sth->execute($variable_name,$value) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | $self->{settings_cache}{$variable_name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 1318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | ▶ | return $self->{settings_cache}{$variable_name} if exists $self->{settings_cache}{$variable_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | my $query = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1322 | SELECT value FROM $meta as m WHERE m.name=? | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | my $sth = $self->_prepare($query); | |||||||||||||||||||||||||||||||||||||||||
| 1325 | 0 | ▶ | $sth->execute($variable_name) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1326 | 0 | my ($value) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | return $self->{settings_cache}{$variable_name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 1329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||
| 1332 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1333 | # Replace Bio::SeqFeatureI into database. | ||||||||||||||||||||||||||||||||||||||||||
| 1334 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | ▶ | sub replace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replace: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1337 | 0 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | ▶ | my $index_flag = shift || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || undef
MC/DC0%0/1
shift() || undef
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||
| 1340 | # ?? shouldn't need to do this | ||||||||||||||||||||||||||||||||||||||||||
| 1341 | # $self->_load_class($object); | ||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | my $id = $object->primary_id; | |||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | my $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 1346 | REPLACE INTO $features (id,object,indexed,seqid,start,end,strand,tier,bin,typeid) VALUES (?,?,?,?,?,?,?,?,?,?) | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||
| 1349 | 0 | ▶ | my @location = $index_flag ? $self->_get_location_and_bin($object) : (undef)x6; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | my $primary_tag = $object->primary_tag; | |||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | ▶ | my $source_tag = $object->source_tag || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$object->source_tag || ''
MC/DC0%0/1
$object->source_tag || ''
$object->source_tag
Truth table0%0/2
A
A= $object->source_tag
| |||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | $primary_tag .= ":$source_tag"; | |||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | my $typeid = $self->_typeid($primary_tag,1); | |||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | ▶ | my $frozen = $self->no_blobs() ? 0 : $self->freeze($object); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | ▶ | $sth->execute($id,$frozen,$index_flag||0,@location,$typeid) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$index_flag || 0
MC/DC0%0/1
$index_flag || 0
$index_flag
Truth table0%0/2
A
A= $index_flag
| |||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1361 | 0 | ▶ | $object->primary_id($dbh->{mariadb_insertid}) unless defined $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | ▶ | $self->flag_for_indexing($dbh->{mariadb_insertid}) if $self->{bulk_update_in_progress}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||
| 1366 | # doesn't work with this schema, since we have to update name and attribute | ||||||||||||||||||||||||||||||||||||||||||
| 1367 | # tables which need object ids, which we can only know by replacing feats in | ||||||||||||||||||||||||||||||||||||||||||
| 1368 | # the feature table one by one | ||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | ▶ | sub bulk_replace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bulk_replace: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | ▶ | my $index_flag = shift || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || undef
MC/DC0%0/1
shift() || undef
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | my @objects = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | my @insert_values; | |||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | foreach my $object (@objects) { | |||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | my $id = $object->primary_id; | |||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | ▶ | my @location = $index_flag ? $self->_get_location_and_bin($object) : (undef)x6; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | my $primary_tag = $object->primary_tag; | |||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | ▶ | my $source_tag = $object->source_tag || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$object->source_tag || ''
MC/DC0%0/1
$object->source_tag || ''
$object->source_tag
Truth table0%0/2
A
A= $object->source_tag
| |||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | $primary_tag .= ":$source_tag"; | |||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | my $typeid = $self->_typeid($primary_tag,1); | |||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | ▶ | push(@insert_values, ($id,0,$index_flag||0,@location,$typeid)); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$index_flag || 0
MC/DC0%0/1
$index_flag || 0
$index_flag
Truth table0%0/2
A
A= $index_flag
| |||||||||||||||||||||||||||||||||||||||||||
| 1386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | my @value_blocks; | |||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | for (1..@objects) { | |||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | push(@value_blocks, '(?,?,?,?,?,?,?,?,?,?)'); | |||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | my $value_blocks = join(',', @value_blocks); | |||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | my $sql = qq{REPLACE INTO $features (id,object,indexed,seqid,start,end,strand,tier,bin,typeid) VALUES $value_blocks}; | |||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | my $sth = $self->_prepare($sql); | |||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | ▶ | $sth->execute(@insert_values) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||
| 1399 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | # Insert one Bio::SeqFeatureI into database. primary_id must be undef | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | ▶ | sub insert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | ▶ | my $index_flag = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | $self->_load_class($object); | |||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | ▶ | defined $object->primary_id and $self->throw("$object already has a primary id"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | my $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 1412 | INSERT INTO $features (id,object,indexed) VALUES (?,?,?) | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | ▶ | $sth->execute(undef,$self->freeze($object),$index_flag) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | $object->primary_id($dbh->{mariadb_insertid}); | |||||||||||||||||||||||||||||||||||||||||
| 1417 | 0 | ▶ | $self->flag_for_indexing($dbh->{mariadb_insertid}) if $self->{bulk_update_in_progress}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||
| 1420 | =head2 types | ||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||
| 1422 | Title : types | ||||||||||||||||||||||||||||||||||||||||||
| 1423 | Usage : @type_list = $db->types | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | Function: Get all the types in the database | ||||||||||||||||||||||||||||||||||||||||||
| 1425 | Returns : array of Bio::DB::GFF::Typename objects | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1427 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||
| 1429 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | ▶ | sub types { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
types: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | ▶ | eval "require Bio::DB::GFF::Typename" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1434 | unless Bio::DB::GFF::Typename->can('new'); | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | my $typelist = $self->_typelist_table; | |||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | my $sql = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1437 | SELECT tag from $typelist | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1439 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | ▶ | $self->_print_query($sql) if DEBUG || $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | my $sth = $self->_prepare($sql); | |||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | ▶ | $sth->execute() or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | ▶ | while (my($tag) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | push @results,Bio::DB::GFF::Typename->new($tag); | |||||||||||||||||||||||||||||||||||||||||
| 1447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | return @results; | |||||||||||||||||||||||||||||||||||||||||
| 1450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||
| 1452 | =head2 toplevel_types | ||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||
| 1454 | Title : toplevel_types | ||||||||||||||||||||||||||||||||||||||||||
| 1455 | Usage : @type_list = $db->toplevel_types | ||||||||||||||||||||||||||||||||||||||||||
| 1456 | Function: Get the toplevel types in the database | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | Returns : array of Bio::DB::GFF::Typename objects | ||||||||||||||||||||||||||||||||||||||||||
| 1458 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | Status : public | ||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||
| 1461 | This is similar to types() but only returns the types of | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | INDEXED (toplevel) features. | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||
| 1464 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||
| 1466 | 0 | ▶ | sub toplevel_types { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toplevel_types: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1467 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1468 | 0 | ▶ | eval "require Bio::DB::GFF::Typename" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1469 | unless Bio::DB::GFF::Typename->can('new'); | ||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | my $typelist = $self->_typelist_table; | |||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | my $sql = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1473 | SELECT distinct(tag) from $typelist as tl,$features as f | ||||||||||||||||||||||||||||||||||||||||||
| 1474 | WHERE tl.id=f.typeid | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | AND f.indexed=1 | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1477 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | ▶ | $self->_print_query($sql) if DEBUG || $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | my $sth = $self->_prepare($sql); | |||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | ▶ | $sth->execute() or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||
| 1482 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 1483 | 0 | ▶ | while (my($tag) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | push @results,Bio::DB::GFF::Typename->new($tag); | |||||||||||||||||||||||||||||||||||||||||
| 1485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | return @results; | |||||||||||||||||||||||||||||||||||||||||
| 1488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||
| 1490 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1491 | # Insert a bit of DNA or protein into the database | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | ▶ | sub _insert_sequence { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_insert_sequence: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | my ($seqid,$seq,$offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | my $id = $self->_locationid($seqid); | |||||||||||||||||||||||||||||||||||||||||
| 1497 | 0 | my $sequence = $self->_sequence_table; | |||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | my $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 1499 | REPLACE INTO $sequence (id,offset,sequence) VALUES (?,?,?) | ||||||||||||||||||||||||||||||||||||||||||
| 1500 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1501 | 0 | ▶ | $sth->execute($id,$offset,$seq) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||
| 1504 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1505 | # This subroutine flags the given primary ID for later reindexing | ||||||||||||||||||||||||||||||||||||||||||
| 1506 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1507 | 0 | ▶ | sub flag_for_indexing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flag_for_indexing: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1508 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | my $needs_updating = $self->_update_table; | |||||||||||||||||||||||||||||||||||||||||
| 1511 | 0 | my $sth = $self->_prepare("REPLACE INTO $needs_updating VALUES (?)"); | |||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | ▶ | $sth->execute($id) or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||
| 1515 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1516 | # Update indexes for given object | ||||||||||||||||||||||||||||||||||||||||||
| 1517 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | ▶ | sub _update_indexes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_indexes: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1520 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1521 | 0 | ▶ | defined (my $id = $obj->primary_id) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||
| 1523 | 0 | ▶ | if ($self->{bulk_update_in_progress}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1524 | 0 | $self->_dump_update_name_index($obj,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1525 | 0 | $self->_dump_update_attribute_index($obj,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1526 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | 0 | $self->_update_name_index($obj,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1528 | 0 | $self->_update_attribute_index($obj,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||||||||||
| 1532 | 0 | ▶ | sub _update_name_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_name_index: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | my ($obj,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | my $name = $self->_name_table; | |||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | my $primary_id = $obj->primary_id; | |||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | $self->_delete_index($name,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1539 | 0 | my ($names,$aliases) = $self->feature_names($obj); | |||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | my $sth = $self->_prepare("INSERT INTO $name (id,name,display_name) VALUES (?,?,?)"); | |||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | ▶ | $sth->execute($id,$_,1) or $self->throw($sth->errstr) foreach @$names; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | ▶ | $sth->execute($id,$_,0) or $self->throw($sth->errstr) foreach @$aliases; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1545 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | ▶ | sub _update_attribute_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_attribute_index: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1550 | 0 | my ($obj,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1551 | 0 | my $attribute = $self->_attribute_table; | |||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | $self->_delete_index($attribute,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | my $sth = $self->_prepare("INSERT INTO $attribute (id,attribute_id,attribute_value) VALUES (?,?,?)"); | |||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | for my $tag ($obj->get_all_tags) { | |||||||||||||||||||||||||||||||||||||||||
| 1556 | 0 | my $tagid = $self->_attributeid($tag); | |||||||||||||||||||||||||||||||||||||||||
| 1557 | 0 | for my $value ($obj->get_tag_values($tag)) { | |||||||||||||||||||||||||||||||||||||||||
| 1558 | 0 | ▶ | $sth->execute($id,$tagid,$value) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||
| 1564 | 0 | ▶ | sub _genericid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_genericid: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | my ($table,$namefield,$name,$add_if_missing) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1567 | 0 | my $qualified_table = $self->_qualify($table); | |||||||||||||||||||||||||||||||||||||||||
| 1568 | 0 | my $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 1569 | SELECT id FROM $qualified_table WHERE $namefield=? | ||||||||||||||||||||||||||||||||||||||||||
| 1570 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | ▶ | $sth->execute($name) or die $sth->errstr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | my ($id) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1574 | 0 | ▶ | return $id if defined $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1575 | 0 | ▶ | return unless $add_if_missing; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 1578 | INSERT INTO $qualified_table ($namefield) VALUES (?) | ||||||||||||||||||||||||||||||||||||||||||
| 1579 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1580 | 0 | ▶ | $sth->execute($name) or die $sth->errstr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1581 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1582 | 0 | return $dbh->{mariadb_insertid}; | |||||||||||||||||||||||||||||||||||||||||
| 1583 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||
| 1585 | 0 | ▶ | sub _typeid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_typeid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1586 | 0 | shift->_genericid('typelist','tag',shift,1); | |||||||||||||||||||||||||||||||||||||||||
| 1587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1588 | 0 | ▶ | sub _locationid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_locationid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1589 | 0 | shift->_genericid('locationlist','seqname',shift,1); | |||||||||||||||||||||||||||||||||||||||||
| 1590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | ▶ | sub _locationid_nocreate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_locationid_nocreate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | shift->_genericid('locationlist','seqname',shift,0); | |||||||||||||||||||||||||||||||||||||||||
| 1593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | 0 | ▶ | sub _attributeid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attributeid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | shift->_genericid('attributelist','tag',shift,1); | |||||||||||||||||||||||||||||||||||||||||
| 1596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | ▶ | sub _get_location_and_bin { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_location_and_bin: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | my $feature = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | ▶ | my $seqid = $self->_locationid($feature->seq_id||''); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->seq_id || ''
MC/DC0%0/1
$feature->seq_id || ''
$feature->seq_id
Truth table0%0/2
A
A= $feature->seq_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | my $start = $feature->start; | |||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | my $end = $feature->end; | |||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | ▶ | my $strand = $feature->strand || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->strand || 0
MC/DC0%0/1
$feature->strand || 0
$feature->strand
Truth table0%0/2
A
A= $feature->strand
| |||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | my ($tier,$bin) = $self->get_bin($start,$end); | |||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | return ($seqid,$start,$end,$strand,$tier,$bin); | |||||||||||||||||||||||||||||||||||||||||
| 1607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||
| 1609 | 0 | ▶ | sub get_bin { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_bin: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1610 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1611 | 0 | my ($start,$end) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1612 | 0 | my $binsize = MIN_BIN; | |||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | my ($bin_start,$bin_end,$tier); | |||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | $tier = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | $bin_start = int $start/$binsize; | |||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | $bin_end = int $end/$binsize; | |||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | ▶ | last if $bin_start == $bin_end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | $binsize *= 10; | |||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | $tier++; | |||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | return ($tier,$bin_start); | |||||||||||||||||||||||||||||||||||||||||
| 1623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||||||||||||
| 1625 | 0 | ▶ | sub bin_where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bin_where: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1626 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1627 | 0 | my ($start,$end,$f) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1628 | 0 | my (@bins,@args); | |||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||
| 1630 | 0 | my $tier = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1631 | 0 | my $binsize = MIN_BIN; | |||||||||||||||||||||||||||||||||||||||||
| 1632 | 0 | ▶ | while ($binsize <= MAX_BIN) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1633 | 0 | my $bin_start = int($start/$binsize); | |||||||||||||||||||||||||||||||||||||||||
| 1634 | 0 | my $bin_end = int($end/$binsize); | |||||||||||||||||||||||||||||||||||||||||
| 1635 | 0 | push @bins,"($f.tier=? AND $f.bin between ? AND ?)"; | |||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | push @args,($tier,$bin_start,$bin_end); | |||||||||||||||||||||||||||||||||||||||||
| 1637 | 0 | $binsize *= 10; | |||||||||||||||||||||||||||||||||||||||||
| 1638 | 0 | $tier++; | |||||||||||||||||||||||||||||||||||||||||
| 1639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1640 | 0 | my $query = join ("\n\t OR ",@bins); | |||||||||||||||||||||||||||||||||||||||||
| 1641 | 0 | ▶ | return wantarray ? ($query,@args) : substitute($query,@args); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1643 | |||||||||||||||||||||||||||||||||||||||||||
| 1644 | 0 | ▶ | sub _delete_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_delete_index: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | my ($table_name,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | ▶ | return if $self->{reindexing}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | ▶ | my $sth = $self->_prepare("DELETE FROM $table_name WHERE id=?") or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | $sth->execute($id); | |||||||||||||||||||||||||||||||||||||||||
| 1650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||||||||||||||||
| 1652 | # given a statement handler that is expected to return rows of (id,object) | ||||||||||||||||||||||||||||||||||||||||||
| 1653 | # unthaw each object and return a list of 'em | ||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | ▶ | sub _sth2objs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sth2objs: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | my $sth = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | ▶ | while (my ($id,$o,$typeid,$seqid,$start,$end,$strand) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | my $obj; | |||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | ▶ | if ($o eq '0') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1661 | # rebuild a new feat object from the data stored in the db | ||||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | $obj = $self->_rebuild_obj($id,$typeid,$seqid,$start,$end,$strand); | |||||||||||||||||||||||||||||||||||||||||
| 1663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1664 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | $obj = $self->thaw($o,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1666 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | push @result,$obj; | |||||||||||||||||||||||||||||||||||||||||
| 1669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1670 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | return @result; | |||||||||||||||||||||||||||||||||||||||||
| 1672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||||||||||||||||
| 1674 | # given a statement handler that is expected to return rows of (id,object) | ||||||||||||||||||||||||||||||||||||||||||
| 1675 | # unthaw each object and return a list of 'em | ||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | ▶ | sub _sth2obj { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sth2obj: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | my $sth = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | my ($id,$o,$typeid,$seqid,$start,$end,$strand) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | ▶ | return unless defined $o; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | my $obj; | |||||||||||||||||||||||||||||||||||||||||
| 1682 | 0 | ▶ | if ($o eq '0') { # I don't understand why an object ever needs to be rebuilt! | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1683 | # rebuild a new feat object from the data stored in the db | ||||||||||||||||||||||||||||||||||||||||||
| 1684 | 0 | $obj = $self->_rebuild_obj($id,$typeid,$seqid,$start,$end,$strand); | |||||||||||||||||||||||||||||||||||||||||
| 1685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1686 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | $obj = $self->thaw($o,$id); | |||||||||||||||||||||||||||||||||||||||||
| 1688 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1689 | |||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | $obj; | |||||||||||||||||||||||||||||||||||||||||
| 1691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | ▶ | sub _rebuild_obj { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rebuild_obj: not called CC=31 SCAR=69.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | my ($self, $id, $typeid, $db_seqid, $start, $end, $strand) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | my ($type, $source, $seqid); | |||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||
| 1697 | # convert typeid to type and source | ||||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | ▶ | if (exists $self->{_type_cache}->{$typeid}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | ($type, $source) = @{$self->{_type_cache}->{$typeid}}; | |||||||||||||||||||||||||||||||||||||||||
| 1700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1701 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | my $sql = qq{ SELECT `tag` FROM typelist WHERE `id` = ? }; | |||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | ▶ | my $sth = $self->_prepare($sql) or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | $sth->execute($typeid); | |||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 1706 | 0 | $sth->bind_columns(\$result); | |||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | ▶ | while ($sth->fetch()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1708 | # there should be only one row returned, but we ensure to get all rows | ||||||||||||||||||||||||||||||||||||||||||
| 1709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | ($type, $source) = split(':', $result); | |||||||||||||||||||||||||||||||||||||||||
| 1712 | 0 | $self->{_type_cache}->{$typeid} = [$type, $source]; | |||||||||||||||||||||||||||||||||||||||||
| 1713 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||
| 1715 | # convert the db seqid to the sequence name | ||||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | ▶ | if (exists $self->{_seqid_cache}->{$db_seqid}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1717 | 0 | $seqid = $self->{_seqid_cache}->{$db_seqid}; | |||||||||||||||||||||||||||||||||||||||||
| 1718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1719 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | my $sql = qq{ SELECT `seqname` FROM locationlist WHERE `id` = ? }; | |||||||||||||||||||||||||||||||||||||||||
| 1721 | 0 | ▶ | my $sth = $self->_prepare($sql) or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1722 | 0 | $sth->execute($db_seqid); | |||||||||||||||||||||||||||||||||||||||||
| 1723 | 0 | $sth->bind_columns(\$seqid); | |||||||||||||||||||||||||||||||||||||||||
| 1724 | 0 | ▶ | while ($sth->fetch()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1725 | # there should be only one row returned, but we ensure to get all rows | ||||||||||||||||||||||||||||||||||||||||||
| 1726 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | $self->{_seqid_cache}->{$db_seqid} = $seqid; | |||||||||||||||||||||||||||||||||||||||||
| 1729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||||||||||||||||
| 1731 | # get the names from name table? | ||||||||||||||||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||||||||||||||||
| 1733 | # get the attributes and store those in obj | ||||||||||||||||||||||||||||||||||||||||||
| 1734 | 0 | my $sql = qq{ SELECT attribute_id,attribute_value FROM attribute WHERE `id` = ? }; | |||||||||||||||||||||||||||||||||||||||||
| 1735 | 0 | ▶ | my $sth = $self->_prepare($sql) or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | $sth->execute($id); | |||||||||||||||||||||||||||||||||||||||||
| 1737 | 0 | my ($attribute_id, $attribute_value); | |||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | $sth->bind_columns(\($attribute_id, $attribute_value)); | |||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | my %attribs; | |||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | ▶ | while ($sth->fetch()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1741 | # convert the attribute_id to its real name | ||||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | my $attribute; | |||||||||||||||||||||||||||||||||||||||||
| 1743 | 0 | ▶ | if (exists $self->{_attribute_cache}->{$attribute_id}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1744 | 0 | $attribute = $self->{_attribute_cache}->{$attribute_id}; | |||||||||||||||||||||||||||||||||||||||||
| 1745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1746 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1747 | 0 | my $sql = qq{ SELECT `tag` FROM attributelist WHERE `id` = ? }; | |||||||||||||||||||||||||||||||||||||||||
| 1748 | 0 | ▶ | my $sth2 = $self->_prepare($sql) or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1749 | 0 | $sth2->execute($attribute_id); | |||||||||||||||||||||||||||||||||||||||||
| 1750 | 0 | $sth2->bind_columns(\$attribute); | |||||||||||||||||||||||||||||||||||||||||
| 1751 | 0 | ▶ | while ($sth2->fetch()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1752 | # there should be only one row returned, but we ensure to get all rows | ||||||||||||||||||||||||||||||||||||||||||
| 1753 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1754 | |||||||||||||||||||||||||||||||||||||||||||
| 1755 | 0 | $self->{_attribute_cache}->{$attribute_id} = $attribute; | |||||||||||||||||||||||||||||||||||||||||
| 1756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | ▶ | if ($source && $attribute eq 'source' && $attribute_value eq $source) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$source and $attribute eq "source" and $attribute_value eq $source
$source and $attribute eq "source"
MC/DC0%0/3
$source and $attribute eq "source" and $attribute_value eq $source
$source
$attribute eq "source"
$attribute_value eq $source
Truth table0%0/4
A and B and C
A= $sourceB= $attribute eq "source"C= $attribute_value eq $source
| |||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | $attribs{$attribute} = $attribute_value; | |||||||||||||||||||||||||||||||||||||||||
| 1763 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1764 | |||||||||||||||||||||||||||||||||||||||||||
| 1765 | # if we weren't called with all the params, pull those out of the database too | ||||||||||||||||||||||||||||||||||||||||||
| 1766 | 0 | ▶ | if ( not ( grep { defined($_) } ( $typeid, $db_seqid, $start, $end, $strand ))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1767 | 0 | my $sql = qq{ SELECT start,end,tag,strand,seqname | |||||||||||||||||||||||||||||||||||||||||
| 1768 | FROM feature,feature_location,typelist,locationlist | ||||||||||||||||||||||||||||||||||||||||||
| 1769 | WHERE feature.id=feature_location.id AND feature.typeid=typelist.id | ||||||||||||||||||||||||||||||||||||||||||
| 1770 | AND seqid=locationlist.id AND feature.id = ? }; | ||||||||||||||||||||||||||||||||||||||||||
| 1771 | 0 | ▶ | my $sth = $self->_prepare($sql) or $self->throw($self->dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | $sth->execute($id); | |||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | my ($feature_start, $feature_end, $feature_type, $feature_strand,$feature_seqname); | |||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | $sth->bind_columns(\($feature_start, $feature_end, $feature_type, $feature_strand, $feature_seqname)); | |||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | ▶ | while ($sth->fetch()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1776 | # there should be only one row returned, but we call like this to | ||||||||||||||||||||||||||||||||||||||||||
| 1777 | # ensure we get all rows | ||||||||||||||||||||||||||||||||||||||||||
| 1778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1779 | 0 | ▶ | $start ||= $feature_start; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$start ||= $feature_start
MC/DC0%0/2
$start ||= $feature_start
$start
$feature_start
Truth table0%0/3
A ||= B
A= $startB= $feature_start
| |||||||||||||||||||||||||||||||||||||||||||
| 1780 | 0 | ▶ | $end ||= $feature_end; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$end ||= $feature_end
MC/DC0%0/2
$end ||= $feature_end
$end
$feature_end
Truth table0%0/3
A ||= B
A= $endB= $feature_end
| |||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | ▶ | $strand ||= $feature_strand; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$strand ||= $feature_strand
MC/DC0%0/2
$strand ||= $feature_strand
$strand
$feature_strand
Truth table0%0/3
A ||= B
A= $strandB= $feature_strand
| |||||||||||||||||||||||||||||||||||||||||||
| 1782 | 0 | ▶ | $seqid ||= $feature_seqname; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$seqid ||= $feature_seqname
MC/DC0%0/2
$seqid ||= $feature_seqname
$seqid
$feature_seqname
Truth table0%0/3
A ||= B
A= $seqidB= $feature_seqname
| |||||||||||||||||||||||||||||||||||||||||||
| 1783 | |||||||||||||||||||||||||||||||||||||||||||
| 1784 | 0 | my( $feature_typename , $feature_typesource ) = split /:/ , $feature_type; | |||||||||||||||||||||||||||||||||||||||||
| 1785 | 0 | ▶ | $type ||= $feature_typename; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$type ||= $feature_typename
MC/DC0%0/2
$type ||= $feature_typename
$type
$feature_typename
Truth table0%0/3
A ||= B
A= $typeB= $feature_typename
| |||||||||||||||||||||||||||||||||||||||||||
| 1786 | 0 | ▶ | $source ||= $feature_typesource; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$source ||= $feature_typesource
MC/DC0%0/2
$source ||= $feature_typesource
$source
$feature_typesource
Truth table0%0/3
A ||= B
A= $sourceB= $feature_typesource
| |||||||||||||||||||||||||||||||||||||||||||
| 1787 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||||||||||||||||
| 1789 | 0 | ▶ | my $obj = Bio::SeqFeature::Lite->new(-primary_id => $id, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1790 | $type ? (-type => $type) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 1791 | $source ? (-source => $source) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | $seqid ? (-seq_id => $seqid) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 1793 | defined $start ? (-start => $start) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 1794 | defined $end ? (-end => $end) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 1795 | defined $strand ? (-strand => $strand) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 1796 | keys %attribs ? (-attributes => \%attribs) : ()); | ||||||||||||||||||||||||||||||||||||||||||
| 1797 | |||||||||||||||||||||||||||||||||||||||||||
| 1798 | 0 | return $obj; | |||||||||||||||||||||||||||||||||||||||||
| 1799 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | ▶ | sub _prepare { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1802 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | my $query = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | ▶ | my $sth = $dbh->prepare_cached($query, {}, 3) or $self->throw($dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | $sth; | |||||||||||||||||||||||||||||||||||||||||
| 1807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||||||||||||||||
| 1810 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 1811 | # SQL Fragment generators | ||||||||||||||||||||||||||||||||||||||||||
| 1812 | #################################################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||
| 1814 | 0 | ▶ | sub _attribute_table { shift->_qualify('attribute') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attribute_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1815 | 0 | ▶ | sub _attributelist_table { shift->_qualify('attributelist') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attributelist_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | ▶ | sub _feature_table { shift->_qualify('feature') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_feature_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1817 | 0 | ▶ | sub _interval_stats_table { shift->_qualify('interval_stats') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_interval_stats_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1818 | 0 | ▶ | sub _location_table { shift->_qualify('location') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_location_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1819 | 0 | ▶ | sub _locationlist_table { shift->_qualify('locationlist') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_locationlist_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1820 | 0 | ▶ | sub _meta_table { shift->_qualify('meta') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_meta_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | ▶ | sub _name_table { shift->_qualify('name') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_name_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | ▶ | sub _parent2child_table { shift->_qualify('parent2child') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parent2child_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | ▶ | sub _sequence_table { shift->_qualify('sequence') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sequence_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | ▶ | sub _type_table { shift->_qualify('feature') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_type_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1825 | 0 | ▶ | sub _typelist_table { shift->_qualify('typelist') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_typelist_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | ▶ | sub _update_table { shift->_qualify('update_table') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1827 | |||||||||||||||||||||||||||||||||||||||||||
| 1828 | 0 | ▶ | sub _make_attribute_where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_attribute_where: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 1829 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1830 | 0 | my ($attributetable,$attributenametable,$attributes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||
| 1832 | my @sql; | ||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | foreach (keys %$attributes) { | |||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | my @match_values; | |||||||||||||||||||||||||||||||||||||||||
| 1836 | 0 | ▶ | my @values = ref($attributes->{$_}) && ref($attributes->{$_}) eq 'ARRAY' ? @{$attributes->{$_}} : $attributes->{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $attributes->{$_} and ref $attributes->{$_} eq "ARRAY"
MC/DC0%0/2
ref $attributes->{$_} and ref $attributes->{$_} eq "ARRAY"
ref $attributes->{$_}
ref $attributes->{$_} eq "ARRAY"
Truth table0%0/3
A and B
A= ref $attributes->{$_}B= ref $attributes->{$_} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | foreach (@values) { # convert * into % for wildcard matches | |||||||||||||||||||||||||||||||||||||||||
| 1838 | 0 | s/\*/%/g; | |||||||||||||||||||||||||||||||||||||||||
| 1839 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1840 | my $match = join ' OR ',map { | ||||||||||||||||||||||||||||||||||||||||||
| 1841 | 0 | ▶ | /%/ ? "$attributetable.attribute_value LIKE ?" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1842 | : "$attributetable.attribute_value=?" | ||||||||||||||||||||||||||||||||||||||||||
| 1843 | } @values; | ||||||||||||||||||||||||||||||||||||||||||
| 1844 | 0 | push @sql,"($attributenametable.tag=? AND ($match))"; | |||||||||||||||||||||||||||||||||||||||||
| 1845 | 0 | push @args,($_,@values); | |||||||||||||||||||||||||||||||||||||||||
| 1846 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1847 | 0 | return (join(' OR ',@sql),@args); | |||||||||||||||||||||||||||||||||||||||||
| 1848 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||
| 1850 | 0 | ▶ | sub _make_attribute_group { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_attribute_group: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1851 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1852 | 0 | my ($table_name,$attributes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1853 | 0 | ▶ | my $key_count = keys %$attributes or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1854 | 0 | return "f.id,f.object,f.typeid,f.seqid,f.start,f.end,f.strand HAVING count(f.id)>?",$key_count-1; | |||||||||||||||||||||||||||||||||||||||||
| 1855 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||||||||||
| 1857 | 0 | ▶ | sub _print_query { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_print_query: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1858 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1859 | 0 | my ($query,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1860 | 0 | ▶ | while ($query =~ /\?/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1861 | 0 | my $arg = $self->dbh->quote(shift @args); | |||||||||||||||||||||||||||||||||||||||||
| 1862 | 0 | $query =~ s/\?/$arg/; | |||||||||||||||||||||||||||||||||||||||||
| 1863 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1864 | 0 | warn $query,"\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1865 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||
| 1867 | ### | ||||||||||||||||||||||||||||||||||||||||||
| 1868 | # special-purpose store for bulk loading - write to a file rather than to the db | ||||||||||||||||||||||||||||||||||||||||||
| 1869 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1870 | 0 | ▶ | sub _dump_store { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dump_store: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1871 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1872 | 0 | my $indexed = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1875 | 0 | my $store_fh = $self->dump_filehandle('feature'); | |||||||||||||||||||||||||||||||||||||||||
| 1876 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||||||||||||||||
| 1878 | 0 | my $autoindex = $self->autoindex; | |||||||||||||||||||||||||||||||||||||||||
| 1879 | |||||||||||||||||||||||||||||||||||||||||||
| 1880 | 0 | for my $obj (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 1881 | 0 | my $id = $self->next_id; | |||||||||||||||||||||||||||||||||||||||||
| 1882 | 0 | ▶ | my ($seqid,$start,$end,$strand,$tier,$bin) = $indexed ? $self->_get_location_and_bin($obj) : (undef)x6; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1883 | 0 | my $primary_tag = $obj->primary_tag; | |||||||||||||||||||||||||||||||||||||||||
| 1884 | 0 | ▶ | my $source_tag = $obj->source_tag || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$obj->source_tag || ''
MC/DC0%0/1
$obj->source_tag || ''
$obj->source_tag
Truth table0%0/2
A
A= $obj->source_tag
| |||||||||||||||||||||||||||||||||||||||||||
| 1885 | 0 | $primary_tag .= ":$source_tag"; | |||||||||||||||||||||||||||||||||||||||||
| 1886 | 0 | my $typeid = $self->_typeid($primary_tag,1); | |||||||||||||||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||||||||||||||||
| 1888 | 0 | print $store_fh join("\t",$id,$typeid,$seqid,$start,$end,$strand,$tier,$bin,$indexed,$dbh->quote($self->freeze($obj))),"\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1889 | 0 | $obj->primary_id($id); | |||||||||||||||||||||||||||||||||||||||||
| 1890 | 0 | ▶ | $self->_update_indexes($obj) if $indexed && $autoindex; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$indexed and $autoindex
MC/DC0%0/2
$indexed and $autoindex
$indexed
$autoindex
Truth table0%0/3
A and B
A= $indexedB= $autoindex
| |||||||||||||||||||||||||||||||||||||||||||
| 1891 | 0 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 1892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||
| 1894 | # remember whether we are have ever stored a non-indexed feature | ||||||||||||||||||||||||||||||||||||||||||
| 1895 | 0 | ▶ | unless ($indexed or $self->{indexed_flag}++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$indexed or $self->{"indexed_flag"}++
MC/DC0%0/2
$indexed or $self->{"indexed_flag"}++
$indexed
$self->{"indexed_flag"}++
Truth table0%0/3
A or B
A= $indexedB= $self->{"indexed_flag"}++
| |||||||||||||||||||||||||||||||||||||||||||
| 1896 | 0 | $self->subfeatures_are_indexed(0); | |||||||||||||||||||||||||||||||||||||||||
| 1897 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1898 | 0 | $count; | |||||||||||||||||||||||||||||||||||||||||
| 1899 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1900 | |||||||||||||||||||||||||||||||||||||||||||
| 1901 | 0 | ▶ | sub _dump_add_SeqFeature { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dump_add_SeqFeature: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1902 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1903 | 0 | my $parent = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1904 | 0 | my @children = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||
| 1906 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1907 | 0 | my $fh = $self->dump_filehandle('parent2child'); | |||||||||||||||||||||||||||||||||||||||||
| 1908 | 0 | ▶ | my $parent_id = (ref $parent ? $parent->primary_id : $parent) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1909 | or $self->throw("$parent should have a primary_id"); | ||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1911 | |||||||||||||||||||||||||||||||||||||||||||
| 1912 | 0 | for my $child_id (@children) { | |||||||||||||||||||||||||||||||||||||||||
| 1913 | 0 | print $fh join("\t",$parent_id,$child_id),"\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 1915 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1916 | 0 | $count; | |||||||||||||||||||||||||||||||||||||||||
| 1917 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||||||||||||||||
| 1919 | 0 | ▶ | sub _dump_update_name_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dump_update_name_index: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1920 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1921 | 0 | my ($obj,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1922 | 0 | my $fh = $self->dump_filehandle('name'); | |||||||||||||||||||||||||||||||||||||||||
| 1923 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1924 | 0 | my ($names,$aliases) = $self->feature_names($obj); | |||||||||||||||||||||||||||||||||||||||||
| 1925 | 0 | print $fh join("\t",$id,$dbh->quote($_),1),"\n" foreach @$names; | |||||||||||||||||||||||||||||||||||||||||
| 1926 | 0 | print $fh join("\t",$id,$dbh->quote($_),0),"\n" foreach @$aliases; | |||||||||||||||||||||||||||||||||||||||||
| 1927 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1928 | |||||||||||||||||||||||||||||||||||||||||||
| 1929 | 0 | ▶ | sub _dump_update_attribute_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dump_update_attribute_index: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1930 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1931 | 0 | my ($obj,$id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1932 | 0 | my $fh = $self->dump_filehandle('attribute'); | |||||||||||||||||||||||||||||||||||||||||
| 1933 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 1934 | 0 | for my $tag ($obj->all_tags) { | |||||||||||||||||||||||||||||||||||||||||
| 1935 | 0 | my $tagid = $self->_attributeid($tag); | |||||||||||||||||||||||||||||||||||||||||
| 1936 | 0 | for my $value ($obj->each_tag_value($tag)) { | |||||||||||||||||||||||||||||||||||||||||
| 1937 | 0 | print $fh join("\t",$id,$tagid,$dbh->quote($value)),"\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1938 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1939 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1940 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1941 | |||||||||||||||||||||||||||||||||||||||||||
| 1942 | 0 | ▶ | sub coverage_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coverage_array: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1943 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1944 | 0 | my ($seq_name,$start,$end,$types,$bins) = | |||||||||||||||||||||||||||||||||||||||||
| 1945 | rearrange([['SEQID','SEQ_ID','REF'],'START',['STOP','END'], | ||||||||||||||||||||||||||||||||||||||||||
| 1946 | ['TYPES','TYPE','PRIMARY_TAG'],'BINS'],@_); | ||||||||||||||||||||||||||||||||||||||||||
| 1947 | |||||||||||||||||||||||||||||||||||||||||||
| 1948 | 0 | ▶ | $bins ||= 1000; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$bins ||= 1000
MC/DC0%0/1
$bins ||= 1000
$bins
Truth table0%0/2
A
A= $bins
| |||||||||||||||||||||||||||||||||||||||||||
| 1949 | 0 | ▶ | $start ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$start ||= 1
MC/DC0%0/1
$start ||= 1
$start
Truth table0%0/2
A
A= $start
| |||||||||||||||||||||||||||||||||||||||||||
| 1950 | 0 | ▶ | unless ($end) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1951 | 0 | ▶ | my $segment = $self->segment($seq_name) or $self->throw("unknown seq_id $seq_name"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1952 | 0 | $end = $segment->end; | |||||||||||||||||||||||||||||||||||||||||
| 1953 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1954 | |||||||||||||||||||||||||||||||||||||||||||
| 1955 | 0 | my $binsize = ($end-$start+1)/$bins; | |||||||||||||||||||||||||||||||||||||||||
| 1956 | 0 | ▶ | my $seqid = $self->_locationid_nocreate($seq_name) || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_locationid_nocreate($seq_name) || 0
MC/DC0%0/1
$self->_locationid_nocreate($seq_name) || 0
$self->_locationid_nocreate($seq_name)
Truth table0%0/2
A
A= $self->_locationid_nocreate($seq_name)
| |||||||||||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||||||||||
| 1958 | 0 | ▶ | return [] unless $seqid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||
| 1960 | # where each bin starts | ||||||||||||||||||||||||||||||||||||||||||
| 1961 | 0 | my @his_bin_array = map {$start + $binsize * $_} (0..$bins-1); | |||||||||||||||||||||||||||||||||||||||||
| 1962 | 0 | my @sum_bin_array = map {int(($_-1)/SUMMARY_BIN_SIZE)} @his_bin_array; | |||||||||||||||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||||||||||||||||
| 1964 | 0 | my $interval_stats = $self->_interval_stats_table; | |||||||||||||||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||||||||||||||||
| 1966 | 0 | my ($sth,@a); | |||||||||||||||||||||||||||||||||||||||||
| 1967 | 0 | ▶ | if ($types) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1968 | # pick up the type ids | ||||||||||||||||||||||||||||||||||||||||||
| 1969 | 0 | my ($from,$where,$group); | |||||||||||||||||||||||||||||||||||||||||
| 1970 | 0 | ($from,$where,$group,@a) = $self->_types_sql($types,'b'); | |||||||||||||||||||||||||||||||||||||||||
| 1971 | 0 | $where =~ s/.+AND//s; | |||||||||||||||||||||||||||||||||||||||||
| 1972 | 0 | $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 1973 | SELECT id,tag FROM $from | ||||||||||||||||||||||||||||||||||||||||||
| 1974 | WHERE $where | ||||||||||||||||||||||||||||||||||||||||||
| 1975 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1976 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 1977 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1978 | 0 | $sth = $self->_prepare(<<END); | |||||||||||||||||||||||||||||||||||||||||
| 1979 | SELECT id,tag FROM typelist | ||||||||||||||||||||||||||||||||||||||||||
| 1980 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1981 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1982 | 0 | my (@t,$report_tag); | |||||||||||||||||||||||||||||||||||||||||
| 1983 | 0 | $sth->execute(@a); | |||||||||||||||||||||||||||||||||||||||||
| 1984 | 0 | ▶ | while (my ($t,$tag) = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1985 | 0 | ▶ | $report_tag ||= $tag; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$report_tag ||= $tag
MC/DC0%0/2
$report_tag ||= $tag
$report_tag
$tag
Truth table0%0/3
A ||= B
A= $report_tagB= $tag
| |||||||||||||||||||||||||||||||||||||||||||
| 1986 | 0 | push @t,$t; | |||||||||||||||||||||||||||||||||||||||||
| 1987 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1988 | |||||||||||||||||||||||||||||||||||||||||||
| 1989 | 0 | my %bins; | |||||||||||||||||||||||||||||||||||||||||
| 1990 | 0 | my $sql = <<END; | |||||||||||||||||||||||||||||||||||||||||
| 1991 | SELECT bin,cum_count | ||||||||||||||||||||||||||||||||||||||||||
| 1992 | FROM $interval_stats | ||||||||||||||||||||||||||||||||||||||||||
| 1993 | WHERE typeid=? | ||||||||||||||||||||||||||||||||||||||||||
| 1994 | AND seqid=? AND bin >= ? | ||||||||||||||||||||||||||||||||||||||||||
| 1995 | LIMIT 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1996 | END | ||||||||||||||||||||||||||||||||||||||||||
| 1997 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 1998 | 0 | $sth = $self->_prepare($sql); | |||||||||||||||||||||||||||||||||||||||||
| 1999 | |||||||||||||||||||||||||||||||||||||||||||
| 2000 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 2001 | 0 | for my $typeid (@t) { | |||||||||||||||||||||||||||||||||||||||||
| 2002 | |||||||||||||||||||||||||||||||||||||||||||
| 2003 | 0 | ▶ | for (my $i=0;$i<@sum_bin_array;$i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2004 | |||||||||||||||||||||||||||||||||||||||||||
| 2005 | 0 | my @args = ($typeid,$seqid,$sum_bin_array[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 2006 | 0 | ▶ | $self->_print_query($sql,@args) if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2007 | |||||||||||||||||||||||||||||||||||||||||||
| 2008 | 0 | ▶ | $sth->execute(@args) or $self->throw($sth->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2009 | 0 | my ($bin,$cum_count) = $sth->fetchrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 2010 | 0 | push @{$bins{$typeid}},[$bin,$cum_count]; | |||||||||||||||||||||||||||||||||||||||||
| 2011 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2012 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2013 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 2014 | 0 | ▶ | return unless %bins; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2015 | |||||||||||||||||||||||||||||||||||||||||||
| 2016 | 0 | my @merged_bins; | |||||||||||||||||||||||||||||||||||||||||
| 2017 | 0 | my $firstbin = int(($start-1)/$binsize); | |||||||||||||||||||||||||||||||||||||||||
| 2018 | 0 | for my $type (keys %bins) { | |||||||||||||||||||||||||||||||||||||||||
| 2019 | 0 | my $arry = $bins{$type}; | |||||||||||||||||||||||||||||||||||||||||
| 2020 | 0 | my $last_count = $arry->[0][1]; | |||||||||||||||||||||||||||||||||||||||||
| 2021 | 0 | my $last_bin = -1; | |||||||||||||||||||||||||||||||||||||||||
| 2022 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2023 | 0 | my $delta; | |||||||||||||||||||||||||||||||||||||||||
| 2024 | 0 | for my $b (@$arry) { | |||||||||||||||||||||||||||||||||||||||||
| 2025 | 0 | my ($bin,$count) = @$b; | |||||||||||||||||||||||||||||||||||||||||
| 2026 | 0 | ▶ | $delta = $count - $last_count if $bin > $last_bin; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2027 | 0 | $merged_bins[$i++] += $delta; | |||||||||||||||||||||||||||||||||||||||||
| 2028 | 0 | $last_count = $count; | |||||||||||||||||||||||||||||||||||||||||
| 2029 | 0 | $last_bin = $bin; | |||||||||||||||||||||||||||||||||||||||||
| 2030 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2031 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2032 | |||||||||||||||||||||||||||||||||||||||||||
| 2033 | 0 | ▶ | return wantarray ? (\@merged_bins,$report_tag) : \@merged_bins; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2034 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2035 | |||||||||||||||||||||||||||||||||||||||||||
| 2036 | 0 | ▶ | sub build_summary_statistics { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_summary_statistics: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2037 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | my $interval_stats = $self->_interval_stats_table; | |||||||||||||||||||||||||||||||||||||||||
| 2039 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | $self->begin_work; | |||||||||||||||||||||||||||||||||||||||||
| 2041 | |||||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | my $sbs = SUMMARY_BIN_SIZE; | |||||||||||||||||||||||||||||||||||||||||
| 2043 | |||||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | my $result = eval { | |||||||||||||||||||||||||||||||||||||||||
| 2045 | 0 | $self->_add_interval_stats_table; | |||||||||||||||||||||||||||||||||||||||||
| 2046 | 0 | $self->_disable_keys($dbh,$interval_stats); | |||||||||||||||||||||||||||||||||||||||||
| 2047 | 0 | $dbh->do("DELETE FROM $interval_stats"); | |||||||||||||||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||||||||||||||||
| 2049 | 0 | ▶ | my $insert = $dbh->prepare(<<END) or $self->throw($dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2050 | INSERT INTO $interval_stats | ||||||||||||||||||||||||||||||||||||||||||
| 2051 | (typeid,seqid,bin,cum_count) | ||||||||||||||||||||||||||||||||||||||||||
| 2052 | VALUES (?,?,?,?) | ||||||||||||||||||||||||||||||||||||||||||
| 2053 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2054 | |||||||||||||||||||||||||||||||||||||||||||
| 2055 | 0 | my $sql = $self->_fetch_indexed_features_sql; | |||||||||||||||||||||||||||||||||||||||||
| 2056 | 0 | ▶ | my $select = $dbh->prepare($sql) or $self->throw($dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2057 | |||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | my $current_bin = -1; | |||||||||||||||||||||||||||||||||||||||||
| 2059 | 0 | my ($current_type,$current_seqid,$count); | |||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | my $cum_count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | my (%residuals,$last_bin); | |||||||||||||||||||||||||||||||||||||||||
| 2062 | |||||||||||||||||||||||||||||||||||||||||||
| 2063 | 0 | ▶ | my $le = -t \*STDERR ? "\r" : "\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2064 | |||||||||||||||||||||||||||||||||||||||||||
| 2065 | 0 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2066 | 0 | $select->execute; | |||||||||||||||||||||||||||||||||||||||||
| 2067 | |||||||||||||||||||||||||||||||||||||||||||
| 2068 | 0 | ▶ | while (my($typeid,$seqid,$start,$end) = $select->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2069 | 0 | ▶ | print STDERR $count," features processed$le" if ++$count % 1000 == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2070 | |||||||||||||||||||||||||||||||||||||||||||
| 2071 | 0 | my $bin = int($start/$sbs); | |||||||||||||||||||||||||||||||||||||||||
| 2072 | 0 | ▶ | $current_type ||= $typeid; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$current_type ||= $typeid
MC/DC0%0/2
$current_type ||= $typeid
$current_type
$typeid
Truth table0%0/3
A ||= B
A= $current_typeB= $typeid
| |||||||||||||||||||||||||||||||||||||||||||
| 2073 | 0 | ▶ | $current_seqid ||= $seqid; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$current_seqid ||= $seqid
MC/DC0%0/2
$current_seqid ||= $seqid
$current_seqid
$seqid
Truth table0%0/3
A ||= B
A= $current_seqidB= $seqid
| |||||||||||||||||||||||||||||||||||||||||||
| 2074 | |||||||||||||||||||||||||||||||||||||||||||
| 2075 | # because the input is sorted by start, no more features will contribute to the | ||||||||||||||||||||||||||||||||||||||||||
| 2076 | # current bin so we can dispose of it | ||||||||||||||||||||||||||||||||||||||||||
| 2077 | 0 | ▶ | if ($bin != $current_bin) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2078 | 0 | ▶ | if ($seqid != $current_seqid or $typeid != $current_type) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$seqid != $current_seqid or $typeid != $current_type
MC/DC0%0/2
$seqid != $current_seqid or $typeid != $current_type
$seqid != $current_seqid
$typeid != $current_type
Truth table0%0/3
A or B
A= $seqid != $current_seqidB= $typeid != $current_type
| |||||||||||||||||||||||||||||||||||||||||||
| 2079 | # load all bins left over | ||||||||||||||||||||||||||||||||||||||||||
| 2080 | 0 | $self->_load_bins($insert,\%residuals,\$cum_count,$current_type,$current_seqid); | |||||||||||||||||||||||||||||||||||||||||
| 2081 | 0 | %residuals = () ; | |||||||||||||||||||||||||||||||||||||||||
| 2082 | 0 | $cum_count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 2083 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2084 | # load all up to current one | ||||||||||||||||||||||||||||||||||||||||||
| 2085 | 0 | $self->_load_bins($insert,\%residuals,\$cum_count,$current_type,$current_seqid,$current_bin); | |||||||||||||||||||||||||||||||||||||||||
| 2086 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2087 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||
| 2089 | 0 | $last_bin = $current_bin; | |||||||||||||||||||||||||||||||||||||||||
| 2090 | 0 | ($current_seqid,$current_type,$current_bin) = ($seqid,$typeid,$bin); | |||||||||||||||||||||||||||||||||||||||||
| 2091 | |||||||||||||||||||||||||||||||||||||||||||
| 2092 | # summarize across entire spanned region | ||||||||||||||||||||||||||||||||||||||||||
| 2093 | 0 | my $last_bin = int(($end-1)/$sbs); | |||||||||||||||||||||||||||||||||||||||||
| 2094 | 0 | ▶ | for (my $b=$bin;$b<=$last_bin;$b++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2095 | 0 | $residuals{$b}++; | |||||||||||||||||||||||||||||||||||||||||
| 2096 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2097 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2098 | # handle tail case | ||||||||||||||||||||||||||||||||||||||||||
| 2099 | # load all bins left over | ||||||||||||||||||||||||||||||||||||||||||
| 2100 | 0 | $self->_load_bins($insert,\%residuals,\$cum_count,$current_type,$current_seqid); | |||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | $self->_enable_keys($dbh,$interval_stats); | |||||||||||||||||||||||||||||||||||||||||
| 2102 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 2103 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 2104 | |||||||||||||||||||||||||||||||||||||||||||
| 2105 | 0 | ▶ | if ($result) { $self->commit } else { warn "Can't build summary statistics: $@"; $self->rollback }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2106 | 0 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2108 | |||||||||||||||||||||||||||||||||||||||||||
| 2109 | 0 | ▶ | sub _load_bins { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_bins: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2110 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2111 | 0 | my ($insert,$residuals,$cum_count,$type,$seqid,$stop_after) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 2112 | 0 | for my $b (sort {$a<=>$b} keys %$residuals) { | |||||||||||||||||||||||||||||||||||||||||
| 2113 | 0 | ▶ | last if defined $stop_after and $b > $stop_after; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $stop_after and $b > $stop_after
MC/DC0%0/2
defined $stop_after and $b > $stop_after
defined $stop_after
$b > $stop_after
Truth table0%0/3
A and B
A= defined $stop_afterB= $b > $stop_after
| |||||||||||||||||||||||||||||||||||||||||||
| 2114 | 0 | $$cum_count += $residuals->{$b}; | |||||||||||||||||||||||||||||||||||||||||
| 2115 | 0 | my @args = ($type,$seqid,$b,$$cum_count); | |||||||||||||||||||||||||||||||||||||||||
| 2116 | 0 | $insert->execute(@args); | |||||||||||||||||||||||||||||||||||||||||
| 2117 | 0 | delete $residuals->{$b}; # no longer needed | |||||||||||||||||||||||||||||||||||||||||
| 2118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||
| 2121 | 0 | ▶ | sub _add_interval_stats_table { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_interval_stats_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2122 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2123 | 0 | my $tables = $self->table_definitions; | |||||||||||||||||||||||||||||||||||||||||
| 2124 | 0 | my $interval_stats = $self->_interval_stats_table; | |||||||||||||||||||||||||||||||||||||||||
| 2125 | 0 | $self->dbh->do("CREATE TABLE IF NOT EXISTS $interval_stats $tables->{interval_stats}"); | |||||||||||||||||||||||||||||||||||||||||
| 2126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2127 | |||||||||||||||||||||||||||||||||||||||||||
| 2128 | 0 | ▶ | sub _fetch_indexed_features_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_indexed_features_sql: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2129 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2130 | 0 | my $features = $self->_feature_table; | |||||||||||||||||||||||||||||||||||||||||
| 2131 | 0 | return <<END; | |||||||||||||||||||||||||||||||||||||||||
| 2132 | SELECT typeid,seqid,start-1,end | ||||||||||||||||||||||||||||||||||||||||||
| 2133 | FROM $features as f | ||||||||||||||||||||||||||||||||||||||||||
| 2134 | WHERE f.indexed=1 | ||||||||||||||||||||||||||||||||||||||||||
| 2135 | ORDER BY typeid,seqid,start | ||||||||||||||||||||||||||||||||||||||||||
| 2136 | END | ||||||||||||||||||||||||||||||||||||||||||
| 2137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||
| 2139 | 0 | ▶ | sub _disable_keys { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_disable_keys: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2140 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2141 | 0 | my ($dbh,$table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 2142 | 0 | $dbh->do("ALTER TABLE $table DISABLE KEYS"); | |||||||||||||||||||||||||||||||||||||||||
| 2143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2144 | 0 | ▶ | sub _enable_keys { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_enable_keys: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2145 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2146 | 0 | my ($dbh,$table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 2147 | 0 | $dbh->do("ALTER TABLE $table ENABLE KEYS"); | |||||||||||||||||||||||||||||||||||||||||
| 2148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2149 | |||||||||||||||||||||||||||||||||||||||||||
| 2150 | 0 | ▶ | sub time { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2151 | 0 | ▶ | return Time::HiRes::time() if Time::HiRes->can('time'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | return time(); | |||||||||||||||||||||||||||||||||||||||||
| 2153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||||||||||
| 2155 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 2156 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2157 | 0 | ▶ | if ($self->{bulk_update_in_progress}) { # be sure to remove temp files | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2158 | 0 | for my $table ($self->_feature_table,$self->index_tables) { | |||||||||||||||||||||||||||||||||||||||||
| 2159 | 0 | my $path = $self->dump_path($table); | |||||||||||||||||||||||||||||||||||||||||
| 2160 | 0 | unlink $path; | |||||||||||||||||||||||||||||||||||||||||
| 2161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||||||||||||||||
| 2165 | 0 | ▶ | sub begin_work { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
begin_work: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2166 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2167 | 0 | ▶ | return if $self->{_in_transaction}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 2169 | 0 | ▶ | return unless $dbh->{AutoCommit}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2170 | 0 | $dbh->begin_work; | |||||||||||||||||||||||||||||||||||||||||
| 2171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||||||||||||||||
| 2173 | 0 | ▶ | sub commit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
commit: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2174 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2175 | 0 | ▶ | return unless $self->{_in_transaction}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2176 | 0 | delete $self->{_in_transaction}; | |||||||||||||||||||||||||||||||||||||||||
| 2177 | 0 | $self->dbh->commit; | |||||||||||||||||||||||||||||||||||||||||
| 2178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||||||||||||||||
| 2180 | 0 | ▶ | sub rollback { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rollback: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 2181 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 2182 | 0 | ▶ | return unless $self->{_in_transaction}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2183 | 0 | delete $self->{_in_transaction}; | |||||||||||||||||||||||||||||||||||||||||
| 2184 | 0 | $self->dbh->rollback; | |||||||||||||||||||||||||||||||||||||||||
| 2185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||
| 2187 | |||||||||||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||||||||||
| 2189 | |||||||||||||||||||||||||||||||||||||||||||
| 2190 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||