line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::ConnectDots::ConnectDots; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.0.2'; |
4
|
|
|
|
|
|
|
|
5
|
15
|
|
|
15
|
|
337089
|
use vars qw(@ISA @AUTO_ATTRIBUTES @OTHER_ATTRIBUTES %SYNONYMS %DEFAULTS); |
|
15
|
|
|
|
|
39
|
|
|
15
|
|
|
|
|
3792
|
|
6
|
15
|
|
|
15
|
|
93
|
use strict; |
|
15
|
|
|
|
|
27
|
|
|
15
|
|
|
|
|
484
|
|
7
|
15
|
|
|
15
|
|
10061
|
use Bio::ConnectDots::DB; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Bio::ConnectDots::DB::ConnectDots; |
9
|
|
|
|
|
|
|
use Bio::ConnectDots::DotSet; |
10
|
|
|
|
|
|
|
use Bio::ConnectDots::ConnectorSet; |
11
|
|
|
|
|
|
|
use Bio::ConnectDots::ConnectorTable; |
12
|
|
|
|
|
|
|
use Bio::ConnectDots::Util; |
13
|
|
|
|
|
|
|
@ISA = qw(Class::AutoClass); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@AUTO_ATTRIBUTES=qw(db |
16
|
|
|
|
|
|
|
label2dotset id2dotset |
17
|
|
|
|
|
|
|
name2cs id2cs |
18
|
|
|
|
|
|
|
name2dt id2dt |
19
|
|
|
|
|
|
|
name2ct id2ct |
20
|
|
|
|
|
|
|
label2labelid |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
@OTHER_ATTRIBUTES=qw(connectorsets dotsets connectortables dottables); |
23
|
|
|
|
|
|
|
%SYNONYMS=(); |
24
|
|
|
|
|
|
|
%DEFAULTS=(); |
25
|
|
|
|
|
|
|
Class::AutoClass::declare(__PACKAGE__); |
26
|
|
|
|
|
|
|
my $VERSION=1.0; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _init_self { |
29
|
|
|
|
|
|
|
my($self,$class,$args)=@_; |
30
|
|
|
|
|
|
|
return unless $class eq __PACKAGE__; # to prevent subclasses from re-running this |
31
|
|
|
|
|
|
|
my $db=$self->db; |
32
|
|
|
|
|
|
|
Bio::ConnectDots::DB::ConnectDots->get($self); |
33
|
|
|
|
|
|
|
my $label2labelid= $self->label2labelid({}); |
34
|
|
|
|
|
|
|
my $connectorsets=$self->connectorsets; |
35
|
|
|
|
|
|
|
for my $connectorset (@$connectorsets) { |
36
|
|
|
|
|
|
|
my $l2id=$connectorset->label2labelid; |
37
|
|
|
|
|
|
|
@$label2labelid{keys %$l2id}=values %$l2id; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub connectorsets { |
42
|
|
|
|
|
|
|
my $self=shift; |
43
|
|
|
|
|
|
|
if (@_) { |
44
|
|
|
|
|
|
|
my $connectorsets=shift; |
45
|
|
|
|
|
|
|
my $name2cs=$self->name2cs({}); |
46
|
|
|
|
|
|
|
my $id2cs=$self->id2cs({}); |
47
|
|
|
|
|
|
|
for my $connectorset (@$connectorsets) { |
48
|
|
|
|
|
|
|
$self->throw("Connectorset must have a version attribute.") unless $connectorset->cs_version; |
49
|
|
|
|
|
|
|
$name2cs->{$connectorset->name}{$connectorset->cs_version}=$connectorset; |
50
|
|
|
|
|
|
|
$id2cs->{$connectorset->db_id}=$connectorset; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
my $label2labelid=$self->label2labelid({}); |
53
|
|
|
|
|
|
|
for my $connectorset (@$connectorsets) { |
54
|
|
|
|
|
|
|
my $l2id=$connectorset->label2labelid; |
55
|
|
|
|
|
|
|
@$label2labelid{keys %$l2id}=values %$l2id; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
my @connectorsets; |
59
|
|
|
|
|
|
|
foreach my $csname (keys %{$self->name2cs}) { |
60
|
|
|
|
|
|
|
grep { push @connectorsets, $_ } values %{$self->name2cs->{$csname}}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
wantarray? @connectorsets: \@connectorsets; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
sub dotsets { |
65
|
|
|
|
|
|
|
my $self=shift; |
66
|
|
|
|
|
|
|
if (@_) { |
67
|
|
|
|
|
|
|
my $dotsets=shift; |
68
|
|
|
|
|
|
|
my $label2dotset=$self->label2dotset({}); |
69
|
|
|
|
|
|
|
my $id2dotset=$self->id2dotset({}); |
70
|
|
|
|
|
|
|
for my $dotset (@$dotsets) { |
71
|
|
|
|
|
|
|
$label2dotset->{$dotset->name}=$dotset; |
72
|
|
|
|
|
|
|
$id2dotset->{$dotset->db_id}=$dotset; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
my @dotsets=values %{$self->label2dotset}; |
76
|
|
|
|
|
|
|
wantarray? @dotsets: \@dotsets; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
sub connectortables { |
79
|
|
|
|
|
|
|
my $self=shift; |
80
|
|
|
|
|
|
|
if (@_) { |
81
|
|
|
|
|
|
|
my $connectortables=shift; |
82
|
|
|
|
|
|
|
my $name2ct=$self->name2ct({}); |
83
|
|
|
|
|
|
|
my $id2ct=$self->id2ct({}); |
84
|
|
|
|
|
|
|
for my $connectortable (@$connectortables) { |
85
|
|
|
|
|
|
|
$name2ct->{$connectortable->name}=$connectortable; |
86
|
|
|
|
|
|
|
$id2ct->{$connectortable->db_id}=$connectortable; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
my @connectortables=values %{$self->name2ct}; |
90
|
|
|
|
|
|
|
wantarray? @connectortables: \@connectortables; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
sub dottables { |
93
|
|
|
|
|
|
|
my $self=shift; |
94
|
|
|
|
|
|
|
if (@_) { |
95
|
|
|
|
|
|
|
my $dottables=shift; |
96
|
|
|
|
|
|
|
my $name2dt=$self->name2dt({}); |
97
|
|
|
|
|
|
|
my $id2dt=$self->id2dt({}); |
98
|
|
|
|
|
|
|
for my $dottable (@$dottables) { |
99
|
|
|
|
|
|
|
$name2dt->{$dottable->name}=$dottable; |
100
|
|
|
|
|
|
|
$id2dt->{$dottable->db_id}=$dottable; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
my @dottables=values %{$self->name2dt}; |
104
|
|
|
|
|
|
|
wantarray? @dottables: \@dottables; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub connectorset { |
108
|
|
|
|
|
|
|
my($self,$name,$version)=@_; |
109
|
|
|
|
|
|
|
if (!$version) { # no specified version, get newest |
110
|
|
|
|
|
|
|
foreach my $ver (keys %{$self->name2cs->{$name}}) { |
111
|
|
|
|
|
|
|
$version = $ver if $ver gt $version; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
return $self->name2cs->{$name}->{$version}; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub dotset { |
118
|
|
|
|
|
|
|
my($self,$name)=@_; |
119
|
|
|
|
|
|
|
$self->label2dotset->{$name}; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
sub query { |
122
|
|
|
|
|
|
|
my($self,@args)=@_; |
123
|
|
|
|
|
|
|
my $args=new Class::AutoClass::Args(@args); |
124
|
|
|
|
|
|
|
my $query_type=$args->query_type; |
125
|
|
|
|
|
|
|
if ($query_type=~/dot/i || $args->input) { |
126
|
|
|
|
|
|
|
my $dottable=new Bio::ConnectDots::DotTable(-connectdots=>$self,-db=>$self->db,%$args); |
127
|
|
|
|
|
|
|
$dottable->query($args); |
128
|
|
|
|
|
|
|
$self->name2dt->{$dottable->name}=$dottable; |
129
|
|
|
|
|
|
|
} else { # assume it's a ConnectorQuery |
130
|
|
|
|
|
|
|
my $connectortable=new Bio::ConnectDots::ConnectorTable(-connectdots=>$self,-db=>$self->db,%$args); |
131
|
|
|
|
|
|
|
$connectortable->query($args); |
132
|
|
|
|
|
|
|
$self->name2ct->{$connectortable->name}=$connectortable; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
sub connector_query { |
136
|
|
|
|
|
|
|
my($self,@args)=@_; |
137
|
|
|
|
|
|
|
my $args=new Class::AutoClass::Args(@args); |
138
|
|
|
|
|
|
|
my $connectortable=new Bio::ConnectDots::ConnectorTable |
139
|
|
|
|
|
|
|
(-connectdots=>$self,-db=>$self->db,%$args); |
140
|
|
|
|
|
|
|
$connectortable->query($args); |
141
|
|
|
|
|
|
|
$self->name2ct->{$connectortable->name}=$connectortable; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
sub dot_query { |
144
|
|
|
|
|
|
|
my($self,@args)=@_; |
145
|
|
|
|
|
|
|
my $args=new Class::AutoClass::Args(@args); |
146
|
|
|
|
|
|
|
my $dottable=new Bio::ConnectDots::DotTable |
147
|
|
|
|
|
|
|
(-connectdots=>$self,-db=>$self->db,%$args); |
148
|
|
|
|
|
|
|
$dottable->query($args); |
149
|
|
|
|
|
|
|
$self->name2dt->{$dottable->name}=$dottable; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _flatten {map {'ARRAY' eq ref $_? @$_: $_} @_;} |
154
|
|
|
|
|
|
|
1; |
155
|
|
|
|
|
|
|
__END__ |