GFF/Adaptor/dbi/mysqlcmap.pm

filter: Statementstmt 18.2% 36 / 197 Branchbran 0.0% 0 / 62 Conditioncond 0.0% 0 / 23 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 39.2% 11 / 28 Podpod 76.4% 13 / 17 totaltotal 17.6% 60 / 341 CC 42 SCAR 38.2
CC
42
Cov
13%
load_gff_line
132.0
get_table_id
90.0
search_notes
56.0
CRAP 45.5
« GFF/RelSegment.pm ↑ Summary GFF/Adaptor/dbi/pg_fts.pm »
1 package Bio::DB::GFF::Adaptor::dbi::mysqlcmap;
2 1 $Bio::DB::GFF::Adaptor::dbi::mysqlcmap::VERSION = '1.7.4';
3 =head1 NAME
4  
5 Bio::DB::GFF::Adaptor::dbi::mysqlcmap -- Database adaptor for an integraded
6 CMap/GBrowse mysql schema
7  
8 =head1 SYNOPSIS
9  
10 See L<Bio::DB::GFF>
11  
12 =cut
13  
14 # a simple mysql adaptor
15 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Bio::DB::GFF::Adaptor::dbi;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Bio::DB::GFF::Util::Rearrange; # for rearrange()
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Bio::DB::GFF::Util::Binning;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use base qw(Bio::DB::GFF::Adaptor::dbi::mysql);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 require Bio::DB::GFF::Adaptor::dbi::mysql;
22  
23 1 ▶use constant GETSEQCOORDS =><<END;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 SELECT fref,
25 IF(ISNULL(gclass),'Sequence',gclass),
26 min(fstart),
27 max(fstop),
28 fstrand,
29 feature_name as gname
30 FROM fdata,cmap_feature
31 WHERE cmap_feature.feature_name=?
32 AND cmap_feature.gclass=?
33 AND cmap_feature.feature_id=fdata.feature_id
34 GROUP BY fref,fstrand,feature_name
35 END
36 ;
37  
38 1 ▶use constant GETALIASCOORDS =><<END;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 SELECT fref,
40 IF(ISNULL(gclass),'Sequence',gclass),
41 min(fstart),
42 max(fstop),
43 fstrand,
44 feature_name as gname
45 FROM fdata,cmap_feature,fattribute,fattribute_to_feature
46 WHERE fattribute_to_feature.fattribute_value=?
47 AND cmap_feature.gclass=?
48 AND cmap_feature.feature_id=fdata.feature_id
49 AND fattribute.fattribute_name='Alias'
50 AND fattribute_to_feature.fattribute_id=fattribute.fattribute_id
51 AND fattribute_to_feature.fid=fdata.fid
52 GROUP BY fref,fstrand,feature_name
53 END
54 ;
55  
56 1 ▶use constant GETALIASLIKE =><<END;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 SELECT fref,
58 IF(ISNULL(gclass),'Sequence',gclass),
59 min(fstart),
60 max(fstop),
61 fstrand,
62 feature_name as gname
63 FROM fdata,cmap_feature,fattribute,fattribute_to_feature
64 WHERE fattribute_to_feature.fattribute_value LIKE ?
65 AND cmap_feature.gclass=?
66 AND cmap_feature.feature_id=fdata.feature_id
67 AND fattribute.fattribute_name='Alias'
68 AND fattribute_to_feature.fattribute_id=fattribute.fattribute_id
69 AND fattribute_to_feature.fid=fdata.fid
70 GROUP BY fref,fstrand,feature_name
71 END
72 ;
73  
74 1 ▶use constant GETFORCEDSEQCOORDS =><<END;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 SELECT fref,
76 IF(ISNULL(gclass),'Sequence',gclass),
77 min(fstart),
78 max(fstop),
79 fstrand
80 FROM fdata,cmap_feature
81 WHERE cmap_feature.feature_name=?
82 AND cmap_feature.gclass=?
83 AND fdata.fref=?
84 AND cmap_feature.feature_id=fdata.feature_id
85 GROUP BY fref,fstrand
86 END
87 ;
88  
89 1 ▶use constant FULLTEXTSEARCH => <<END;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 SELECT distinct gclass,feature_name,fattribute_value,MATCH(fattribute_value) AGAINST (?) as score
91 FROM cmap_feature,fattribute_to_feature,fdata
92 WHERE cmap_feature.feature_id=fdata.feature_id
93 AND fdata.fid=fattribute_to_feature.fid
94 AND MATCH(fattribute_value) AGAINST (?)
95 END
96 ;
97  
98 =head1 DESCRIPTION
99  
100 This adaptor implements a specific mysql database schema that is
101 compatible with Bio::DB::GFF. It inherits from
102 Bio::DB::GFF::Adaptor::dbi, which itself inherits from Bio::DB::GFF.
103  
104 The schema uses several tables:
105  
106 =over 4
107  
108 =item fdata
109  
110 This is the feature data table. Its columns are:
111 -
112 fid feature ID (integer)
113 fref reference sequence name (string)
114 fstart start position relative to reference (integer)
115 fstop stop position relative to reference (integer)
116 ftypeid feature type ID (integer)
117 fscore feature score (float); may be null
118 fstrand strand; one of "+" or "-"; may be null
119 fphase phase; one of 0, 1 or 2; may be null
120 feature_id group ID used to be 'gid' (integer)
121 ftarget_start for similarity features, the target start position (integer)
122 ftarget_stop for similarity features, the target stop position (integer)
123  
124 Note that it would be desirable to normalize the reference sequence
125 name, since there are usually many features that share the same
126 reference feature. However, in the current schema, query performance
127 suffers dramatically when this additional join is added.
128  
129 =item cmap_feature (replaces fgroup)
130  
131 This is the group table. There is one row for each group. This is the
132 shared table between CMap and GBrowse. There are many CMap related
133 columns but only a few that GBrowse uses.
134  
135 GBrowse Columns:
136  
137 feature_id the group ID (integer)
138 gclass the class of the group (string)
139 feature_name the name of the group (string)
140  
141 The group table serves multiple purposes. As you might expect, it is
142 used to cluster features that logically belong together, such as the
143 multiple exons of the same transcript. It is also used to assign a
144 name and class to a singleton feature. Finally, the group table is
145 used to identify the target of a similarity hit. This is consistent
146 with the way in which the group field is used in the GFF version 2
147 format.
148  
149 The cmap_feature.feature_id field joins with the fdata.feature_id field.
150  
151 Examples:
152  
153 mysql> select * from cmap_feature where feature_name='sjj_2L52.1';
154 +--------------+-------------+--------------+
155 | feature_id | gclass | feature_name |
156 +--------------+-------------+--------------+
157 | 69736 | PCR_product | sjj_2L52.1 |
158 +--------------+-------------+--------------+
159 1 row in set (0.70 sec)
160  
161 mysql> select fref,fstart,fstop from fdata,cmap_feature
162 where gclass='PCR_product' and feature_name = 'sjj_2L52.1'
163 and fdata.feature_id=cmap_feature.feature_id;
164 +---------------+--------+-------+
165 | fref | fstart | fstop |
166 +---------------+--------+-------+
167 | CHROMOSOME_II | 1586 | 2355 |
168 +---------------+--------+-------+
169 1 row in set (0.03 sec)
170  
171 =item ftype
172  
173 This table contains the feature types, one per row. Columns are:
174  
175 ftypeid the feature type ID (integer)
176 fmethod the feature type method name (string)
177 fsource the feature type source name (string)
178  
179 The ftype.ftypeid field joins with the fdata.ftypeid field. Example:
180  
181 mysql> select fref,fstart,fstop,fmethod,fsource from fdata,cmap_feature,ftype
182 where gclass='PCR_product'
183 and feature_name = 'sjj_2L52.1'
184 and fdata.feature_id=cmap_feature.feature_id
185 and fdata.ftypeid=ftype.ftypeid;
186 +---------------+--------+-------+-------------+-----------+
187 | fref | fstart | fstop | fmethod | fsource |
188 +---------------+--------+-------+-------------+-----------+
189 | CHROMOSOME_II | 1586 | 2355 | PCR_product | GenePairs |
190 +---------------+--------+-------+-------------+-----------+
191 1 row in set (0.08 sec)
192  
193 =item fdna
194  
195 This table holds the raw DNA of the reference sequences. It has three
196 columns:
197  
198 fref reference sequence name (string)
199 foffset offset of this sequence
200 fdna the DNA sequence (longblob)
201  
202 To overcome problems loading large blobs, DNA is automatically
203 fragmented into multiple segments when loading, and the position of
204 each segment is stored in foffset. The fragment size is controlled by
205 the -clump_size argument during initialization.
206  
207 =item fattribute_to_feature
208  
209 This table holds "attributes", which are tag/value pairs stuffed into
210 the GFF line. The first tag/value pair is treated as the group, and
211 anything else is treated as an attribute (weird, huh?).
212  
213 CHR_I assembly_tag Finished 2032 2036 . + . Note "Right: cTel33B"
214 CHR_I assembly_tag Polymorphism 668 668 . + . Note "A->C in cTel33B"
215  
216 The columns of this table are:
217  
218 fid feature ID (integer)
219 fattribute_id ID of the attribute (integer)
220 fattribute_value text of the attribute (text)
221  
222 The fdata.fid column joins with fattribute_to_feature.fid.
223  
224 =item fattribute
225  
226 This table holds the normalized names of the attributes. Fields are:
227  
228 fattribute_id ID of the attribute (integer)
229 fattribute_name Name of the attribute (varchar)
230  
231 =back
232  
233 =head2 Data Loading Methods
234  
235 In addition to implementing the abstract SQL-generating methods of
236 Bio::DB::GFF::Adaptor::dbi, this module also implements the data
237 loading functionality of Bio::DB::GFF.
238  
239 =cut
240  
241  
242 =head2 new
243  
244 Title : new
245 Usage : $db = Bio::DB::GFF->new(@args)
246 Function: create a new adaptor
247 Returns : a Bio::DB::GFF object
248 Args : see below
249 Status : Public
250  
251 The new constructor is identical to the "dbi" adaptor's new() method,
252 except that the prefix "dbi:mysql" is added to the database DSN identifier
253 automatically if it is not there already.
254  
255 Argument Description
256 -------- -----------
257  
258 -dsn the DBI data source, e.g. 'dbi:mysql:ens0040' or "ens0040"
259  
260 -user username for authentication
261  
262 -pass the password for authentication
263  
264 =cut
265  
266 #'
267  
268 #Defined in mysql.pm
269  
270 =head2 get_dna
271  
272 Title : get_dna
273 Usage : $string = $db->get_dna($name,$start,$stop,$class)
274 Function: get DNA string
275 Returns : a string
276 Args : name, class, start and stop of desired segment
277 Status : Public
278  
279 This method performs the low-level fetch of a DNA substring given its
280 name, class and the desired range. This should probably be moved to
281 the parent class.
282  
283 =cut
284  
285 0 ▶sub make_features_select_part {
Subroutine make_features_select_part: not called CC=5 SCAR=34.0
Pod documented
286 0 my $self = shift;
287 0 ▶ my $options = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
288 0 my $s;
289 0 ▶ if (my $b = $options->{bin_width}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $b = $options->{'bin_width'}) { } 0 0 0
290  
291 0 $s = <<END;
292 fref,
293 1+$b*floor(fstart/$b) as fstart,
294 $b*(1+floor(fstart/$b)) as fstop,
295 IF(ISNULL(fsource),fmethod,concat(fmethod,':',fsource)),'bin',
296 count(*) as fscore,
297 '.','.','bin',
298 IF(ISNULL(fsource),concat(fref,':',fmethod),concat(fref,':',fmethod,':',fsource)),
299 NULL,NULL,NULL,NULL
300 END
301 ;
302 } else {
303 0 $s = <<END;
304 fref,fstart,fstop,fsource,fmethod,fscore,fstrand,fphase,gclass,feature_name as gname,ftarget_start,ftarget_stop,fdata.fid,fdata.feature_id
305 END
306 ;
307 }
308 0 ▶ $s .= ",count(fdata.fid)" if $options->{attributes} && keys %{$options->{attributes}}>1;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"attributes"} and keys %{$$options{"attributes"};} > 1 0 0 0
Condition0%0/3
$options->{"attributes"} and keys %{$$options{"attributes"};} > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$options->{"attributes"} and keys %{$$options{"attributes"};} > 1
$options->{"attributes"} keys %{$$options{"attributes"};} > 1
Truth table0%0/3
A and B
A= $options->{"attributes"}B= keys %{$$options{"attributes"};} > 1
ABresult
0X0
100
111
309 0 $s;
310 }
311  
312  
313 # IMPORTANT NOTE:
314 # WHETHER OR NOT THIS WORKS IS CRITICALLY DEPENDENT ON THE RELATIVE MAGNITUDE OF THE
315 0 ▶sub make_features_from_part {
Subroutine make_features_from_part: not called CC=5 SCAR=34.0
Pod documented
316 0 my $self = shift;
317 0 my $sparse_types = shift;
318 0 ▶ my $options = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
319 0 my $sparse_groups = $options->{sparse_groups};
320 0 ▶ my $index = $sparse_groups ? ' USE INDEX(feature_id)'
Branch: 2 branches
BranchTrueFalseTotal
$sparse_groups ? : 0 0 0
$sparse_types ? : 0 0 0
321 : $sparse_types ? ' USE INDEX(ftypeid)'
322 : '';
323 0 ▶ return $options->{attributes} ? "fdata${index},ftype,cmap_feature,fattribute,fattribute_to_feature\n"
Branch: 1 branch
BranchTrueFalseTotal
$options->{'attributes'} ? : 0 0 0
324 : "fdata${index},ftype,cmap_feature\n";
325 }
326  
327 ################################ loading and initialization ##################################
328  
329 =head2 schema
330  
331 Title : schema
332 Usage : $schema = $db->schema
333 Function: return the CREATE script for the schema
334 Returns : a list of CREATE statemetns
335 Args : none
336 Status : protected
337  
338 This method returns a list containing the various CREATE statements
339 needed to initialize the database tables.
340  
341 =cut
342  
343 0 ▶sub schema {
Subroutine schema: not called CC=1 SCAR=6.9
Pod documented
344 0 my %schema = (
345 fdata =>{
346 table=> q{
347 #create table fdata (
348 # fid int not null auto_increment,
349 # fref varchar(100) not null,
350 # fstart int unsigned not null,
351 # fstop int unsigned not null,
352 # ftypeid int not null,
353 # fscore float,
354 # fstrand enum('+','-'),
355 # fphase enum('0','1','2'),
356 # feature_id int not null,
357 # ftarget_start int unsigned,
358 # ftarget_stop int unsigned,
359 # primary key(fid),
360 # unique index(fref,fstart,fstop,ftypeid,feature_id),
361 # index(ftypeid),
362 # index(feature_id)
363 #) type=MyISAM
364  
365  
366 create table fdata (
367 fid int not null auto_increment,
368 fref varchar(100) not null,
369 fstart int unsigned not null,
370 fstop int unsigned not null,
371 fbin double(20,6) not null,
372 ftypeid int not null,
373 fscore float,
374 fstrand enum('+','-'),
375 fphase enum('0','1','2'),
376 feature_id int not null,
377 ftarget_start int unsigned,
378 ftarget_stop int unsigned,
379 primary key(fid),
380 unique index(fref,fbin,fstart,fstop,ftypeid,feature_id),
381 index(ftypeid),
382 index(feature_id)
383 ) type=MyISAM
384 } # fdata table
385 }, # fdata
386  
387 ftype => {
388 table=> q{
389 create table ftype (
390 ftypeid int not null auto_increment,
391 fmethod varchar(100) not null,
392 fsource varchar(100),
393 primary key(ftypeid),
394 index(fmethod),
395 index(fsource),
396 unique ftype (fmethod,fsource)
397 )type=MyISAM
398 } #ftype table
399 }, #ftype
400  
401 fdna => {
402 table=> q{
403 create table fdna (
404 fref varchar(100) not null,
405 foffset int(10) unsigned not null,
406 fdna longblob,
407 primary key(fref,foffset)
408 )type=MyISAM
409 } # fdna table
410 },#fdna
411  
412 fmeta => {
413 table=> q{
414 create table fmeta (
415 fname varchar(255) not null,
416 fvalue varchar(255) not null,
417 primary key(fname)
418 )type=MyISAM
419 } # fmeta table
420 },#fmeta
421  
422 fattribute => {
423 table=> q{
424 create table fattribute (
425 fattribute_id int(10) unsigned not null auto_increment,
426 fattribute_name varchar(255) not null,
427 primary key(fattribute_id)
428 )type=MyISAM
429 } #fattribute table
430 },#fattribute
431  
432 fattribute_to_feature => {
433 table=> q{
434 create table fattribute_to_feature (
435 fid int(10) not null,
436 fattribute_id int(10) not null,
437 fattribute_value text,
438 key(fid,fattribute_id),
439 key(fattribute_value(48)),
440 fulltext(fattribute_value)
441 )type=MyISAM
442 } # fattribute_to_feature table
443 }, # fattribute_to_feature
444  
445  
446 cmap_attribute => {
447 table=>q{
448 create table cmap_attribute (
449 attribute_id int(11) NOT NULL default '0',
450 table_name varchar(30) NOT NULL default '',
451 object_id int(11) NOT NULL default '0',
452 display_order int(11) NOT NULL default '1',
453 is_public tinyint(4) NOT NULL default '1',
454 attribute_name varchar(200) NOT NULL default '',
455 attribute_value text NOT NULL,
456 PRIMARY KEY (attribute_id),
457 KEY table_name (table_name,object_id,display_order,attribute_name)
458 ) TYPE=MyISAM;
459 } # table
460 },
461  
462 cmap_correspondence_evidence => {
463 table=>q{
464 create table cmap_correspondence_evidence (
465 correspondence_evidence_id int(11) NOT NULL default '0',
466 accession_id varchar(20) NOT NULL default '',
467 feature_correspondence_id int(11) NOT NULL default '0',
468 evidence_type_accession varchar(20) NOT NULL default '0',
469 score double(8,2) default NULL,
470 rank int(11) NOT NULL default '0',
471 PRIMARY KEY (correspondence_evidence_id),
472 UNIQUE KEY accession_id (accession_id),
473 KEY feature_correspondence_id (feature_correspondence_id)
474 ) TYPE=MyISAM;
475 } # table
476 },
477  
478  
479 cmap_correspondence_lookup => {
480 table=>q{
481 create table cmap_correspondence_lookup (
482 feature_id1 int(11) default NULL,
483 feature_id2 int(11) default NULL,
484 feature_correspondence_id int(11) default NULL,
485 start_position1 double(11,2) default NULL,
486 start_position2 double(11,2) default NULL,
487 stop_position1 double(11,2) default NULL,
488 stop_position2 double(11,2) default NULL,
489 map_id1 int(11) default NULL,
490 map_id2 int(11) default NULL,
491 feature_type_accession1 varchar(20) default NULL,
492 feature_type_accession2 varchar(20) default NULL,
493 KEY feature_id1 (feature_id1),
494 KEY corr_id (feature_correspondence_id),
495 KEY cl_map_id1 (map_id1),
496 KEY cl_map_id2 (map_id2),
497 KEY cl_map_id1_map_id2 (map_id1,map_id2),
498 KEY cl_map_id2_map_id1 (map_id2,map_id1)
499 ) TYPE=MyISAM;
500 } # table
501 },
502  
503  
504 cmap_correspondence_matrix => {
505 table=>q{
506 create table cmap_correspondence_matrix (
507 reference_map_aid varchar(20) NOT NULL default '0',
508 reference_map_name varchar(32) NOT NULL default '',
509 reference_map_set_aid varchar(20) NOT NULL default '0',
510 reference_species_aid varchar(20) NOT NULL default '0',
511 link_map_aid varchar(20) default NULL,
512 link_map_name varchar(32) default NULL,
513 link_map_set_aid varchar(20) NOT NULL default '0',
514 link_species_aid varchar(20) NOT NULL default '0',
515 no_correspondences int(11) NOT NULL default '0'
516 ) TYPE=MyISAM;
517 } # table
518 },
519  
520  
521 cmap_feature => {
522 table=>q{
523 create table cmap_feature (
524 feature_id int(11) NOT NULL default '0',
525 accession_id varchar(20) NOT NULL default '',
526 map_id int(11) default NULL,
527 feature_type_accession varchar(20) NOT NULL default '0',
528 feature_name varchar(32) NOT NULL default '',
529 is_landmark tinyint(4) NOT NULL default '0',
530 start_position double(11,2) NOT NULL default '0.00',
531 stop_position double(11,2) default NULL,
532 default_rank int(11) NOT NULL default '1',
533 direction tinyint(4) NOT NULL default '1',
534 gclass varchar(100) default NULL,
535 PRIMARY KEY (feature_id),
536 UNIQUE KEY gclass (gclass,feature_name),
537 UNIQUE KEY accession_id (accession_id),
538 KEY feature_name (feature_name),
539 KEY feature_id_map_id (feature_id,map_id),
540 KEY feature_id_map_id_start (feature_id,map_id,start_position),
541 KEY map_id (map_id),
542 KEY map_id_feature_id (map_id,feature_id)
543 ) TYPE=MyISAM;
544 } # table
545 },
546  
547  
548 cmap_feature_alias => {
549 table=>q{
550 create table cmap_feature_alias (
551 feature_alias_id int(11) NOT NULL default '0',
552 feature_id int(11) NOT NULL default '0',
553 alias varchar(255) default NULL,
554 PRIMARY KEY (feature_alias_id),
555 UNIQUE KEY feature_id_2 (feature_id,alias),
556 KEY feature_id (feature_id),
557 KEY alias (alias)
558 ) TYPE=MyISAM;
559 } # table
560 },
561  
562  
563 cmap_feature_correspondence => {
564 table=>q{
565 create table cmap_feature_correspondence (
566 feature_correspondence_id int(11) NOT NULL default '0',
567 accession_id varchar(20) NOT NULL default '',
568 feature_id1 int(11) NOT NULL default '0',
569 feature_id2 int(11) NOT NULL default '0',
570 is_enabled tinyint(4) NOT NULL default '1',
571 PRIMARY KEY (feature_correspondence_id),
572 UNIQUE KEY accession_id (accession_id),
573 KEY feature_id1 (feature_id1),
574 KEY cmap_feature_corresp_idx (is_enabled,feature_correspondence_id)
575 ) TYPE=MyISAM;
576 } # table
577 },
578  
579  
580 cmap_map => {
581 table=>q{
582 create table cmap_map (
583 map_id int(11) NOT NULL default '0',
584 accession_id varchar(20) NOT NULL default '',
585 map_set_id int(11) NOT NULL default '0',
586 map_name varchar(32) NOT NULL default '',
587 display_order int(11) NOT NULL default '1',
588 start_position double(11,2) default NULL,
589 stop_position double(11,2) default NULL,
590 PRIMARY KEY (map_id),
591 UNIQUE KEY accession_id (accession_id),
592 UNIQUE KEY map_id (map_id,map_set_id,map_name,accession_id),
593 KEY map_set_id_index (map_set_id)
594 ) TYPE=MyISAM;
595 } # table
596 },
597  
598  
599 cmap_map_set => {
600 table=>q{
601 create table cmap_map_set (
602 map_set_id int(11) NOT NULL default '0',
603 accession_id varchar(20) NOT NULL default '',
604 map_set_name varchar(64) NOT NULL default '',
605 short_name varchar(30) NOT NULL default '',
606 map_type_accession varchar(20) NOT NULL default '0',
607 species_id int(11) NOT NULL default '0',
608 published_on date default NULL,
609 can_be_reference_map tinyint(4) NOT NULL default '1',
610 display_order int(11) NOT NULL default '1',
611 is_enabled tinyint(4) NOT NULL default '1',
612 shape varchar(12) default NULL,
613 color varchar(20) default NULL,
614 width int(11) default NULL,
615 map_units varchar(12) NOT NULL default '',
616 is_relational_map tinyint(11) NOT NULL default '0',
617 PRIMARY KEY (map_set_id),
618 UNIQUE KEY accession_id (accession_id),
619 UNIQUE KEY map_set_id (map_set_id,species_id,short_name,accession_id),
620 KEY cmap_map_set_idx (can_be_reference_map,is_enabled,species_id,display_order,published_on,short_name)
621 ) TYPE=MyISAM;
622 } # table
623 },
624  
625  
626 cmap_next_number => {
627 table=>q{
628 create table cmap_next_number (
629 table_name varchar(40) NOT NULL default '',
630 next_number int(11) NOT NULL default '0',
631 PRIMARY KEY (table_name)
632 ) TYPE=MyISAM;
633 }, # table
634 insert=>{next_num=>q[ insert into cmap_next_number (table_name,next_number) VALUES ('cmap_feature',82);]}
635 },
636  
637  
638 cmap_species => {
639 table=>q{
640 create table cmap_species (
641 species_id int(11) NOT NULL default '0',
642 accession_id varchar(20) NOT NULL default '',
643 common_name varchar(64) NOT NULL default '',
644 full_name varchar(64) NOT NULL default '',
645 display_order int(11) NOT NULL default '1',
646 PRIMARY KEY (species_id),
647 KEY acc_id_species_id (accession_id,species_id)
648 ) TYPE=MyISAM;
649 } # table
650 },
651  
652  
653 cmap_xref => {
654 table=>q{
655 create table cmap_xref (
656 xref_id int(11) NOT NULL default '0',
657 table_name varchar(30) NOT NULL default '',
658 object_id int(11) default NULL,
659 display_order int(11) NOT NULL default '1',
660 xref_name varchar(200) NOT NULL default '',
661 xref_url text NOT NULL,
662 PRIMARY KEY (xref_id),
663 KEY table_name (table_name,object_id,display_order)
664 ) TYPE=MyISAM;
665 } # table
666 },
667  
668  
669 );
670 0 return \%schema;
671 }
672  
673  
674  
675 =head2 make_classes_query
676  
677 Title : make_classes_query
678 Usage : ($query,@args) = $db->make_classes_query
679 Function: return query fragment for generating list of reference classes
680 Returns : a query and args
681 Args : none
682 Status : public
683  
684 =cut
685  
686 0 ▶sub make_classes_query {
Subroutine make_classes_query: not called CC=1 SCAR=6.9
Pod documented
687 0 my $self = shift;
688 0 return 'SELECT DISTINCT gclass FROM cmap_feature WHERE NOT ISNULL(gclass)';
689 }
690  
691  
692 =head2 setup_load
693  
694 Title : setup_load
695 Usage : $db->setup_load
696 Function: called before load_gff_line()
697 Returns : void
698 Args : none
699 Status : protected
700  
701 This method performs schema-specific initialization prior to loading a
702 set of GFF records. It prepares a set of DBI statement handlers to be
703 used in loading the data.
704  
705 =cut
706  
707 0 ▶sub setup_load {
Subroutine setup_load: not called CC=2 SCAR=17.9
Pod documented
708 0 my $self = shift;
709  
710 0 my $dbh = $self->features_db;
711  
712 0 ▶ if ($self->lock_on_load) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->lock_on_load) 0 0 0
713 0 my @tables = map { "$_ WRITE"} $self->tables;
714 0 my $tables = join ', ',@tables;
715 0 $dbh->do("LOCK TABLES $tables");
716 }
717  
718 #xx1
719 0 my $lookup_type = $dbh->prepare_delayed('SELECT ftypeid FROM ftype WHERE fmethod=? AND fsource=?');
720 0 my $insert_type = $dbh->prepare_delayed('INSERT INTO ftype (fmethod,fsource) VALUES (?,?)');
721  
722 0 my $lookup_group = $dbh->prepare_delayed('SELECT feature_id FROM cmap_feature WHERE feature_name=? AND gclass=?');
723 0 my $insert_group = $dbh->prepare_delayed(' INSERT into cmap_feature (feature_id, accession_id,feature_name, gclass ) VALUES (?,feature_id,?,?)');
724 0 my $aux_insert_group = $dbh->prepare_delayed(' update cmap_next_number set next_number = next_number +1 where table_name=\'cmap_feature\'');
725 0 my $next_id_group = $dbh->prepare_delayed('select next_number from cmap_next_number where table_name=\'cmap_feature\'');
726  
727 0 my $lookup_attribute = $dbh->prepare_delayed('SELECT fattribute_id FROM fattribute WHERE fattribute_name=?');
728 0 my $insert_attribute = $dbh->prepare_delayed('INSERT INTO fattribute (fattribute_name) VALUES (?)');
729 0 my $insert_attribute_value = $dbh->prepare_delayed('INSERT INTO fattribute_to_feature (fid,fattribute_id,fattribute_value) VALUES (?,?,?)');
730  
731 0 my $insert_data = $dbh->prepare_delayed(<<END);
732 INSERT INTO fdata (fref,fstart,fstop,fbin,ftypeid,fscore,
733 fstrand,fphase,feature_id,ftarget_start,ftarget_stop)
734 VALUES(?,?,?,?,?,?,?,?,?,?,?)
735 END
736 ;
737  
738  
739 0 $self->{load_stuff}{sth}{lookup_ftype} = $lookup_type;
740 0 $self->{load_stuff}{sth}{insert_ftype} = $insert_type;
741 #$self->{load_stuff}{sth}{lookup_fgroup} = $lookup_group;
742 #$self->{load_stuff}{sth}{insert_fgroup} = $insert_group;
743 0 $self->{load_stuff}{sth}{lookup_cmap_feature} = $lookup_group;
744 0 $self->{load_stuff}{sth}{insert_cmap_feature} = $insert_group;
745 0 $self->{load_stuff}{sth}{aux_insert_cmap_feature} = $aux_insert_group;
746 0 $self->{load_stuff}{sth}{next_id_cmap_feature} = $next_id_group;
747 0 $self->{load_stuff}{sth}{insert_fdata} = $insert_data;
748 0 $self->{load_stuff}{sth}{lookup_fattribute} = $lookup_attribute;
749 0 $self->{load_stuff}{sth}{insert_fattribute} = $insert_attribute;
750 0 $self->{load_stuff}{sth}{insert_fattribute_value} = $insert_attribute_value;
751 0 $self->{load_stuff}{types} = {};
752 0 $self->{load_stuff}{groups} = {};
753 0 $self->{load_stuff}{counter} = 0;
754 }
755  
756 =head2 load_gff_line
757  
758 Title : load_gff_line
759 Usage : $db->load_gff_line($fields)
760 Function: called to load one parsed line of GFF
761 Returns : true if successfully inserted
762 Args : hashref containing GFF fields
763 Status : protected
764  
765 This method is called once per line of the GFF and passed a series of
766 parsed data items that are stored into the hashref $fields. The keys are:
767  
768 ref reference sequence
769 source annotation source
770 method annotation method
771 start annotation start
772 stop annotation stop
773 score annotation score (may be undef)
774 strand annotation strand (may be undef)
775 phase annotation phase (may be undef)
776 group_class class of annotation's group (may be undef)
777 group_name ID of annotation's group (may be undef)
778 target_start start of target of a similarity hit
779 target_stop stop of target of a similarity hit
780 attributes array reference of attributes, each of which is a [tag=>value] array ref
781  
782 =cut
783  
784 0 ▶sub load_gff_line {
Subroutine load_gff_line: not called CC=11 SCAR=48.8
Pod documented
785 0 my $self = shift;
786 0 my $gff = shift;
787  
788 0 my $s = $self->{load_stuff};
789 0 my $dbh = $self->features_db;
790 0 local $dbh->{PrintError} = 0;
791  
792 0 ▶ defined(my $typeid = $self->get_table_id('ftype', $gff->{method} => $gff->{source})) or return;
Branch: 1 branch
BranchTrueFalseTotal
defined(my $typeid = $self->get_table_id("ftype", $gff->{"method"}, $gff->{"source"})) or return 0 0 0
793 0 ▶ defined(my $groupid = $self->get_table_id('cmap_feature',$gff->{gname} => $gff->{gclass})) or return;
Branch: 1 branch
BranchTrueFalseTotal
defined(my $groupid = $self->get_table_id("cmap_feature", $gff->{"gname"}, $gff->{"gclass"})) or return 0 0 0
794  
795 0 ▶ if ($gff->{stop}-$gff->{start}+1 > $self->max_bin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($gff->{"stop"} - $gff->{"start"} + 1 > $self->max_bin) 0 0 0
796 0 warn "$gff->{gclass}:$gff->{gname} is longer than ",$self->maxbin,".\n";
797 0 warn "Please set the maxbin value to a larger length than the largest feature you wish to store.\n";
798 0 warn "With the command-line tools you do with this with --maxfeature option.\n";
799 }
800  
801 0 my $bin = bin($gff->{start},$gff->{stop},$self->min_bin);
802 my $result = $s->{sth}{insert_fdata}->execute($gff->{ref},
803 $gff->{start},$gff->{stop},$bin,
804 $typeid,
805 $gff->{score},$gff->{strand},$gff->{phase},
806 $groupid,
807 0 $gff->{tstart},$gff->{tstop});
808  
809 0 ▶ warn $dbh->errstr,"\n" && return unless $result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 0 0
810  
811 my $fid = $dbh->{mysql_insertid}
812 0 ▶ || $self->get_feature_id($gff->{ref},$gff->{start},$gff->{stop},$typeid,$groupid);
Condition0%0/3
$dbh->{'mysql_insertid'} || $self->get_feature_id($gff->{'ref'}, $gff->{'start'}, $gff->{'stop'}, $typeid, $groupid)
l!l&&r!l&&!r
000
MC/DC0%0/2
$dbh->{'mysql_insertid'} || $self->get_feature_id($gff->{'ref'}, $gff->{'start'}, $gff->{'stop'}, $typeid, $groupid)
$dbh->{'mysql_insertid'} $self->get_feature_id($gff->{'ref'}, $gff->{'start'}, $gff->{'stop'}, $typeid, $groupid)
Truth table0%0/3
A || B
A= $dbh->{'mysql_insertid'}B= $self->get_feature_id($gff->{'ref'}, $gff->{'start'}, $gff->{'stop'}, $typeid, $groupid)
ABresult
1X1
011
000
813  
814  
815 # insert attributes
816 0 foreach (@{$gff->{attributes}}) {
817 0 ▶ defined(my $attribute_id = $self->get_table_id('fattribute',$_->[0])) or return;
Branch: 1 branch
BranchTrueFalseTotal
defined(my $attribute_id = $self->get_table_id("fattribute", $_->[0])) or return 0 0 0
818 0 $s->{sth}{insert_fattribute_value}->execute($fid,$attribute_id,$_->[1]);
819 }
820  
821 0 ▶ if ( (++$s->{counter} % 1000) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$s->{"counter"} % 1000 == 0) 0 0 0
822 0 print STDERR "$s->{counter} records loaded...";
823 0 ▶ print STDERR -t STDOUT && !$ENV{EMACS} ? "\r" : "\n";
Branch: 1 branch
BranchTrueFalseTotal
-t STDOUT && !$ENV{'EMACS'} ? : 0 0 0
Condition0%0/3
-t STDOUT and not $ENV{"EMACS"}
!ll&&!rl&&r
000
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"}
ABresult
0X0
100
111
824 }
825  
826 0 $fid;
827 }
828  
829 =head2 get_feature_id
830  
831 Title : get_feature_id
832 Usage : $integer = $db->get_feature_id($ref,$start,$stop,$typeid,$groupid)
833 Function: get the ID of a feature
834 Returns : an integer ID or undef
835 Args : none
836 Status : private
837  
838 This internal method is called by load_gff_line to look up the integer
839 ID of an existing feature. It is ony needed when replacing a feature
840 with new information.
841  
842 =cut
843  
844 # this method is called when needed to look up a feature's ID
845 0 ▶sub get_feature_id {
Subroutine get_feature_id: not called CC=4 SCAR=30.0
Pod documented
846 0 my $self = shift;
847 0 my ($ref,$start,$stop,$typeid,$groupid) = @_;
848 0 my $s = $self->{load_stuff};
849 0 ▶ unless ($s->{get_feature_id}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->{"get_feature_id"}) 0 0 0
850 0 my $dbh = $self->features_db;
851 $s->{get_feature_id} =
852 0 $dbh->prepare_delayed('SELECT fid FROM fdata WHERE fref=? AND fstart=? AND fstop=? AND ftypeid=? AND feature_id=?');
853 }
854 0 ▶ my $sth = $s->{get_feature_id} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $sth = $s->{"get_feature_id"} or return 0 0 0
855 0 ▶ $sth->execute($ref,$start,$stop,$typeid,$groupid) or return;
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($ref, $start, $stop, $typeid, $groupid) or return 0 0 0
856 0 my ($fid) = $sth->fetchrow_array;
857 0 return $fid;
858 }
859  
860 =head2 get_table_id
861  
862 Title : get_table_id
863 Usage : $integer = $db->get_table_id($table,@ids)
864 Function: get the ID of a group or type
865 Returns : an integer ID or undef
866 Args : none
867 Status : private
868  
869 This internal method is called by load_gff_line to look up the integer
870 ID of an existing feature type or group. The arguments are the name
871 of the table, and two string identifiers. For feature types, the
872 identifiers are the method and source. For groups, the identifiers
873 are group name and class.
874  
875 This method requires that a statement handler named I<lookup_$table>,
876 have been created previously by setup_load(). It is here to overcome
877 deficiencies in mysql's INSERT syntax.
878  
879 =cut
880  
881 #'
882 # get the object ID from a named table
883 0 ▶sub get_table_id {
Subroutine get_table_id: not called CC=9 SCAR=45.0
Pod documented
884 0 my $self = shift;
885 0 my $table = shift;
886 0 my @ids = @_;
887  
888 # irritating warning for null id
889 0 my $id_key;
890 {
891 0 local $^W=0;
892 0 $id_key = join ':',@ids;
893 }
894  
895 0 my $s = $self->{load_stuff};
896 0 my $sth = $s->{sth};
897 0 my $dbh = $self->features_db;
898  
899 0 ▶ unless (defined($s->{$table}{$id_key})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $s->{$table}{$id_key}) 0 0 0
900  
901 #########################################
902 # retrieval of the last inserted id is now located at the adaptor and not in caching_handle
903 #######################################
904 0 ▶ if ( (my $result = $sth->{"lookup_$table"}->execute(@ids)) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $result = $$sth{"lookup_$table"}->execute(@ids)) > 0) { } 0 0 0
905 0 $s->{$table}{$id_key} = ($sth->{"lookup_$table"}->fetchrow_array)[0];
906 } else {
907 0 ▶ if (defined($sth->{"next_id_$table"})){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$sth{"next_id_$table"}) { } 0 0 0
908  
909 0 $sth->{"insert_$table"}->execute(3,'string1','string2');
910 # Can't use auto incrementing
911 0 $sth->{"next_id_$table"}->execute();
912 0 $s->{$table}{$id_key} = ($sth->{"next_id_$table"}->fetchrow_array)[0];
913 0 ▶ if ($s->{$table}{$id_key}){
Branch: 1 branch
BranchTrueFalseTotal
if ($s->{$table}{$id_key}) 0 0 0
914 0 $sth->{"insert_$table"}->execute($s->{$table}{$id_key},@ids);
915 0 ▶ $sth->{"aux_insert_$table"}->execute() if $sth->{"aux_insert_$table"};
Branch: 1 branch
BranchTrueFalseTotal
if $$sth{"aux_insert_$table"} 0 0 0
916 }
917 }
918 else{
919 0 $sth->{"insert_$table"}->execute(@ids);
920 0 ▶ $s->{$table}{$id_key} = $self->insertid($sth->{"insert_$table"}) unless $s->{$table}{$id_key};
Branch: 1 branch
BranchTrueFalseTotal
unless $s->{$table}{$id_key} 0 0 0
921 0 ▶ $sth->{"aux_insert_$table"}->execute() if $sth->{"aux_insert_$table"};
Branch: 1 branch
BranchTrueFalseTotal
if $$sth{"aux_insert_$table"} 0 0 0
922 }
923 }
924 }
925  
926 0 my $id = $s->{$table}{$id_key};
927 0 ▶ unless (defined $id) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id) 0 0 0
928 0 warn "No $table id for $id_key ",$dbh->errstr," Record skipped.\n";
929 0 return;
930 }
931 0 $id;
932 }
933  
934  
935  
936 #-----------------------------------
937  
938 =head2 make_features_by_name_where_part
939  
940 Title : make_features_by_name_where_part
941 Usage : $db->make_features_by_name_where_part
942 Function: create the SQL fragment needed to select a feature by its group name & class
943 Returns : a SQL fragment and bind arguments
944 Args : see below
945 Status : Protected
946  
947 =cut
948  
949 0 ▶sub make_features_by_name_where_part {
Subroutine make_features_by_name_where_part: not called CC=2 SCAR=17.9
Pod documented
950 0 my $self = shift;
951 0 my ($class,$name) = @_;
952 0 ▶ if ($name =~ /\*/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /\*/) { } 0 0 0
953 0 $name =~ tr/*/%/;
954 0 return ("cmap_feature.gclass=? AND cmap_feature.feature_name LIKE ?",$class,$name);
955 } else {
956 0 return ("cmap_feature.gclass=? AND cmap_feature.feature_name=?",$class,$name);
957 }
958 }
959  
960 =head2 make_features_join_part
961  
962 Title : make_features_join_part
963 Usage : $string = $db->make_features_join_part()
964 Function: make join part of the features query
965 Returns : a string
966 Args : none
967 Status : protected
968  
969 This method creates the part of the features query that immediately
970 follows the WHERE keyword.
971  
972 =cut
973  
974 0 ▶sub make_features_join_part {
Subroutine make_features_join_part: not called CC=3 SCAR=24.8
Pod documented
975 0 my $self = shift;
976 0 ▶ my $options = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
977 0 ▶ return !$options->{attributes} ? <<END1 : <<END2;
Branch: 1 branch
BranchTrueFalseTotal
!$options->{'attributes'} ? : 0 0 0
978 cmap_feature.feature_id = fdata.feature_id
979 AND ftype.ftypeid = fdata.ftypeid
980 END1
981 cmap_feature.feature_id = fdata.feature_id
982 AND ftype.ftypeid = fdata.ftypeid
983 AND fattribute.fattribute_id=fattribute_to_feature.fattribute_id
984 AND fdata.fid=fattribute_to_feature.fid
985 END2
986 }
987  
988 0 ▶sub getseqcoords_query {
Subroutine getseqcoords_query: not called CC=1 SCAR=6.9
Pod undocumented
989 0 my $self = shift;
990 0 return GETSEQCOORDS ;
991 }
992  
993 0 ▶sub getaliascoords_query{
Subroutine getaliascoords_query: not called CC=1 SCAR=6.9
Pod undocumented
994 0 my $self = shift;
995 0 return GETALIASCOORDS ;
996 }
997  
998 0 ▶sub getforcedseqcoords_query{
Subroutine getforcedseqcoords_query: not called CC=1 SCAR=6.9
Pod undocumented
999 0 my $self = shift;
1000 0 return GETFORCEDSEQCOORDS ;
1001 }
1002  
1003 0 ▶sub getaliaslike_query{
Subroutine getaliaslike_query: not called CC=1 SCAR=6.9
Pod undocumented
1004 0 my $self = shift;
1005 0 return GETALIASLIKE ;
1006 }
1007  
1008 =head2 search_notes
1009  
1010 Title : search_notes
1011 Usage : @search_results = $db->search_notes("full text search string",$limit)
1012 Function: Search the notes for a text string, using mysql full-text search
1013 Returns : array of results
1014 Args : full text search string, and an optional row limit
1015 Status : public
1016  
1017 This is a mysql-specific method. Given a search string, it performs a
1018 full-text search of the notes table and returns an array of results.
1019 Each row of the returned array is a arrayref containing the following fields:
1020  
1021 column 1 A Bio::DB::GFF::Featname object, suitable for passing to segment()
1022 column 2 The text of the note
1023 column 3 A relevance score.
1024  
1025 =cut
1026  
1027 0 ▶sub search_notes {
Subroutine search_notes: not called CC=7 SCAR=40.3
Pod documented
1028 0 my $self = shift;
1029 0 my ($search_string,$limit) = @_;
1030  
1031 0 $search_string =~ tr/*?//d;
1032  
1033 0 my @words = $search_string =~ /(\w+)/g;
1034 0 my $regex = join '|',@words;
1035 0 my @searches = map {"fattribute_value LIKE '%${_}%'"} @words;
1036 0 my $search = join(' OR ',@searches);
1037  
1038 0 my $query = <<END;
1039 SELECT distinct gclass,feature_name as gname,fattribute_value
1040 FROM cmap_feature,fattribute_to_feature,fdata
1041 WHERE cmap_feature.feature_id=fdata.feature_id
1042 AND fdata.fid=fattribute_to_feature.fid
1043 END
1044 ;
1045 0 ▶ $query .= " AND ($search) " if ($search);
Branch: 1 branch
BranchTrueFalseTotal
if $search 0 0 0
1046  
1047 0 my $sth = $self->dbh->do_query($query);
1048 0 my @results;
1049 0 ▶ while (my ($class,$name,$note) = $sth->fetchrow_array) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $sth->fetchrow_array) 0 0 0
1050 0 ▶ next unless $class && $name; # sorry, ignore NULL objects
Branch: 1 branch
BranchTrueFalseTotal
unless $class and $name 0 0 0
Condition0%0/3
$class and $name
!ll&&!rl&&r
000
MC/DC0%0/2
$class and $name
$class $name
Truth table0%0/3
A and B
A= $classB= $name
ABresult
0X0
100
111
1051 0 my @matches = $note =~ /($regex)/g;
1052 0 my $relevance = 10*@matches;
1053 0 my $featname = Bio::DB::GFF::Featname->new($class=>$name);
1054 0 push @results,[$featname,$note,$relevance];
1055 0 ▶ last if $limit && @results >= $limit;
Branch: 1 branch
BranchTrueFalseTotal
if $limit and @results >= $limit 0 0 0
Condition0%0/3
$limit and @results >= $limit
!ll&&!rl&&r
000
MC/DC0%0/2
$limit and @results >= $limit
$limit @results >= $limit
Truth table0%0/3
A and B
A= $limitB= @results >= $limit
ABresult
0X0
100
111
1056 }
1057 0 @results;
1058 }
1059  
1060 # sub search_notes {
1061 # my $self = shift;
1062 # my ($search_string,$limit) = @_;
1063 # my $query = FULLTEXTSEARCH;
1064 # $query .= " limit $limit" if defined $limit;
1065 # my $sth = $self->dbh->do_query($query,$search_string,$search_string);
1066 # my @results;
1067 # while (my ($class,$name,$note,$relevance) = $sth->fetchrow_array) {
1068 # next unless $class && $name; # sorry, ignore NULL objects
1069 # $relevance = sprintf("%.2f",$relevance); # trim long floats
1070 # my $featname = Bio::DB::GFF::Featname->new($class=>$name);
1071 # push @results,[$featname,$note,$relevance];
1072 # }
1073 # @results;
1074 # }
1075  
1076 =head2 make_features_order_by_part
1077  
1078 Title : make_features_order_by_part
1079 Usage : ($query,@args) = $db->make_features_order_by_part()
1080 Function: make the ORDER BY part of the features() query
1081 Returns : a SQL fragment and bind arguments, if any
1082 Args : none
1083 Status : protected
1084  
1085 This method creates the part of the features query that immediately
1086 follows the ORDER BY part of the query issued by features() and
1087 related methods.
1088  
1089 =cut
1090  
1091 0 ▶sub make_features_order_by_part {
Subroutine make_features_order_by_part: not called CC=2 SCAR=17.9
Pod documented
1092 0 my $self = shift;
1093 0 ▶ my $options = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
1094 0 return "cmap_feature.feature_name";
1095 }
1096  
1097 =head2 create_cmap_viewer_link
1098  
1099 Title : create_cmap_viewer_link
1100 Usage : $link_str = $db->create_cmap_viewer_link(data_source=>$ds,group_id=>$gid)
1101 Function:
1102 Returns :
1103 Args :
1104 Status :
1105  
1106  
1107 =cut
1108  
1109 0 ▶sub create_cmap_viewer_link {
Subroutine create_cmap_viewer_link: not called CC=2 SCAR=17.9
Pod documented
1110 0 my $self = shift;
1111 0 my %args = @_;
1112 0 my $data_source = $args{'data_source'};
1113 0 my $gid = $args{'group_id'};
1114 0 my $link_str = undef;
1115  
1116 0 my $db = $self->features_db;
1117 0 my $sql_str = qq[
1118 select f.feature_name,
1119 f.feature_type_accession feature_type_aid,
1120 m.accession_id as map_aid,
1121 ms.accession_id as map_set_aid
1122 from cmap_feature f,
1123 cmap_map m,
1124 cmap_map_set ms
1125 where f.map_id=m.map_id
1126 and ms.map_set_id=m.map_set_id
1127 and f.feature_id=$gid
1128 ];
1129  
1130 0 my $result_ref = $db->selectrow_hashref($sql_str,{ Columns => {} });
1131
1132 0 ▶ if ( $result_ref ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result_ref) 0 0 0
1133 $link_str='/cgi-bin/cmap/viewer?ref_map_set_aid='
1134 . $result_ref->{'map_set_aid'}
1135 . '&ref_map_aids='
1136 . $result_ref->{'map_aid'}
1137 . '&data_source='
1138 . $data_source
1139 . '&highlight='
1140 .$result_ref->{'feature_name'}
1141 . '&feature_type_'
1142 0 .$result_ref->{'feature_type_aid'}
1143 . '=2';
1144 }
1145  
1146 0 return $link_str;
1147 }
1148  
1149 1 1;
1150  
1151  
1152 __END__
« GFF/RelSegment.pm ↑ Summary GFF/Adaptor/dbi/pg_fts.pm »