lib/Bio/DB/Das/Chado/Segment/Feature.pm

filter: Statementstmt 11.1% 47 / 422 Branchbran 0.0% 0 / 190 Conditioncond 0.0% 0 / 69 MC/DCmcdc 0.0% 0 / 42 Subroutinesub 20.4% 10 / 49 Podpod 100% 36 / 36 totaltotal 11.5% 93 / 808 CC 126 SCAR 57.6
CC
126
Cov
7%
sub_SeqFeature
870.0
_do_the_inferring
870.0
adjust_bounds
210.0
CRAP 317.3
↑ Summary script/gmod_chado_fts_prep.pl »
1 =head1 NAME
2  
3 Bio::DB::Das::Chado::Segment::Feature
4  
5 =head1 SYNOPSIS
6  
7 See L<Bio::DB::Das::Chado>.
8  
9 =head1 DESCRIPTION
10  
11 Not yet written
12  
13 =head1 API
14  
15 =cut
16  
17 package Bio::DB::Das::Chado::Segment::Feature;
18  
19 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Bio::DB::Das::Chado::Segment;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Bio::SeqFeatureI;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Bio::LocationI;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶use vars qw(@ISA $AUTOLOAD %CONSTANT_TAGS $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 @ISA = qw(Bio::DB::Das::Chado::Segment Bio::SeqFeatureI
32 Bio::Root::Root);
33 1 $VERSION = 0.35;
34  
35 1 %CONSTANT_TAGS = ();
36  
37 1 ▶use overload '""' => 'asString';
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 =head2 new
40  
41 Title : new
42 Usage : $f = Bio::DB::Das::Chado::Segment::Feature->new(@args);
43 Function: create a new feature object
44 Returns : new Bio::DB::Das::Chado::Segment::Feature object
45 Args : see below
46 Status : Internal
47  
48 This method is called by Bio::DB::Das::Chado::Segment to create a new
49 feature using information obtained from the chado database.
50  
51 The 11 arguments are positional:
52  
53 $factory a Bio::DB::Das::Chado adaptor object (or descendent)
54 $parent the parent feature object (if it exists)
55 $srcseq the source sequence
56 $start start of this feature
57 $stop stop of this feature
58 $type a Bio::DB::GFF::Typename (containing a method and source)
59 $score the feature's score
60 $strand this feature's strand (relative to the source
61 sequence, which has its own strandedness!)
62 $phase this feature's phase (often with respect to the
63 previous feature in a group of related features)
64 $group this feature's featureloc.locgroup (NOT a GFF holdover)
65 $uniquename this feature's internal unique database
66 name (feature.uniquename)
67 $feature_id the feature's feature_id
68  
69 This is called when creating a feature from scratch. It does not have
70 an inherited coordinate system.
71  
72 =cut
73  
74 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
75 0 my $package = shift;
76 0 my ($factory,
77 $parent,
78 $srcseq,
79 $start,$end,
80 $type,
81 $score,
82 $strand,
83 $phase,
84 $group,
85 $uniquename,
86 $feature_id) = @_;
87  
88 0 my $self = bless { },$package;
89  
90 #check that this is what you want!
91 #($start,$end) = ($end,$start) if defined($strand) and $strand == -1;
92  
93 0 $self->factory($factory);
94 0 ▶ $self->parent($parent) if $parent;
Branch: 1 branch
BranchTrueFalseTotal
if $parent 0 0 0
95 0 $self->seq_id($srcseq);
96 0 $self->start($start);
97 0 $self->end($end);
98 0 $self->score($score);
99 0 $self->strand($strand);
100 0 $self->phase($phase);
101 0 $self->type($type);
102 0 $self->group($group);
103 0 $self->uniquename($uniquename);
104 # $self->absolute($factory->absolute);
105 0 $self->absolute(1);
106  
107 0 $self->feature_id($feature_id);
108  
109 0 ▶ if ($srcseq && !$parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($srcseq and not $parent) 0 0 0
Condition0%0/3
$srcseq and not $parent
!ll&&!rl&&r
000
MC/DC0%0/2
$srcseq and not $parent
$srcseq not $parent
Truth table0%0/3
A and not(B)
A= $srcseqB= not $parent
ABresult
0X0
100
111
110 0 $parent = $factory->segment( -name => $srcseq,
111 -start=> $start,
112 -stop => $end,
113 );
114 }
115  
116 0 ▶ $self->srcfeature_id($parent->srcfeature_id() )
Branch: 1 branch
BranchTrueFalseTotal
if ref $parent and $parent->can("srcfeature_id") 0 0 0
Condition0%0/3
ref $parent and $parent->can("srcfeature_id")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $parent and $parent->can("srcfeature_id")
ref $parent $parent->can("srcfeature_id")
Truth table0%0/3
A and B
A= ref $parentB= $parent->can("srcfeature_id")
ABresult
0X0
100
111
117 if (ref $parent && $parent->can('srcfeature_id'));
118  
119 0 return $self;
120 }
121  
122 ######################################################################
123 # feature and featureloc db value slots
124 ######################################################################
125  
126 =head1 feature and featureloc accessors
127  
128 Methods below are accessors for data that is drawn directly from the
129 Chado database and can be considered "primary" accessors for this
130 class.
131  
132 =cut
133  
134 =head2 feature_id()
135  
136 Title : feature_id
137 Usage : $obj->feature_id($newval)
138 Function: holds feature.feature_id
139 Returns : value of feature_id (a scalar)
140 Args : on set, new value (a scalar or undef, optional)
141  
142 Implemented in Bio::DB::Das::Chado::Segment
143  
144 =cut
145  
146 =head2 organism
147  
148 =over
149  
150 =item Usage
151  
152 $obj->organism() #get existing value
153 $obj->organism($newval) #set new value
154  
155 =item Function
156  
157 =item Returns
158  
159 value of organism (a scalar)
160  
161 =item Arguments
162  
163 new value of organism (to set)
164  
165 =back
166  
167 =cut
168  
169 0 ▶sub organism {
Subroutine organism: not called CC=2 SCAR=17.9
Pod documented
170 0 my $self = shift;
171 0 my $organism = shift;
172 0 ▶ return $self->{'organism'} = $organism if defined($organism);
Branch: 1 branch
BranchTrueFalseTotal
if defined $organism 0 0 0
173  
174 #if it isn't passed in, we need to try to go get it
175  
176 0 my $dbh = $self->factory->dbh;
177  
178 0 my $organism_query = $dbh->prepare("
179 SELECT genus, species FROM organism WHERE organism_id IN
180 (SELECT organism_id FROM feature WHERE feature_id = ?)
181 ");
182 0 $organism_query->execute($self->feature_id);
183  
184 0 my ($genus, $species) = $organism_query->fetchrow_array;
185  
186 0 $organism_query->finish;
187 0 $self->{'organism'} = "$genus $species";
188 0 return $self->{'organism'};
189 }
190  
191  
192 =head2 group()
193  
194 Title : group
195 Usage : $group = $f->group([$new_group]);
196 Function: Returns a feature name--this is here to maintain backward
197 compatibility with GFF and gbrowse.
198 Returns : value of group (a scalar)
199 Args : on set, new value (a scalar or undef, optional)
200  
201  
202 =cut
203  
204 0 ▶sub group {
Subroutine group: not called CC=2 SCAR=17.9
Pod documented
205 0 my $self = shift;
206  
207 0 ▶ return $self->{'group'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
208 0 return $self->{'group'};
209 }
210  
211 =head2 srcfeature_id()
212  
213 Title : srcfeature_id
214 Usage : $obj->srcfeature_id($newval)
215 Function: ???
216 Returns : value of srcfeature_id (a scalar)
217 Args : on set, new value (a scalar or undef, optional)
218  
219  
220 =cut
221  
222 0 ▶sub srcfeature_id {
Subroutine srcfeature_id: not called CC=2 SCAR=17.9
Pod documented
223 0 my $self = shift;
224  
225 0 ▶ return $self->{'srcfeature_id'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
226  
227 0 my $feature_id = $self->feature_id;
228 0 my $sf_query = $self->factory->dbh->prepare("select srcfeature_id from featureloc where feature_id = ? and rank=0");
229 0 $sf_query->execute($feature_id);
230 0 my ($sf) = $sf_query->fetchrow_array;
231  
232 0 return $self->{'srcfeature_id'} = $sf;
233 }
234  
235 =head2 strand()
236  
237 Title : strand
238 Usage : $obj->strand()
239 Function: Returns the strand of the feature. Unlike the other
240 methods, the strand cannot be changed once the object is
241 created (due to coordinate considerations).
242 corresponds to featureloc.strand
243 Returns : -1, 0, or 1
244 Args : on set, new value (a scalar or undef, optional)
245  
246  
247 =cut
248  
249 0 ▶sub strand {
Subroutine strand: not called CC=3 SCAR=24.8
Pod documented
250 0 my $self = shift;
251  
252 0 ▶ return $self->{'strand'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
253 0 ▶ return $self->{'strand'} || 0;
Condition0%0/2
$self->{'strand'} || 0
l!l
00
MC/DC0%0/1
$self->{'strand'} || 0
$self->{'strand'}
Truth table0%0/2
A
A= $self->{'strand'}
Aresult
11
00
254 }
255  
256 =head2 phase
257  
258 =over
259  
260 =item Usage
261  
262 $obj->phase() #get existing value
263 $obj->phase($newval) #set new value
264  
265 =item Function
266  
267 =item Returns
268  
269 value of phase (a scalar)
270  
271 =item Arguments
272  
273 new value of phase (to set)
274  
275 =back
276  
277 =cut
278  
279 0 ▶sub phase {
Subroutine phase: not called CC=2 SCAR=17.9
Pod documented
280 0 my $self = shift;
281 0 ▶ return $self->{'phase'} = shift if defined($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] 0 0 0
282 0 return $self->{'phase'};
283 }
284  
285  
286 =head2 type()
287  
288 Title : type
289 Usage : $obj->type($newval)
290 Function: holds a Bio::DB::GFF::Typename object
291 Returns : returns a Bio::DB::GFF::Typename object
292 Args : on set, new value
293  
294 =cut
295  
296 0 ▶sub type {
Subroutine type: not called CC=2 SCAR=17.9
Pod documented
297 0 my $self = shift;
298  
299 0 ▶ return $self->{'type'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
300 0 return $self->{'type'};
301 }
302  
303 =head2 uniquename()
304  
305 Title : uniquename
306 Usage : $obj->uniquename($newval)
307 Function: holds feature.uniquename
308 Returns : value of uniquename (a scalar)
309 Args : on set, new value (a scalar or undef, optional)
310  
311 =cut
312  
313 0 ▶sub uniquename {
Subroutine uniquename: not called CC=2 SCAR=17.9
Pod documented
314 0 my $self = shift;
315  
316 0 ▶ return $self->{'uniquename'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
317 0 return $self->{'uniquename'};
318 }
319  
320 =head2 is_analysis()
321  
322 Title : is_analysis
323 Usage : $obj->is_analysis($newval)
324 Function: holds feature.is_analysis
325 Returns : value of is_analysis (a scalar)
326 Args : on set, new value (a scalar or undef, optional)
327  
328 =cut
329  
330 0 ▶sub is_analysis {
Subroutine is_analysis: not called CC=2 SCAR=17.9
Pod documented
331 0 my $self = shift;
332 0 ▶ return $self->{'is_analysis'} = shift if defined($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] 0 0 0
333  
334 0 my $dbh = $self->factory->dbh;
335 0 my $fid = $self->feature_id;
336 0 my $sth = $dbh->prepare("SELECT is_analysis FROM feature WHERE feature_id =?");
337 0 $sth->execute($fid);
338  
339 0 my ($is_analysis) = $sth->fetchrow_array;
340  
341 0 $sth->finish;
342 0 return $self->{'is_analysis'} = $is_analysis;
343 }
344  
345  
346 ######################################################################
347 # ISA Bio::SeqFeatureI
348 ######################################################################
349  
350 =head1 SeqFeatureI methods
351  
352 Bio::DB::Das::Chado::Segment::Feature implements the Bio::SeqFeatureI
353 interface. Methods described below, see Bio:SeqFeatureI for more
354 details.
355  
356 =cut
357  
358 =head2 attach_seq()
359  
360 Title : attach_seq
361 Usage : $sf->attach_seq($seq)
362 Function: Attaches a Bio::Seq object to this feature. This
363 Bio::Seq object is for the *entire* sequence: ie
364 from 1 to 10000
365 Example :
366 Returns : TRUE on success
367 Args : a Bio::PrimarySeqI compliant object
368  
369 =cut
370  
371 0 ▶sub attach_seq {
Subroutine attach_seq: not called CC=1 SCAR=6.9
Pod documented
372 0 my ($self) = @_;
373  
374 0 $self->throw_not_implemented();
375 }
376  
377 =head2 display_name()
378  
379 Title : display_name
380 Function: aliased to uniquename() for Bio::SeqFeatureI compatibility
381  
382 =cut
383  
384 1 *display_name = \&group;
385  
386 =head2 entire_seq()
387  
388 Title : entire_seq
389 Usage : $whole_seq = $sf->entire_seq()
390 Function: gives the entire sequence that this seqfeature is attached to
391 Example :
392 Returns : a Bio::PrimarySeqI compliant object, or undef if there is no
393 sequence attached
394 Args : none
395  
396  
397 =cut
398  
399 0 ▶sub entire_seq {
Subroutine entire_seq: not called CC=1 SCAR=6.9
Pod documented
400 0 my $self = shift;
401 0 $self->SUPER::seq();
402 }
403  
404 =head2 get_all_tags()
405  
406 Title : get_all_tags
407 Function: aliased to all_tags() for Bio::SeqFeatureI compatibility
408  
409 =cut
410  
411 1 *get_all_tags = \&all_tags;
412  
413 =head2 get_SeqFeatures()
414  
415 Title : get_SeqFeatures
416 Function: aliased to sub_SeqFeature() for Bio::SeqFeatureI compatibility
417  
418 =cut
419  
420 1 *get_SeqFeatures = \&sub_SeqFeature;
421  
422 =head2 get_tag_values()
423  
424 Title : get_tag_values
425 Usage : $feature->get_tag_values
426 Function: Returns values associated with a particular tag
427 Returns : A list of values
428 Args : A string (the name of the tag)
429  
430  
431 =cut
432  
433 0 ▶sub get_tag_values {
Subroutine get_tag_values: not called CC=1 SCAR=6.9
Pod documented
434 0 my $self = shift;
435 0 my $tag = shift;
436  
437 0 my @return = $self->attributes($tag);
438 0 return @return;
439 }
440  
441 =head2 get_tagset_values()
442  
443 Title : get_tagset_values
444 Usage :
445 Function: ???
446 Returns :
447 Args :
448  
449  
450 =cut
451  
452 0 ▶sub get_tagset_values {
Subroutine get_tagset_values: not called CC=1 SCAR=6.9
Pod documented
453 0 my ($self,%arg) = @_;
454  
455 0 $self->throw_not_implemented();
456 }
457  
458 =head2 gff_string()
459  
460 Title : gff_string
461 Usage :
462 Function: ???
463 Returns :
464 Args :
465  
466  
467 =cut
468  
469 0 ▶sub gff_string {
Subroutine gff_string: not called CC=5 SCAR=34.0
Pod documented
470 0 my $self = shift;
471 0 my $recurse = shift;
472 0 my $feature_id=$self->feature_id;
473  
474 0 my $gff_init_query = "SELECT ref,source,type,fstart,fend,score,strand,phase FROM gff3view WHERE feature_id=$feature_id";
475 0 my @row_ary = $self->factory->dbh->selectrow_array($gff_init_query);
476 0 my $string = join("\t",@row_ary)."\t";
477  
478 0 my $gff_atts_query = "SELECT type,attribute from gff3atts where feature_id=?";
479 0 my $sth = $self->factory->dbh->prepare($gff_atts_query);
480 0 $sth->execute($feature_id);
481  
482 0 ▶ while (my $hashref = $sth->fetchrow_hashref()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hashref = $sth->fetchrow_hashref) 0 0 0
483 0 my $attribute = uri_escape($$hashref{'attribute'});
484 0 ▶ next unless $attribute;
Branch: 1 branch
BranchTrueFalseTotal
unless $attribute 0 0 0
485 0 $string .= "$$hashref{'type'}=$attribute;";
486 }
487  
488 0 ▶ if ($recurse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recurse) 0 0 0
489 0 foreach($self->sub_SeqFeature) {
490 0 $string .= "\n";
491 0 $string .= $_->gff_string(1);
492 }
493 }
494  
495 0 return $string;
496 }
497  
498 =head2 has_tag()
499  
500 Title : has_tag
501 Usage :
502 Function: ???
503 Returns :
504 Args :
505  
506  
507 =cut
508  
509 0 ▶sub has_tag {
Subroutine has_tag: not called CC=1 SCAR=6.9
Pod documented
510 0 my $self = shift;
511 0 my $tag = shift;
512 0 my %tags = map {$_=>1} $self->all_tags;
513 0 return $tags{$tag};
514 }
515  
516 =head2 primary_tag()
517  
518 Title : primary_tag
519 Function: aliased to type() for Bio::SeqFeatureI compatibility
520  
521 =cut
522  
523 1 *primary_tag = \&method;
524  
525 =head2 seq()
526  
527 Title : seq
528 Usage :
529 Function: ???
530 Returns :
531 Args :
532  
533 =cut
534  
535 #sub seq {
536 # my ($self,%arg) = @_;
537 #
538 # $self->throw_not_implemented();
539 #}
540  
541 =head2 seq_id()
542  
543 Title : seq_id
544 Usage : $obj->seq_id($newval)
545 Function: Set or get the name of the reference sequence that the feature
546 resides on.
547 Returns : value of seq_id (a scalar)
548 Args : on set, new value (a scalar or undef, optional)
549  
550  
551 =cut
552  
553 0 ▶sub seq_id {
Subroutine seq_id: not called CC=4 SCAR=30.0
Pod documented
554 0 my $self = shift;
555  
556 0 ▶ return $self->{'seq_id'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
557 0 ▶ return $self->{'seq_id'} if defined $self->{'seq_id'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"seq_id"} 0 0 0
558  
559 #OK, no seq_id found, we'll try to find one.
560  
561 0 my $feature_id = $self->feature_id;
562 0 ▶ return unless $feature_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $feature_id 0 0 0
563  
564 0 my $query =<<END
565 SELECT COALESCE(f.name,f.uniquename) AS seq_id
566 FROM feature f join featureloc fl ON (f.feature_id = fl.srcfeature_id)
567 WHERE fl.feature_id = $feature_id AND fl.rank = 0
568 END
569 ;
570  
571 0 my ($seq_id) = $self->factory->dbh->selectrow_array($query);
572  
573 0 return $self->{'seq_id'} = $seq_id;
574 }
575  
576 ######################################################################
577 # ISA Bio::SeqFeatureI
578 ######################################################################
579  
580 =head1 Bio::RangeI methods
581  
582 Bio::SeqFeatureI in turn ISA Bio::RangeI. Bio::RangeI interface
583 methods described below, L<Bio::RangeI> for details.
584  
585 =cut
586  
587 =head2 end()
588  
589 Title : end
590 Function: inherited, L<Bio::DB::Das::Chado::Segment>
591  
592 =cut
593  
594 =head2 start()
595  
596 Title : start
597 Function: inherited, L<Bio::DB::Das::Chado::Segment>
598  
599 =cut
600  
601 =head2 strand()
602  
603 Title : strand
604 Function: inherited, L<Bio::DB::Das::Chado::Segment>
605  
606 =cut
607  
608  
609  
610 ###############################################################
611 # get/setters and their composites, alphabetical
612 ###############################################################
613  
614 =head1 other get/setters
615  
616 =cut
617  
618 =head2 abs_strand()
619  
620 Title : abs_strand
621 Usage : $obj->abs_strand($newval)
622 Function: aliased to strand() for backward compatibility
623  
624 =cut
625  
626 1 *abs_strand = \&strand;
627  
628 =head2 db_id()
629  
630 Title : db_id
631 Function: aliased to uniquename() for backward compatibility
632  
633 =cut
634  
635 1 *db_id = \&uniquename;
636  
637 =head2 factory()
638  
639 Title : factory
640 Usage : $obj->factory($newval)
641 Function: ???
642 Returns : value of factory (a scalar)
643 Args : on set, new value (a scalar or undef, optional)
644  
645  
646 =cut
647  
648 0 ▶sub factory {
Subroutine factory: not called CC=2 SCAR=17.9
Pod documented
649 0 my $self = shift;
650  
651 0 ▶ return $self->{'factory'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
652 0 return $self->{'factory'};
653 }
654  
655 =head2 id()
656  
657 Title : id
658 Function: aliased to uniquename() for backward compatibility
659  
660 =cut
661  
662 1 *id = \&uniquename;
663  
664 =head2 info()
665  
666 Title : info
667 Function: aliased to uniquename() for backward compatibility
668 with broken generic glyphs primarily
669  
670 =cut
671  
672 1 *info = \&uniquename;
673  
674 =head2 length()
675  
676 Title : length
677 Usage : $obj->length()
678 Function: convenience for end - start + 1
679 Returns : length of feature in basepairs
680 Args : none
681  
682 =cut
683  
684 0 ▶sub length {
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
685 0 my ($self) = @_;
686 0 my $len = $self->end() - $self->start() +1;
687 0 return $len;
688 }
689  
690 =head2 method()
691  
692 Title : method
693 Usage : $obj->method
694 Function: returns a Feature's method (SOFA type)
695 Returns : the Features SOFA type
696 Args : none
697  
698 =cut
699  
700 0 ▶sub method {
Subroutine method: not called CC=1 SCAR=6.9
Pod documented
701 0 my $self = shift;
702 0 return $self->type->method();
703 }
704  
705 =head2 name()
706  
707 Title : name
708 Function: aliased to group for backward compatibility
709  
710 =cut
711  
712 1 *name = \&group;
713  
714 =head2 parent()
715  
716 Title : parent
717 Usage : $obj->parent($newval)
718 Function: ???
719 Returns : value of parent (a scalar)
720 Args : on set, new value (a scalar or undef, optional)
721  
722  
723 =cut
724  
725 0 ▶sub parent {
Subroutine parent: not called CC=2 SCAR=17.9
Pod documented
726 0 my $self = shift;
727  
728 0 ▶ return $self->{'parent'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
729 0 return $self->{'parent'};
730 }
731  
732 =head2 score()
733  
734 Title : score
735 Usage : $obj->score($newval)
736 Function: holds the (alignment?) feature's score
737 Returns : value of score (a scalar)
738 Args : on set, new value (a scalar or undef, optional)
739  
740  
741 =cut
742  
743 0 ▶sub score {
Subroutine score: not called CC=2 SCAR=17.9
Pod documented
744 0 my $self = shift;
745  
746 0 ▶ return $self->{'score'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
747 0 return $self->{'score'};
748 }
749  
750 =head2 target()
751  
752 Title : target
753 Usage : $feature->target
754 Function: returns a Bio::DB::Das::Chado::Segment that corresponds
755 to the target of a similarity pair
756 Returns : a Bio::DB::Das::Chado::Segment object
757 Args : none
758  
759 =cut
760  
761 0 ▶sub target {
Subroutine target: not called CC=2 SCAR=17.9
Pod documented
762 0 my ($self) = shift;
763  
764 0 my $self_id = $self->feature_id;
765  
766 #so, we need to construct a segment that corresponds to to the
767 #target sequence. So, what do I need from chado:
768 #
769 # - the feature_id of the target (from featureloc.srcfeature_id
770 # where featureloc.rank > 0 ; when rank = 0, it corresponds
771 # to the feature's coords on the 'main' sequence)
772 # - featureloc.fmin and fmax for the target
773 # - feature.name
774  
775 0 my $query = "SELECT fl.srcfeature_id,fl.fmin,fl.fmax,f.name,f.uniquename
776 FROM featureloc fl JOIN feature f
777 ON (fl.feature_id = ? AND fl.srcfeature_id=f.feature_id)
778 WHERE fl.rank > 0";
779  
780 0 my $sth = $self->factory->dbh->prepare($query);
781 0 $sth->execute($self_id);
782  
783 # While it is theoretically possible for there to be more than
784 # on target per feature, Bio::Graphics::Browser doesn't support it
785  
786 0 my $hashref = $sth->fetchrow_hashref;
787 0 $sth->finish;
788  
789 0 ▶ if ($$hashref{'name'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hashref->{"name"}) 0 0 0
790 my $segment = Bio::DB::Das::Chado::Segment->new(
791 $$hashref{'name'},
792 $self->factory,
793 $$hashref{'fmin'}+1,
794 $$hashref{'fmax'},
795 $$hashref{'uniquename'},
796 1, #new arg to tell Segment this is a Target
797 0 $$hashref{'srcfeature_id'},
798 );
799 0 return $segment;
800 }
801 0 return; #didn't get anything
802 }
803  
804 1 *hit = \&target;
805  
806 #####################################################################
807 # other methods
808 ######################################################################
809  
810 =head1 Other methods
811  
812 =cut
813  
814 =head2 all_tags()
815  
816 Title : all_tags
817 Usage :
818 Function: ???
819 Returns :
820 Args :
821  
822  
823 =cut
824  
825 0 ▶sub all_tags {
Subroutine all_tags: not called CC=2 SCAR=17.9
Pod documented
826 0 my $self = shift;
827 0 my $feature_id = $self->feature_id;
828  
829 0 my $tag_query = $self->factory->dbh->prepare(
830 "SELECT distinct type FROM gffatts WHERE feature_id=?"
831 );
832  
833 0 $tag_query->execute($feature_id);
834  
835 0 my @tags;
836 0 ▶ while (my @tag = $tag_query->fetchrow_array) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@tag) = $tag_query->fetchrow_array) 0 0 0
837 0 push @tags, $tag[0];
838 }
839  
840 0 return @tags;
841 }
842  
843 =head2 source()
844  
845 Title : source
846 Usage : $f->source();
847 Function: caches and returns the source from a GFF file, this is stored
848 in dbxref with a db of 'GFF_Source'
849 Returns : See above
850 Args : none
851  
852 =cut
853  
854 0 ▶sub source {
Subroutine source: not called CC=1 SCAR=6.9
Pod documented
855 0 my $self = shift;
856  
857 0 return $self->type->source();
858 }
859  
860 =head2 segments()
861  
862 Title : segments
863 Function: aliased to sub_SeqFeature() for compatibility
864  
865  
866 =cut
867  
868 1 *segments = \&sub_SeqFeature;
869  
870 =head2 subfeatures
871  
872 Title : subfeatures
873 Usage : $obj->subfeatures($newval)
874 Function: returns a list of subfeatures
875 Returns : value of subfeatures (a scalar)
876 FIXME THIS SHOULD RETURN A LIST OR AN ARRAY AND BE DOCUMENTED AS SUCH
877 NOT RETURN AN ARRAYREF OR HASHREF. FOR ADDING/SETTING ELEMENTS WE
878 NEED ADD_ AND SET_ METHODS
879 Args : on set, new value (a scalar or undef, optional)
880  
881  
882 =cut
883  
884 0 ▶sub subfeatures {
Subroutine subfeatures: not called CC=2 SCAR=17.9
Pod documented
885 0 my $self = shift;
886  
887 0 ▶ return $self->{'subfeatures'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
888 0 return $self->{'subfeatures'};
889 }
890  
891  
892 =head2 sub_SeqFeature()
893  
894 Title : sub_SeqFeature
895 Usage : @feat = $feature->sub_SeqFeature([$type])
896 Function: This method returns a list of any subfeatures
897 that belong to the main feature. For those
898 features that contain heterogeneous subfeatures,
899 you can retrieve a subset of the subfeatures by
900 providing an array of types to filter on.
901  
902 For AcePerl compatibility, this method may also
903 be called as segments().
904 Returns : a list of Bio::DB::Das::Chado::Segment::Feature objects
905 Args : a feature method (optional)
906 Status : Public
907  
908 =cut
909  
910 0 ▶sub sub_SeqFeature {
Subroutine sub_SeqFeature: not called CC=29 SCAR=67.7
Pod documented
911 0 my($self,@type) = @_;
912  
913 0 my @features;
914  
915 #warn "starting subfeatures";
916  
917 #first call, cache subfeatures
918 #Bio::SeqFeature::CollectionI?
919 #like SeqFeature::Generic?
920  
921 # if(!$self->subfeatures ){
922  
923 0 my $parent_id = $self->feature_id();
924 0 my $inferCDS = $self->factory->inferCDS;
925  
926 #warn "inferCDS:$inferCDS";
927  
928 ##URGI - We get the reference_class feature_id to filter out the sub_features results
929 0 ▶ my $refclass_feature_id = $self->factory->refclass_feature_id() || undef;
Condition0%0/2
$self->factory->refclass_feature_id || undef
l!l
00
MC/DC0%0/1
$self->factory->refclass_feature_id || undef
$self->factory->refclass_feature_id
Truth table0%0/2
A
A= $self->factory->refclass_feature_id
Aresult
11
00
930 0 my($join_part, $where_part);
931 0 ▶ if(defined($refclass_feature_id)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $refclass_feature_id) 0 0 0
932 0 $join_part = " inner join featureloc as parentloc on (parent.feature_id = parentloc.feature_id) ";
933 0 $where_part = "and childloc.srcfeature_id = $refclass_feature_id and parentloc.srcfeature_id = $refclass_feature_id ";
934 }
935  
936 0 my $typewhere = '';
937  
938 0 ▶ if (@type > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@type > 0) 0 0 0
939 0 my @id_list = map { $self->factory->name2term($_) } @type;
940  
941  
942 # if CDS features were requested, and inferCDS is set, add
943 # polypeptide and exon features to the list so they can be fetched too
944 0 ▶ if ($inferCDS && grep {'CDS|UTR'} @type ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inferCDS and grep {"CDS|UTR";} @type) 0 0 0
Condition0%0/3
$inferCDS and grep {"CDS|UTR";} @type
!ll&&!rl&&r
000
MC/DC0%0/2
$inferCDS and grep {"CDS|UTR";} @type
$inferCDS grep {"CDS|UTR";} @type
Truth table0%0/3
A and B
A= $inferCDSB= grep {"CDS|UTR";} @type
ABresult
0X0
100
111
945 #warn "adding exon and polypeptide to type list\n";
946 0 push @id_list,
947 ( $self->factory->name2term('exon'),
948 $self->factory->name2term('polypeptide') );
949 }
950  
951 0 $typewhere = " and child.type_id in (". join(',',@id_list) .")" ;
952  
953 #warn $typewhere;
954  
955 0 warn "type:@type, type_id:@id_list" if DEBUG;
956 }
957  
958 0 my $handle = $self->factory->dbh();
959  
960 #$self->factory->dbh->trace(2) if DEBUG;
961  
962 0 my $partof = $self->factory->name2term('part_of');
963 0 my $derivesfrom = $self->factory->name2term('derives_from');
964 0 ▶ $self->throw("part_of cvterm wasn't found. is DB sane?") unless $partof;
Branch: 1 branch
BranchTrueFalseTotal
unless $partof 0 0 0
965 0 ▶ $partof = join ',', @$partof if ref($partof) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $partof eq "ARRAY" 0 0 0
966 0 ▶ $derivesfrom = join ',', @$derivesfrom if ref($derivesfrom) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $derivesfrom eq "ARRAY" 0 0 0
967 0 $partof .= ",$derivesfrom";
968  
969 #deal with Tripal oddness
970 0 my $analsysfeature_part ='';
971 0 my $score_part = 0;
972 0 ▶ unless ($self->factory->tripal()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->factory->tripal) 0 0 0
973 0 $analsysfeature_part = <<END
974 left join
975 analysisfeature as af on
976 (child.feature_id = af.feature_id)
977 END
978 ;
979 0 $score_part = 'COALESCE(af.significance,af.identity,af.normscore,af.rawscore)';
980 }
981  
982 0 warn "partof = $partof" if DEBUG;
983  
984 #silencing unit warnings
985 0 ▶ $typewhere ||='';
Condition0%0/2
$typewhere ||= ""
l!l
00
MC/DC0%0/1
$typewhere ||= ""
$typewhere
Truth table0%0/2
A
A= $typewhere
Aresult
11
00
986 0 ▶ $where_part ||='';
Condition0%0/2
$where_part ||= ""
l!l
00
MC/DC0%0/1
$where_part ||= ""
$where_part
Truth table0%0/2
A
A= $where_part
Aresult
11
00
987 0 ▶ $join_part ||='';
Condition0%0/2
$join_part ||= ""
l!l
00
MC/DC0%0/1
$join_part ||= ""
$join_part
Truth table0%0/2
A
A= $join_part
Aresult
11
00
988  
989 0 my $sql = "
990 select child.feature_id, child.name, child.type_id, child.uniquename, parent.name as pname, child.is_obsolete,
991 childloc.fmin, childloc.fmax, childloc.strand, childloc.locgroup, childloc.phase, $score_part as score,
992 childloc.srcfeature_id
993 from feature as parent
994 inner join
995 feature_relationship as fr0 on
996 (parent.feature_id = fr0.object_id)
997 inner join
998 feature as child on
999 (child.feature_id = fr0.subject_id)
1000 inner join
1001 featureloc as childloc on
1002 (child.feature_id = childloc.feature_id)
1003 $analsysfeature_part
1004 $join_part
1005 where parent.feature_id = $parent_id
1006 and childloc.rank = 0
1007 and fr0.type_id in ($partof)
1008 $where_part
1009 $typewhere
1010 ";
1011  
1012 #Recursive Mapping
1013 #Construct a query that recursively maps clone's features on the underlying chromosome
1014 0 ▶ if ($self->factory->recursivMapping){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->factory->recursivMapping) 0 0 0
1015  
1016 #Notes on the interbase computation :
1017 #$self->start is already converted to base coordinates, so we need to substract the unit which has been added by this conversion
1018 0 $sql="
1019 select child.feature_id, child.name, child.type_id, child.uniquename, parent.name as pname,child.is_obsolete,
1020 (childloc.fmin + ".$self->start." - parentloc.fmin -1) AS fmin,
1021 (childloc.fmax + ".$self->start." - parentloc.fmin -1) AS fmax,
1022 (childloc.strand * ".$self->strand." * parentloc.strand) AS strand,
1023 childloc.locgroup, childloc.phase, af.significance as score,
1024 CASE WHEN (
1025 parentloc.srcfeature_id=
1026 (select distinct srcfeature_id from featureloc where feature_id=".$self->feature_id." and rank=0)
1027 )
1028 THEN ".$self->srcfeature_id."
1029 ELSE childloc.srcfeature_id END as srcfeature_id
1030 from feature as parent
1031 inner join
1032 feature_relationship as fr0 on
1033 (parent.feature_id = fr0.object_id)
1034 inner join
1035 feature as child on
1036 (child.feature_id = fr0.subject_id)
1037 inner join
1038 featureloc as childloc on
1039 (child.feature_id = childloc.feature_id)
1040 inner join
1041 featureloc as parentloc on
1042 (parent.feature_id = parentloc.feature_id)
1043 $analsysfeature_part
1044 where parent.feature_id = $parent_id
1045 and childloc.rank = 0
1046 and fr0.type_id in ($partof)
1047 $where_part
1048 $typewhere";
1049 }
1050  
1051 #END Recursive Mapping
1052  
1053 0 $sql =~ s/\s+/ /gs if DEBUG;
1054 0 warn $sql if DEBUG;
1055  
1056 0 my $subfeature_query = $self->factory->dbh->prepare($sql);
1057 0 ▶ $subfeature_query->execute
Branch: 1 branch
BranchTrueFalseTotal
$subfeature_query->execute or $self->throw("subfeature query failed; here's the sql:$sql") 0 0 0
1058 or $self->throw("subfeature query failed; here's the sql:$sql");
1059  
1060 #$self->factory->dbh->trace(0) if DEBUG;
1061  
1062 0 my $rows = $subfeature_query->rows;
1063 0 ▶ ($subfeature_query->finish && return)
Branch: 1 branch
BranchTrueFalseTotal
if $rows < 1 0 0 0
Condition0%0/5
$rows < 1 && ($subfeature_query->finish && (return))
!ll&&!rl&&r
000
$subfeature_query->finish and return
!ll
00
MC/DC0%0/2
$rows < 1 && ($subfeature_query->finish && (return))
$rows < 1 $subfeature_query->finish
Truth table0%0/3
A && B
A= $rows < 1B= $subfeature_query->finish
ABresult
0X0
100
111
1064 if ($rows<1); #nothing retrieve during query
1065  
1066 0 my @p_e_cache;
1067 0 ▶ while (my $hashref = $subfeature_query->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hashref = $subfeature_query->fetchrow_hashref) 0 0 0
1068  
1069 0 ▶ next if ($$hashref{is_obsolete} and !$self->factory->allow_obsolete);
Branch: 1 branch
BranchTrueFalseTotal
if $hashref->{"is_obsolete"} and not $self->factory->allow_obsolete 0 0 0
Condition0%0/3
$hashref->{"is_obsolete"} and not $self->factory->allow_obsolete
!ll&&!rl&&r
000
MC/DC0%0/2
$hashref->{"is_obsolete"} and not $self->factory->allow_obsolete
$hashref->{"is_obsolete"} not $self->factory->allow_obsolete
Truth table0%0/3
A and not(B)
A= $hashref->{"is_obsolete"}B= not $self->factory->allow_obsolete
ABresult
0X0
100
111
1070 0 ▶ next unless $$hashref{srcfeature_id} == $self->srcfeature_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $hashref->{"srcfeature_id"} == $self->srcfeature_id 0 0 0
1071  
1072 # this problem can't be solved this way--group really needs to return 'name'
1073 # in order for the adaptor to work with gbrowse
1074 # next unless $$hashref{locgroup} eq $self->group; #look out, subfeatures may reside on other segments
1075  
1076 0 my $stop = $$hashref{fmax};
1077 0 my $interbase_start = $$hashref{fmin};
1078 0 my $base_start = $interbase_start +1;
1079  
1080 0 my $source_query = $self->factory->dbh->prepare("
1081 select d.accession from dbxref d,feature_dbxref fd
1082 where fd.feature_id = ? and
1083 fd.dbxref_id = d.dbxref_id and
1084 d.db_id = ?");
1085 0 $source_query->execute($$hashref{feature_id}, $self->factory->gff_source_db_id);
1086  
1087 0 my ($source) = $source_query->fetchrow_array;
1088 my $type_obj = Bio::DB::GFF::Typename->new(
1089 0 $self->factory->term2name($$hashref{type_id}),
1090 $source
1091 );
1092 0 $source_query->finish;
1093  
1094 0 warn "creating new subfeat, $$hashref{name}, $base_start, $stop, $$hashref{phase}" if DEBUG;
1095  
1096 my $feat = Bio::DB::Das::Chado::Segment::Feature->new (
1097 $self->factory,
1098 $self,
1099 $self->ref,
1100 $base_start,$stop,
1101 $type_obj,
1102 $$hashref{score},
1103 $$hashref{strand},
1104 $$hashref{phase},
1105 $$hashref{name},
1106 $$hashref{uniquename},
1107 $$hashref{feature_id}
1108 0 );
1109 0 push @features, $feat;
1110  
1111 0 ▶ if ($inferCDS && ($feat->type =~ /exon/ or $feat->type =~ /polypeptide/ )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inferCDS and $feat->type =~ /exon/ || $feat->type =~ /polypeptide/) 0 0 0
Condition0%0/6
$inferCDS and $feat->type =~ /exon/ || $feat->type =~ /polypeptide/
!ll&&!rl&&r
000
$feat->type =~ /exon/ or $feat->type =~ /polypeptide/
l!l&&r!l&&!r
000
MC/DC0%0/3
$inferCDS and $feat->type =~ /exon/ || $feat->type =~ /polypeptide/
$inferCDS $feat->type =~ /exon/ $feat->type =~ /polypeptide/
Truth table0%0/4
A and B or C
A= $inferCDSB= $feat->type =~ /exon/C= $feat->type =~ /polypeptide/
ABCresult
0XX0
1000
11X1
1011
1112 #saving an object to an array saves a reference to the object--
1113 #we don't want that, so we have to use the clone method to make a copy
1114 0 push @p_e_cache, $feat->clone;
1115 }
1116 }
1117  
1118 0 $subfeature_query->finish;
1119 #now deal with converting polypeptide and exons to CDS
1120  
1121 my @cds_utr_features
1122 0 ▶ = $self->_do_the_inferring(@p_e_cache) if (@p_e_cache > 0);
Branch: 1 branch
BranchTrueFalseTotal
if @p_e_cache > 0 0 0 0
1123 0 push @features, @cds_utr_features;
1124
1125 #this shouldn't be necessary, as filtering took place via the query
1126 #except that is now that infering of CDS features is a possibility
1127  
1128 0 ▶ if(@type && $inferCDS){
Branch: 1 branch
BranchTrueFalseTotal
if (@type and $inferCDS) 0 0 0
Condition0%0/3
@type and $inferCDS
!ll&&!rl&&r
000
MC/DC0%0/2
@type and $inferCDS
@type $inferCDS
Truth table0%0/3
A and B
A= @typeB= $inferCDS
ABresult
0X0
100
111
1129 0 my @ok_feats;
1130
1131 0 my $type_str = join("|", @type);
1132 0 for my $feat (@features) {
1133 0 ▶ if ($feat->method =~ /$type_str/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feat->method =~ /$type_str/) 0 0 0
1134 0 push @ok_feats, $feat;
1135 }
1136 }
1137 0 warn @ok_feats if DEBUG;
1138 0 return @ok_feats;
1139 }
1140
1141 =item Argh...! DONT DROP THE PROTEIN FEATURE
1142  
1143 dgg: polypeptide or protein is a most important feature, don't drop it!
1144
1145 This is the part of a gene that has lots of attached critical info:
1146 protein ID, translation, GO terms, Dbxrefs to other proteins)
1147 While this exclusion fixes a display bug, e.g. Glyph/processed_transcript
1148 it is much less problematic to patch the glyph displayers.
1149
1150 elsif ( 0 && $inferCDS) {
1151 #just remove polypeptide features
1152 my @ok_feats = grep {$_->type->method ne 'polypeptide'} @features;
1153 warn @ok_feats if DEBUG;
1154 return @ok_feats;
1155 }
1156
1157 =cut
1158  
1159 0 return @features;
1160 }
1161  
1162 =head2 _do_the_inferring
1163  
1164 =over
1165  
1166 =item Usage
1167  
1168 $obj->_do_the_inferring(@features)
1169  
1170 =item Function
1171  
1172 Takes a list of polypeptide and exon features and infers CDS and UTR
1173 features from them.
1174  
1175 =item Returns
1176  
1177 A list of CDS and UTR features
1178  
1179 =item Arguments
1180  
1181 A list of polypeptide and exon features
1182  
1183 =item Caveats
1184  
1185 This function will break with polycistronic genes, as there
1186 will be more than one polypeptide per set of exons, and this
1187 function assumes that there is only one.
1188  
1189 =back
1190  
1191 =cut
1192  
1193 0 ▶sub _do_the_inferring {
Subroutine _do_the_inferring: not called CC=29 SCAR=67.7
1194 0 my ($self, @p_e_feats) = @_;
1195  
1196 #get the polypeptide at the top of the list
1197 #and get the exons in translation order
1198 my @sorted = sort {
1199 0 ▶ $b->type cmp $a->type
Condition0%0/3
$b->type cmp $a->type || $a->start * $a->strand <=> $b->start * $b->strand
l!l&&r!l&&!r
000
MC/DC0%0/2
$b->type cmp $a->type || $a->start * $a->strand <=> $b->start * $b->strand
$b->type cmp $a->type $a->start * $a->strand <=> $b->start * $b->strand
Truth table0%0/3
A || B
A= $b->type cmp $a->typeB= $a->start * $a->strand <=> $b->start * $b->strand
ABresult
1X1
011
000
1200 || $a->start * $a->strand <=> $b->start * $b->strand
1201 } @p_e_feats;
1202  
1203 0 my ($start,$stop);
1204 0 my $poly = shift @sorted;
1205  
1206 0 ▶ if ($poly->type->method =~ /poly/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($poly->type->method =~ /poly/) { } 0 0 0
1207 0 $start = $poly->start;
1208 0 $stop = $poly->end;
1209 }
1210 else {
1211 #if there's no polypeptide feature, there's no point in continuing
1212 0 return;
1213 }
1214  
1215 0 warn "poly:$poly,start:$start, stop:$stop" if DEBUG;
1216 0 warn $poly->start if DEBUG;
1217 0 warn $poly->end if DEBUG;
1218  
1219  
1220 #keep two arrays: one with exons that are coding, one noncoding
1221 0 my @coding_array;
1222 my @noncoding_array;
1223 0 ▶ for (my $i=0; $i < scalar @sorted; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @sorted) 0 0 0
1224 0 my $feat = $sorted[$i];
1225  
1226 0 ▶ if ($feat->start < $start and $feat->end < $start) {
Branch: 3 branches
BranchTrueFalseTotal
if ($feat->start < $start and $feat->end < $start) { } 0 0 0
elsif ($feat->start > $stop and $feat->end > $stop) { } 0 0 0
elsif ($feat->start >= $start and $feat->end <= $stop) { } 0 0 0
Condition0%0/3
$feat->start < $start and $feat->end < $start
!ll&&!rl&&r
000
MC/DC0%0/2
$feat->start < $start and $feat->end < $start
$feat->start < $start $feat->end < $start
Truth table0%0/3
A and B
A= $feat->start < $startB= $feat->end < $start
ABresult
0X0
100
111
1227 #this is a 'left' utr
1228 0 ▶ if ( $feat->strand ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feat->strand) { } 0 0 0
1229 0 ▶ if ( $feat->strand > 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($feat->strand > 0) { } 0 0 0
elsif ($feat->strand < 0) { } 0 0 0
1230 0 $feat->type->method('five_prime_UTR');
1231 }
1232 elsif ( $feat->strand < 0 ) {
1233 0 $feat->type->method('three_prime_UTR');
1234 }
1235 }
1236 else {
1237 0 $feat->type->method('UTR');
1238 }
1239 0 push @noncoding_array, $feat;
1240 }
1241 ▶ elsif ($feat->start > $stop and $feat->end > $stop) {
Condition0%0/3
$feat->start > $stop and $feat->end > $stop
!ll&&!rl&&r
000
MC/DC0%0/2
$feat->start > $stop and $feat->end > $stop
$feat->start > $stop $feat->end > $stop
Truth table0%0/3
A and B
A= $feat->start > $stopB= $feat->end > $stop
ABresult
0X0
100
111
1242 #this is a 'right' utr
1243 0 ▶ if ( $feat->strand ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($feat->strand) { } 0 0 0
1244 0 ▶ if ( $feat->strand > 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($feat->strand > 0) { } 0 0 0
elsif ($feat->strand < 0) { } 0 0 0
1245 0 $feat->type->method('three_prime_UTR');
1246 }
1247 elsif ( $feat->strand < 0 ) {
1248 0 $feat->type->method('five_prime_UTR');
1249 }
1250 }
1251 else {
1252 0 $feat->type->method('UTR');
1253 }
1254 0 push @noncoding_array, $feat;
1255 }
1256 ▶ elsif ($feat->start >= $start and $feat->end <= $stop) {
Condition0%0/3
$feat->start >= $start and $feat->end <= $stop
!ll&&!rl&&r
000
MC/DC0%0/2
$feat->start >= $start and $feat->end <= $stop
$feat->start >= $start $feat->end <= $stop
Truth table0%0/3
A and B
A= $feat->start >= $startB= $feat->end <= $stop
ABresult
0X0
100
111
1257 #this is an 'internal' cds
1258 0 $feat->type->method('CDS');
1259 0 push @coding_array, $feat;
1260 }
1261 else {
1262 #this exon needs to be split into two features (CDS & UTR)
1263 0 my $utr = $feat->clone;
1264 #check for left utr/CDS split
1265 0 ▶ if ( $feat->start < $start and $feat->end >= $start ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($feat->start < $start and $feat->end >= $start) { } 0 0 0
elsif ($feat->start >= $start and $feat->end > $stop) { } 0 0 0
Condition0%0/3
$feat->start < $start and $feat->end >= $start
!ll&&!rl&&r
000
MC/DC0%0/2
$feat->start < $start and $feat->end >= $start
$feat->start < $start $feat->end >= $start
Truth table0%0/3
A and B
A= $feat->start < $startB= $feat->end >= $start
ABresult
0X0
100
111
1266 #this on stradles the left end
1267 0 ▶ if ( $utr->strand ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utr->strand) { } 0 0 0
1268 0 ▶ if ( $utr->strand > 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($utr->strand > 0) { } 0 0 0
elsif ($utr->strand < 0) { } 0 0 0
1269 0 $utr->type->method('five_prime_UTR');
1270 }
1271 elsif ( $utr->strand < 0 ) {
1272 0 $utr->type->method('three_prime_UTR');
1273 }
1274 }
1275 else {
1276 0 $utr->type->method('UTR');
1277 }
1278 0 $utr->end($start -1);
1279  
1280 0 $feat->type->method('CDS');
1281 0 $feat->start($start);
1282 }
1283 ▶ elsif ( $feat->start >= $start and $feat->end > $stop ) {
Condition0%0/3
$feat->start >= $start and $feat->end > $stop
!ll&&!rl&&r
000
MC/DC0%0/2
$feat->start >= $start and $feat->end > $stop
$feat->start >= $start $feat->end > $stop
Truth table0%0/3
A and B
A= $feat->start >= $startB= $feat->end > $stop
ABresult
0X0
100
111
1284 #this one stradles the right end
1285 0 ▶ if ( $utr->strand ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($utr->strand) { } 0 0 0
1286 0 ▶ if ( $feat->strand > 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($feat->strand > 0) { } 0 0 0
elsif ($feat->strand < 0) { } 0 0 0
1287 0 $utr->type->method('three_prime_UTR');
1288 }
1289 elsif ( $feat->strand < 0 ) {
1290 0 $utr->type->method('five_prime_UTR');
1291 }
1292 }
1293 else {
1294 0 $utr->type->method('UTR');
1295 }
1296 0 $utr->start($stop+1);
1297
1298 0 $feat->type->method('CDS');
1299 0 $feat->end($stop);
1300 }
1301 else {
1302 0 warn "this should never happen";
1303 }
1304 0 push @noncoding_array, $utr;
1305 0 push @coding_array, $feat;
1306 }
1307 }
1308  
1309 0 ▶ return unless (@coding_array > 0 or @noncoding_array > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless @coding_array > 0 or @noncoding_array > 0 0 0 0
Condition0%0/3
@coding_array > 0 or @noncoding_array > 0
l!l&&r!l&&!r
000
MC/DC0%0/2
@coding_array > 0 or @noncoding_array > 0
@coding_array > 0 @noncoding_array > 0
Truth table0%0/3
A or B
A= @coding_array > 0B= @noncoding_array > 0
ABresult
1X1
011
000
1310  
1311 0 my @features;
1312 0 ▶ if (defined $coding_array[0]->phase) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $coding_array[0]->phase) { } 0 0 0
1313 0 push @features, @coding_array;
1314 }
1315 else {
1316 0 push @features, $self->_calc_phases(@coding_array);
1317 }
1318  
1319 0 push @features, @noncoding_array;
1320  
1321 0 return @features;
1322 }
1323  
1324  
1325 =head2 _calc_phases
1326  
1327 Title : _calc_phases
1328 Usage : $feature->_calc_phases(@exons)
1329 Function: calculstes phases for exons without phases
1330 Returns : a list of exon feature objects with phases
1331 Args : a list of sorted (by transcription order) exons
1332 Status : private
1333  
1334 =cut
1335  
1336 0 ▶sub _calc_phases {
Subroutine _calc_phases: not called CC=3 SCAR=24.8
1337 0 my $self = shift;
1338 0 my @exons = @_;
1339  
1340 # L0 is length of the first segment measured from the start site
1341 # Li is length of the current segment measured from its splice start
1342 # P0 is the phase of the first segment, always 0
1343 # Pi is the phase of the current segment
1344 # P(i+1) = 3 - (Li - Pi) mod 3
1345  
1346 0 $exons[0]->phase(0);
1347  
1348 0 ▶ for (my $i = 0; $i < (scalar @exons) -1; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar(@exons) - 1) 0 0 0
1349 0 ▶ next unless defined $exons[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $exons[$i] 0 0 0
1350 0 my $phase = (3 - ($exons[$i]->length - $exons[$i]->phase) % 3) % 3;
1351 0 $exons[$i+1]->phase($phase);
1352  
1353 0 warn $exons[$i]->parent." ".$exons[$i]." ".$exons[$i]->start." ".$exons[$i]->phase." ".$exons[$i+1]->phase() if DEBUG;
1354 }
1355  
1356 0 return @exons;
1357 }
1358  
1359  
1360 =head2 notes
1361  
1362 Title : notes
1363 Usage : @notes = $feature->notes
1364 Function: get the "notes" on a particular feature
1365 Returns : an array of string
1366 Args : feature ID
1367 Status : public
1368  
1369 =cut
1370  
1371 0 ▶sub notes {
Subroutine notes: not called CC=1 SCAR=6.9
Pod documented
1372 0 my $self = shift;
1373 0 $self->attributes('Note');
1374 }
1375  
1376  
1377 =head2 add_subfeature()
1378  
1379 Title : add_subfeature
1380 Usage : $feature->add_subfeature($feature)
1381 Function: This method adds a new subfeature to the object.
1382 It is used internally by aggregators, but is
1383 available for public use as well.
1384 Returns : nothing
1385 Args : a Bio::DB::Das::Chado::Segment::Feature object
1386 Status : Public
1387  
1388  
1389 =cut
1390  
1391 0 ▶sub add_subfeature {
Subroutine add_subfeature: not called CC=3 SCAR=24.8
Pod documented
1392 0 my $self = shift;
1393 0 my $subfeature = shift;
1394  
1395 # warn "in add_subfeat:$subfeature";
1396  
1397 0 ▶ return undef unless ref($subfeature);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $subfeature 0 0 0
1398 0 ▶ return undef unless $subfeature->isa('Bio::DB::Das::Chado::Segment::Feature');
Branch: 1 branch
BranchTrueFalseTotal
unless $subfeature->isa("Bio::DB::Das::Chado::Segment::Feature") 0 0 0
1399  
1400 0 push @{$self->{subfeatures}}, $subfeature;
1401 0 return $subfeature;
1402 }
1403  
1404 =head2 location()
1405  
1406 Title : location
1407 Usage : my $location = $seqfeature->location()
1408 Function: returns a location object suitable for identifying location
1409 of feature on sequence or parent feature
1410 Returns : Bio::LocationI object
1411 Args : none
1412  
1413 =cut
1414  
1415 0 ▶sub location {
Subroutine location: not called CC=5 SCAR=34.0
Pod documented
1416 0 my $self = shift;
1417 0 ▶ require Bio::Location::Split unless Bio::Location::Split->can('new');
Branch: 1 branch
BranchTrueFalseTotal
unless "Bio::Location::Split"->can("new") 0 0 0
1418 0 ▶ require Bio::Location::Simple unless Bio::Location::Simple->can('new');
Branch: 1 branch
BranchTrueFalseTotal
unless "Bio::Location::Simple"->can("new") 0 0 0
1419  
1420 0 my $location;
1421 0 ▶ if (my @segments = $self->sub_SeqFeature) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@segments) = $self->sub_SeqFeature) { } 0 0 0
1422 0 $location = Bio::Location::Split->new(-seq_id => $self->seq_id);
1423 0 foreach (@segments) {
1424 0 $location->add_sub_Location($_->location);
1425 }
1426 } else {
1427 0 $location = Bio::Location::Simple->new(-start => $self->start,
1428 -end => $self->stop,
1429 -strand => $self->strand,
1430 -seq_id => $self->seq_id);
1431 }
1432 0 $location;
1433 }
1434  
1435 1 *merged_segments = \&sub_SeqFeature;
1436  
1437 =head2 clone()
1438  
1439 Title : clone
1440 Usage : $feature = $f->clone
1441 Function: make a copy of the feature
1442 Returns : a new Bio::DB::Das::Chado::Segment::Feature object
1443 Args : none
1444 Status : Public
1445  
1446 This method returns a copy of the feature.
1447  
1448 =cut
1449  
1450 0 ▶sub clone {
Subroutine clone: not called CC=6 SCAR=37.4
Pod documented
1451 0 my $self = shift;
1452 0 my $clone = $self->SUPER::clone;
1453  
1454 0 ▶ if (ref(my $t = $clone->type)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref(my $t = $clone->type)) 0 0 0
1455 0 ▶ my $type = $t->can('clone') ? $t->clone : bless {%$t},ref $t;
Branch: 1 branch
BranchTrueFalseTotal
$t->can('clone') ? : 0 0 0
1456 0 $clone->type($type);
1457 }
1458  
1459 0 ▶ if (ref(my $g = $clone->group)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref(my $g = $clone->group)) 0 0 0
1460 0 ▶ my $group = $g->can('clone') ? $g->clone : bless {%$g},ref $g;
Branch: 1 branch
BranchTrueFalseTotal
$g->can('clone') ? : 0 0 0
1461 0 $clone->group($group);
1462 }
1463  
1464 0 ▶ if (my $merged = $self->{merged_segs}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $merged = $self->{"merged_segs"}) 0 0 0
1465 0 $clone->{merged_segs} = { %$merged };
1466 }
1467  
1468 0 $clone;
1469 }
1470  
1471  
1472 =head2 sub_types()
1473  
1474 Title : sub_types
1475 Usage : @methods = $feature->sub_types
1476 Function: get methods of all sub-seqfeatures
1477 Returns : a list of method names
1478 Args : none
1479 Status : Public
1480  
1481 For those features that contain subfeatures, this method will return a
1482 unique list of method names of those subfeatures, suitable for use
1483 with sub_SeqFeature().
1484  
1485 =cut
1486  
1487 0 ▶sub sub_types {
Subroutine sub_types: not called CC=2 SCAR=17.9
Pod documented
1488 0 my $self = shift;
1489 0 $self->warn("this method appears to be broken, check subfeatures() return value");
1490 0 ▶ my $subfeat = $self->subfeatures or return;
Branch: 1 branch
BranchTrueFalseTotal
my $subfeat = $self->subfeatures or return 0 0 0
1491 0 return keys %$subfeat;
1492 }
1493  
1494 =head2 Autogenerated Methods
1495  
1496 Title : AUTOLOAD
1497 Usage : @subfeat = $feature->Method
1498 Function: Return subfeatures using autogenerated methods
1499 Returns : a list of Bio::DB::Das::Chado::Segment::Feature objects
1500 Args : none
1501 Status : Public
1502  
1503 Any method that begins with an initial capital letter will be passed
1504 to AUTOLOAD and treated as a call to sub_SeqFeature with the method
1505 name used as the method argument. For instance, this call:
1506  
1507 @exons = $feature->Exon;
1508  
1509 is equivalent to this call:
1510  
1511 @exons = $feature->sub_SeqFeature('exon');
1512  
1513 =cut
1514  
1515 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
1516 0 my($pack,$func_name) = $AUTOLOAD=~/(.+)::([^:]+)$/;
1517 0 my $sub = $AUTOLOAD;
1518 0 my $self = $_[0];
1519  
1520 # ignore DESTROY calls
1521 0 ▶ return if $func_name eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $func_name eq "DESTROY" 0 0 0
1522  
1523 # fetch subfeatures if func_name has an initial cap
1524 #return sort {$a->start <=> $b->start} $self->sub_SeqFeature($func_name) if $func_name =~ /^[A-Z]/;
1525 0 ▶ return $self->sub_SeqFeature($func_name) if $func_name =~ /^[A-Z]/;
Branch: 1 branch
BranchTrueFalseTotal
if $func_name =~ /^[A-Z]/ 0 0 0
1526  
1527 # error message of last resort
1528 #$self->throw(qq(Can't locate object method "$func_name" via package "$pack"));
1529 }
1530  
1531 =head2 adjust_bounds()
1532  
1533 Title : adjust_bounds
1534 Usage : $feature->adjust_bounds
1535 Function: adjust the bounds of a feature
1536 Returns : ($start,$stop,$strand)
1537 Args : none
1538 Status : Public
1539  
1540 This method adjusts the boundaries of the feature to enclose all its
1541 subfeatures. It returns the new start, stop and strand of the
1542 enclosing feature.
1543  
1544 =cut
1545  
1546 # adjust a feature so that its boundaries are synched with its subparts' boundaries.
1547 # this works recursively, so subfeatures can contain other features
1548 0 ▶sub adjust_bounds {
Subroutine adjust_bounds: not called CC=14 SCAR=53.5
Pod documented
1549 0 my $self = shift;
1550 0 my $g = $self->{group};
1551  
1552 0 $self->warn("this method appears to be broken, check subfeatures() return value");
1553  
1554 0 ▶ if (my $subfeat = $self->subfeatures) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $subfeat = $self->subfeatures) 0 0 0
1555 0 for my $list (values %$subfeat) {
1556 0 for my $feat (@$list) {
1557  
1558 # fix up our bounds to hold largest subfeature
1559 0 my($start,$stop,$strand) = $feat->adjust_bounds;
1560 0 ▶ $self->{strand} = $strand unless defined $self->{strand};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"strand"} 0 0 0
1561 0 ▶ if ($start <= $stop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start <= $stop) { } 0 0 0
1562 0 ▶ $self->{start} = $start if !defined($self->{start}) || $start < $self->{start};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->{"start"} or $start < $self->{"start"} 0 0 0
Condition0%0/3
not defined $self->{"start"} or $start < $self->{"start"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"start"} or $start < $self->{"start"}
not defined $self->{"start"} $start < $self->{"start"}
Truth table0%0/3
not(A) or B
A= not defined $self->{"start"}B= $start < $self->{"start"}
ABresult
1X1
011
000
1563 0 ▶ $self->{stop} = $stop if !defined($self->{stop}) || $stop > $self->{stop};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->{"stop"} or $stop > $self->{"stop"} 0 0 0
Condition0%0/3
not defined $self->{"stop"} or $stop > $self->{"stop"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"stop"} or $stop > $self->{"stop"}
not defined $self->{"stop"} $stop > $self->{"stop"}
Truth table0%0/3
not(A) or B
A= not defined $self->{"stop"}B= $stop > $self->{"stop"}
ABresult
1X1
011
000
1564 } else {
1565 0 ▶ $self->{start} = $start if !defined($self->{start}) || $start > $self->{start};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->{"start"} or $start > $self->{"start"} 0 0 0
Condition0%0/3
not defined $self->{"start"} or $start > $self->{"start"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"start"} or $start > $self->{"start"}
not defined $self->{"start"} $start > $self->{"start"}
Truth table0%0/3
not(A) or B
A= not defined $self->{"start"}B= $start > $self->{"start"}
ABresult
1X1
011
000
1566 0 ▶ $self->{stop} = $stop if !defined($self->{stop}) || $stop < $self->{stop};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->{"stop"} or $stop < $self->{"stop"} 0 0 0
Condition0%0/3
not defined $self->{"stop"} or $stop < $self->{"stop"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"stop"} or $stop < $self->{"stop"}
not defined $self->{"stop"} $stop < $self->{"stop"}
Truth table0%0/3
not(A) or B
A= not defined $self->{"stop"}B= $stop < $self->{"stop"}
ABresult
1X1
011
000
1567 }
1568  
1569 # fix up endpoints of targets too (for homologies only)
1570 # my $h = $feat->group;
1571 # next unless $h && $h->isa('Bio::DB::GFF::Homol'); # always false (for now)
1572 # next unless $g && $g->isa('Bio::DB::GFF::Homol');
1573 # ($start,$stop) = ($h->{start},$h->{stop});
1574 # if ($h->strand >= 0) {
1575 # $g->{start} = $start if !defined($g->{start}) || $start < $g->{start};
1576 # $g->{stop} = $stop if !defined($g->{stop}) || $stop > $g->{stop};
1577 # } else {
1578 # $g->{start} = $start if !defined($g->{start}) || $start > $g->{start};
1579 # $g->{stop} = $stop if !defined($g->{stop}) || $stop < $g->{stop};
1580 # }
1581 }
1582 }
1583 }
1584  
1585 0 ( $self->start(),$self->stop(),$self->strand() );
1586 }
1587  
1588 =head2 sort_features()
1589  
1590 Title : sort_features
1591 Usage : $feature->sort_features
1592 Function: sort features
1593 Returns : nothing
1594 Args : none
1595 Status : Public
1596  
1597 This method sorts subfeatures in ascending order by their start
1598 position. For reverse strand features, it sorts subfeatures in
1599 descending order. After this is called sub_SeqFeature will return the
1600 features in order.
1601  
1602 This method is called internally by merged_segments().
1603  
1604 =cut
1605  
1606 # sort features
1607 0 ▶sub sort_features {
Subroutine sort_features: not called CC=7 SCAR=40.3
Pod documented
1608 0 my $self = shift;
1609 0 ▶ return if $self->{sorted}++;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sorted"}++ 0 0 0
1610 0 ▶ my $strand = $self->strand or return;
Branch: 1 branch
BranchTrueFalseTotal
my $strand = $self->strand or return 0 0 0
1611 0 ▶ my $subfeat = $self->subfeatures or return;
Branch: 1 branch
BranchTrueFalseTotal
my $subfeat = $self->subfeatures or return 0 0 0
1612 0 for my $type (keys %$subfeat) {
1613 0 $subfeat->{$type} = [map { $_->[0] }
1614 0 sort {$a->[1] <=> $b->[1] }
1615 0 map { [$_,$_->start] }
1616 0 ▶ @{$subfeat->{$type}}] if $strand > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $strand > 0 0 0 0
1617 0 $subfeat->{$type} = [map { $_->[0] }
1618 0 sort {$b->[1] <=> $a->[1]}
1619 0 map { [$_,$_->start] }
1620 0 ▶ @{$subfeat->{$type}}] if $strand < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $strand < 0 0 0 0
1621 }
1622 }
1623  
1624 =head2 asString()
1625  
1626 Title : asString
1627 Usage : $string = $feature->asString
1628 Function: return human-readabled representation of feature
1629 Returns : a string
1630 Args : none
1631 Status : Public
1632  
1633 This method returns a human-readable representation of the feature and
1634 is called by the overloaded "" operator.
1635  
1636 =cut
1637  
1638 0 ▶sub asString {
Subroutine asString: not called CC=2 SCAR=17.9
Pod documented
1639 0 my $self = shift;
1640 0 my $type = $self->type;
1641 0 my $name = $self->uniquename;
1642  
1643 0 ▶ return "$type($name)" if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 0 0
1644 0 return $type;
1645 # my $type = $self->method;
1646 # my $id = $self->group || 'unidentified';
1647 # return join '/',$id,$type,$self->SUPER::asString;
1648 }
1649  
1650 1 *as_string = \&asString;
1651  
1652 =head2 synonyms()
1653  
1654 Title : synonyms
1655 Usage : @synonyms = $feature->synonyms
1656 Function: return a list of synonyms for a feature
1657 Returns : a list of strings
1658 Args : none
1659 Status : Public
1660  
1661 Looks in the synonym table to collect all synonyms of a feature.
1662  
1663 =cut
1664  
1665  
1666 0 ▶sub synonyms {
Subroutine synonyms: not called CC=5 SCAR=34.0
Pod documented
1667 #returns an array with synonyms
1668 0 my $self = shift;
1669 0 my $dbh = $self->factory->dbh();
1670
1671 0 my $sth;
1672 0 ▶ if ($self->factory->use_all_feature_names()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->factory->use_all_feature_names) { } 0 0 0
1673 0 $sth = $dbh->prepare("
1674 select name from all_feature_names where ? = feature_id
1675 ");
1676 }
1677 else {
1678 0 $sth = $dbh->prepare("
1679 select s.name from synonym s, feature_synonym fs
1680 where ? = fs.feature_id and
1681 fs.synonym_id = s.synonym_id
1682 ");
1683 }
1684 0 ▶ $sth->execute($self->feature_id()) or $self->throw("synonym query failed");
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($self->feature_id) or $self->throw("synonym query failed") 0 0 0
1685
1686 0 my $name = $self->display_name;
1687 0 my @synonyms;
1688 0 ▶ while (my $hashref = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hashref = $sth->fetchrow_hashref) 0 0 0
1689 0 ▶ push @synonyms, $$hashref{name} if ($$hashref{name} ne $name);
Branch: 1 branch
BranchTrueFalseTotal
if $hashref->{"name"} ne $name 0 0 0
1690 }
1691  
1692 0 $sth->finish;
1693 0 return @synonyms;
1694 }
1695  
1696 =head2 cmap_link()
1697  
1698 Title : cmap_link
1699 Usage : $link = $feature->cmap_link
1700 Function: returns a URL link to the corresponding feature in cmap
1701 Returns : a string
1702 Args : none
1703 Status : Public
1704  
1705 Returns a link to a cmap installation (which is assumed to be on the
1706 same host as gbrowse). In addition to the cmap tables being present
1707 in chado, this method also assumes the presence of a link table called
1708 feature_to_cmap. See the cmap documentation for more information.
1709  
1710 This function is intended primarily to be used in gbrowse conf files.
1711 For example:
1712  
1713 link = sub {my $self = shift; return $self->cmap_link();}
1714  
1715 =cut
1716  
1717  
1718 0 ▶sub cmap_link {
Subroutine cmap_link: not called CC=3 SCAR=24.8
Pod documented
1719 # Use ONLY if CMap is installed in chado and
1720 # the feature_to_cmap table is also installed
1721 # This table is provided with CMap.
1722 0 my $self = shift;
1723 0 my $data_source = shift;
1724
1725 0 my $dbh = $self->factory->dbh();
1726  
1727 0 my $sth = $dbh->prepare("
1728 select cm_f.feature_name,
1729 cm_m.accession_id as map_aid
1730 from cmap_feature cm_f,
1731 cmap_map cm_m,
1732 feature_to_cmap ftc
1733 where ? = ftc.feature_id
1734 and cm_f.accession_id=ftc.cmap_feature_aid
1735 and cm_f.map_id=cm_m.map_id
1736 ");
1737 0 ▶ $sth->execute($self->feature_id()) or $self->throw("cmap link query
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($self->feature_id) or $self->throw("cmap link query\nfailed") 0 0 0
1738 failed");
1739 0 my $link_str='';
1740 0 ▶ if (my $hashref = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hashref = $sth->fetchrow_hashref) 0 0 0
1741
1742 0 $link_str='/cgi-bin/cmap/viewer?ref_map_aids='.$$hashref{map_aid}.'&data_source='.$data_source.'&highlight='.$$hashref{'feature_name'};
1743 }
1744  
1745 0 $sth->finish;
1746 0 return $link_str;
1747 }
1748  
1749 1 1;
↑ Summary script/gmod_chado_fts_prep.pl »