| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::ConnectDots::DotQuery::Output; |
|
2
|
1
|
|
|
1
|
|
8
|
use vars qw(@ISA @AUTO_ATTRIBUTES @OTHER_ATTRIBUTES %SYNONYMS %DEFAULTS); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
96
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
175
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use Class::AutoClass; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
5
|
1
|
|
|
1
|
|
512
|
use Bio::ConnectDots::Util; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
313
|
|
|
6
|
1
|
|
|
1
|
|
3666
|
use Bio::ConnectDots::Parser; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
1238
|
|
|
7
|
|
|
|
|
|
|
@ISA = qw(Class::AutoClass); |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@AUTO_ATTRIBUTES=qw(_term output_name dotset); |
|
10
|
|
|
|
|
|
|
%SYNONYMS=(); |
|
11
|
|
|
|
|
|
|
@OTHER_ATTRIBUTES=qw(term termlist column label cs label_id); |
|
12
|
|
|
|
|
|
|
%DEFAULTS=(); |
|
13
|
|
|
|
|
|
|
Class::AutoClass::declare(__PACKAGE__); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _init_self { |
|
16
|
0
|
|
|
0
|
|
|
my($self,$class,$args)=@_; |
|
17
|
0
|
0
|
|
|
|
|
return unless $class eq __PACKAGE__; # to prevent subclasses from re-running this |
|
18
|
0
|
0
|
|
|
|
|
$self->term or $self->term(new Bio::ConnectDots::DotQuery::Term); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# legal formats: |
|
22
|
|
|
|
|
|
|
# 1) Old ConnectorTable format: ARRAY of [column,label] or HASH of output=>[column,label] |
|
23
|
|
|
|
|
|
|
# NOTE: Old ConnectorSet format NOT supported, because it conflicts with |
|
24
|
|
|
|
|
|
|
# new ARRAY of output strings |
|
25
|
|
|
|
|
|
|
# 2) single string -- label, label AS output, column.label, column.label AS output |
|
26
|
|
|
|
|
|
|
# may include multiple aliases AND'ed together |
|
27
|
|
|
|
|
|
|
# 3) single Output object |
|
28
|
|
|
|
|
|
|
# 4) ARRAY of (1) output strings and (2) Output objects |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub parse { |
|
31
|
0
|
|
|
0
|
0
|
|
my($class,$outputs)=@_; |
|
32
|
0
|
|
|
|
|
|
my $parsed=[]; |
|
33
|
0
|
|
|
|
|
|
my $parser=new Bio::ConnectDots::Parser; |
|
34
|
0
|
0
|
|
|
|
|
if (!ref $outputs) { # single string |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
push(@$parsed,$class->parse_string($outputs,$parser)); |
|
36
|
|
|
|
|
|
|
} elsif ('ARRAY' eq ref $outputs) { |
|
37
|
0
|
|
|
|
|
|
for my $output (@$outputs) { |
|
38
|
0
|
0
|
|
|
|
|
if (UNIVERSAL::isa($output,__PACKAGE__)) { # Output object |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
push(@$parsed,$output); |
|
40
|
|
|
|
|
|
|
} elsif (!ref($output)) { # string |
|
41
|
0
|
|
|
|
|
|
push(@$parsed,$class->parse_string($output,$parser)); |
|
42
|
|
|
|
|
|
|
} elsif ('ARRAY' eq ref $output) { # old form: [column,label] |
|
43
|
0
|
|
|
|
|
|
my($column,$label)=@$output; |
|
44
|
0
|
|
|
|
|
|
push(@$parsed,$class->new(-column=>$column,-label=>$label)); |
|
45
|
|
|
|
|
|
|
} else { |
|
46
|
0
|
|
|
|
|
|
$class->throw("llegal output format ".value_as_string($output). |
|
47
|
|
|
|
|
|
|
": must be string, Output object, or ARRAY to appear in ARRAY format"); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} elsif (UNIVERSAL::isa($outputs,__PACKAGE__)) { # single Output object |
|
51
|
0
|
|
|
|
|
|
push(@$parsed,$outputs); |
|
52
|
|
|
|
|
|
|
} elsif ('HASH' eq ref $outputs) { # old form HASH of output=>[column,label] |
|
53
|
0
|
|
|
|
|
|
while(my($output_name,$output)=each %$outputs) { |
|
54
|
0
|
|
|
|
|
|
my($column,$label)=@$output; |
|
55
|
0
|
|
|
|
|
|
push(@$parsed,$class->new(-column=>$column,-label=>$label,-output_name=>$output_name)); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} else { |
|
58
|
0
|
|
|
|
|
|
$class->throw("Unrecognized alias form ".value_as_string($outputs). |
|
59
|
|
|
|
|
|
|
": Strange type! Not scalar, Output object, ARRAY, or HASH"); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
0
|
0
|
|
|
|
|
wantarray? @$parsed: $parsed; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
sub parse_string { |
|
64
|
0
|
|
|
0
|
0
|
|
my($class,$outputs,$parser)=@_; |
|
65
|
0
|
|
|
|
|
|
my $parsed=[]; |
|
66
|
0
|
|
|
|
|
|
my $parsed_outputs=$parser->parse_outputs($outputs); |
|
67
|
0
|
0
|
|
|
|
|
if ($parsed_outputs) { |
|
68
|
0
|
|
|
|
|
|
for my $output (@$parsed_outputs) { |
|
69
|
0
|
|
|
|
|
|
my($termlist,$output_name)=@$output{qw(termlist output_name)}; |
|
70
|
0
|
|
|
|
|
|
push(@$parsed, |
|
71
|
|
|
|
|
|
|
$class->new(-termlist=>$termlist,-output_name=>$output_name)); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
0
|
0
|
|
|
|
|
wantarray? @$parsed: $parsed; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
sub normalize { # if no output_name, set it to label |
|
77
|
0
|
|
|
0
|
0
|
|
my($self)=@_; |
|
78
|
0
|
|
|
|
|
|
$self->term->normalize; |
|
79
|
0
|
0
|
|
|
|
|
$self->output_name($self->label) unless $self->output_name; |
|
80
|
0
|
|
|
|
|
|
$self; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Does validation needed for both ConnectorSet and ConnectorTable inputs |
|
84
|
|
|
|
|
|
|
# check labels and lookup label_ids |
|
85
|
|
|
|
|
|
|
sub validate { |
|
86
|
0
|
|
|
0
|
0
|
|
my($self,$cs)=@_; |
|
87
|
0
|
|
|
|
|
|
my $label=$self->label; |
|
88
|
0
|
0
|
|
|
|
|
$self->throw("Invalid output ".$self->as_string.": must have label") unless $label; |
|
89
|
0
|
|
|
|
|
|
my $label_id=$cs->label2labelid->{$label}; |
|
90
|
0
|
|
|
|
|
|
my $dotset=$cs->label2dotset->{$label}; |
|
91
|
0
|
0
|
|
|
|
|
$self->throw("Label $label not valid for ConnectorSet ".$cs->name) unless $dotset; |
|
92
|
0
|
|
|
|
|
|
$self->cs($cs); |
|
93
|
0
|
|
|
|
|
|
$self->label_id($label_id); |
|
94
|
0
|
|
|
|
|
|
$self->dotset($dotset); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub term { |
|
98
|
0
|
|
|
0
|
0
|
|
my $self=shift @_; |
|
99
|
0
|
0
|
|
|
|
|
my $term=@_? $self->_term($_[0]): $self->_term; |
|
100
|
0
|
0
|
|
|
|
|
$term or $term=$self->_term(new Bio::ConnectDots::DotQuery::Term); |
|
101
|
0
|
|
|
|
|
|
$term; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
sub column { |
|
104
|
0
|
|
|
0
|
0
|
|
my $self=shift @_; |
|
105
|
0
|
0
|
|
|
|
|
my $column=@_? $self->term->column($_[0]): $self->term->column; |
|
106
|
0
|
|
|
|
|
|
$column; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
sub cs { |
|
109
|
0
|
|
|
0
|
0
|
|
my $self=shift @_; |
|
110
|
0
|
0
|
|
|
|
|
my $cs=@_? $self->term->cs($_[0]): $self->term->cs; |
|
111
|
0
|
|
|
|
|
|
$cs; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
0
|
|
|
0
|
0
|
|
sub cs_id {$_[0]->cs->db_id;} |
|
114
|
0
|
|
|
0
|
0
|
|
sub cs_name {$_[0]->cs->name;} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub label { |
|
117
|
0
|
|
|
0
|
0
|
|
my $self=shift @_; |
|
118
|
0
|
0
|
|
|
|
|
my $labels=@_? $self->term->labels([$_[0]]): $self->term->labels; |
|
119
|
0
|
0
|
|
|
|
|
$labels && $labels->[0]; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
sub label_id { |
|
122
|
0
|
|
|
0
|
0
|
|
my $self=shift @_; |
|
123
|
0
|
0
|
|
|
|
|
my $label_ids=@_? $self->term->label_ids([$_[0]]): $self->term->label_ids; |
|
124
|
0
|
0
|
|
|
|
|
$label_ids && $label_ids->[0]; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
sub termlist { |
|
127
|
0
|
|
|
0
|
0
|
|
my $self=shift @_; |
|
128
|
0
|
0
|
|
|
|
|
my $termlist=@_? $self->term->termlist($_[0]): $self->term->termlist; |
|
129
|
0
|
|
|
|
|
|
$termlist; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub as_string { |
|
133
|
0
|
|
|
0
|
0
|
|
my($self)=@_; |
|
134
|
0
|
|
|
|
|
|
my($column,$label,$output_name)=$self->get(qw(column label output_name)); |
|
135
|
0
|
|
|
|
|
|
join('.',$column,$label)." AS $output_name"; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
|
139
|
|
|
|
|
|
|
|