| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::ConnectDots::DotQuery::Term; |
|
2
|
1
|
|
|
1
|
|
6
|
use vars qw(@ISA @AUTO_ATTRIBUTES @OTHER_ATTRIBUTES %SYNONYMS %DEFAULTS); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
188
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use Class::AutoClass; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Bio::ConnectDots::Util; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1084
|
|
|
6
|
|
|
|
|
|
|
@ISA = qw(Class::AutoClass); |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
@AUTO_ATTRIBUTES=qw(column cs labels label_ids termlist); |
|
9
|
|
|
|
|
|
|
%SYNONYMS=(); |
|
10
|
|
|
|
|
|
|
@OTHER_ATTRIBUTES=qw(); |
|
11
|
|
|
|
|
|
|
%DEFAULTS=(termlist=>[]); |
|
12
|
|
|
|
|
|
|
Class::AutoClass::declare(__PACKAGE__); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _init_self { |
|
15
|
0
|
|
|
0
|
|
|
my($self,$class,$args)=@_; |
|
16
|
0
|
0
|
|
|
|
|
return unless $class eq __PACKAGE__; # to prevent subclasses from re-running this |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Be careful with the following delegated accessors: not valid until validation time |
|
20
|
0
|
|
|
0
|
0
|
|
sub cs_id {$_[0]->cs->db_id;} |
|
21
|
0
|
|
|
0
|
0
|
|
sub cs_name {$_[0]->cs->name;} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub normalize { |
|
24
|
0
|
|
|
0
|
0
|
|
my($self)=@_; |
|
25
|
0
|
|
|
|
|
|
my $termlist=$self->termlist; |
|
26
|
0
|
|
|
|
|
|
my($column,$cs,$labels)=$self->get(qw(column cs labels)); |
|
27
|
|
|
|
|
|
|
# set components if unset, or check for equality |
|
28
|
0
|
0
|
|
|
|
|
if (@$termlist==2) { # column.labels |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $i=0; |
|
30
|
0
|
0
|
0
|
|
|
|
$self->throw("termlist and column are inconsistent: \$termlist=".$termlist->[$i]. |
|
31
|
|
|
|
|
|
|
", \$column=$column") |
|
32
|
|
|
|
|
|
|
if defined $column && $termlist->[$i++] ne $column; |
|
33
|
0
|
0
|
0
|
|
|
|
$self->throw("termlist and labels are inconsistent: \$termlist=".$termlist->[$i]. |
|
34
|
|
|
|
|
|
|
", \$labels=$labels") |
|
35
|
|
|
|
|
|
|
if defined $labels && $termlist->[$i++] ne $labels; |
|
36
|
0
|
|
|
|
|
|
my $i=0; |
|
37
|
0
|
0
|
|
|
|
|
defined $column or $self->column($termlist->[$i++]); |
|
38
|
0
|
0
|
|
|
|
|
defined $labels or $self->labels($termlist->[$i++]); |
|
39
|
|
|
|
|
|
|
} elsif (@$termlist==1) { # labels |
|
40
|
0
|
0
|
0
|
|
|
|
$self->throw("termlist and labels are inconsistent: \$termlist=".$termlist->[0]. |
|
41
|
|
|
|
|
|
|
", \$labels=$labels") |
|
42
|
|
|
|
|
|
|
if defined $labels && $termlist->[0] ne $labels; |
|
43
|
0
|
0
|
|
|
|
|
defined $labels or $self->labels($termlist->[0]); |
|
44
|
|
|
|
|
|
|
} elsif (@$termlist>2) { |
|
45
|
0
|
|
|
|
|
|
$self->throw("Invalid termlist ".value_as_string($termlist). |
|
46
|
|
|
|
|
|
|
": must have 0-2 elements, not ".(@$termlist+0)); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
0
|
0
|
|
|
|
|
$self->throw("Invalid term ".$self->as_string.": * can only appear as labels") |
|
49
|
|
|
|
|
|
|
if '*' eq $self->column; |
|
50
|
0
|
0
|
|
|
|
|
$self->throw("Invalid term ".$self->as_string.": lists can only appear as labels") |
|
51
|
|
|
|
|
|
|
if 'ARRAY' eq ref $self->column; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$labels=$self->labels; |
|
54
|
0
|
0
|
0
|
|
|
|
$self->throw("Invalid term ".$self->as_string.": no label!") |
|
|
|
|
0
|
|
|
|
|
|
55
|
|
|
|
|
|
|
if !$labels || ('ARRAY' eq ref $labels && !@$labels); |
|
56
|
0
|
|
|
|
|
|
$self->throw("Invalid term ".$self->as_string.": nested label lists are not supported") |
|
57
|
0
|
0
|
0
|
|
|
|
if 'ARRAY' eq ref $labels && grep {'ARRAY' eq ref $_} @$labels; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
$labels=[] if $labels eq '*'; # empty labels list means '*' hereafter |
|
60
|
0
|
0
|
|
|
|
|
$self->labels('ARRAY' eq ref $labels? $labels: [$labels]); |
|
61
|
0
|
|
|
|
|
|
$self->termlist([grep {defined $_} $self->get(qw(column labels))]); |
|
|
0
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$self; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Does validation needed for both ConnectorSet and ConnectorTable inputs |
|
66
|
|
|
|
|
|
|
# check labels and lookup label_ids |
|
67
|
|
|
|
|
|
|
sub validate { |
|
68
|
0
|
|
|
0
|
0
|
|
my($self,$cs)=@_; |
|
69
|
0
|
|
|
|
|
|
my $labels=$self->labels; |
|
70
|
0
|
|
|
|
|
|
$self->cs($cs); |
|
71
|
0
|
|
|
|
|
|
my $label_ids=[]; |
|
72
|
0
|
|
|
|
|
|
my $label2labelid=$cs->label2labelid; |
|
73
|
0
|
|
|
|
|
|
for my $label (@$labels) { |
|
74
|
0
|
|
|
|
|
|
my $label_id=$label2labelid->{$label}; |
|
75
|
0
|
0
|
|
|
|
|
$self->throw("Invalid label $label for ConnectorSet ".$self->cs_name) unless $label_id; |
|
76
|
0
|
|
|
|
|
|
push(@$label_ids,$label_id); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
0
|
|
|
|
|
|
$self->label_ids($label_ids); |
|
79
|
0
|
|
|
|
|
|
$self; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub as_string { |
|
83
|
0
|
|
|
0
|
0
|
|
my($self)=@_; |
|
84
|
0
|
|
|
|
|
|
join('.',map {value_as_string($_)} @{$self->termlist}); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
|
88
|
|
|
|
|
|
|
|