DotQuery/InnerCt.pm untested

filter: Statementstmt 0.0% 0 / 65 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 88 CC 7 SCAR 25.9
CC
7
Cov
0%
db_execute
30.0
_init_self
12.0
BEGIN
2.0
CRAP 13.3
1 package Bio::ConnectDots::DotQuery::InnerCt;
2 use vars qw(@ISA @AUTO_ATTRIBUTES @OTHER_ATTRIBUTES %SYNONYMS %DEFAULTS);
3 use strict;
4 use DBI;
5 use Class::AutoClass;
6 use Bio::ConnectDots::Util;
7 use Bio::ConnectDots::DotQuery;
8 use Bio::ConnectDots::DotQuery::CtMixin;
9 @ISA = qw(Bio::ConnectDots::DotQuery Bio::ConnectDots::DotQuery::CtMixin);
10  
11 @AUTO_ATTRIBUTES=qw();
12 %SYNONYMS=();
13 @OTHER_ATTRIBUTES=qw();
14 %DEFAULTS=();
15 Class::AutoClass::declare(__PACKAGE__);
16  
17 sub _init_self {
18 my($self,$class,$args)=@_;
19 return unless $class eq __PACKAGE__; # to prevent subclasses from re-running this
20 $self->execute if $args->execute;
21 }
22  
23 sub db_execute {
24 my($self)=@_;
25 my $db=$self->db;
26 $self->throw("Cannot run query: database is not connected") unless $db->is_connected;
27 $self->throw("Cannot run query: database does not exist") unless $db->exists;
28 my $name=$self->name;
29 my $preview = $self->dottable->preview;
30 my $plimit = $self->dottable->preview_limit;
31  
32 my(@targets,@columns,@where);
33 my $subselect = $self->input." AS ct";
34 $subselect = "(SELECT * FROM ". $self->input ." LIMIT $plimit) AS ct" if $preview;
35 my @tables=($subselect);
36 my $i=0;
37 for my $output (@{$self->outputs}) {
38 my($output_name,$column,$cs_id,$label_id)=$output->get(qw(output_name column cs_id label_id));
39 my $cd="cd$i";
40 push(@targets,"$cd.id AS $output_name");
41 push(@columns,$output_name);
42 my $subselect = "connectdot AS cd$i";
43 $subselect = "(SELECT * FROM connectdot WHERE connectorset_id=$cs_id AND label_id=$label_id LIMIT $plimit) AS cd$i" if $preview;
44 push(@tables,$subselect);
45 push(@where,("ct.$column=$cd.connector_id",
46 "$cd.connectorset_id=$cs_id",
47 "$cd.label_id=$label_id"));
48 $i++;
49 }
50 for my $constraint (@{$self->constraints}) {
51 my $cd="cd$i";
52 my($column,$cs_id)=($constraint->column,$constraint->cs_id);
53 push(@tables,"connectdot AS $cd");
54 push(@where,("ct.$column=$cd.connector_id",
55 $self->constraint_where($constraint,$cs_id,$cd)));
56 $i++;
57 }
58 my $targets=join(', ',@targets);
59 my $from=join(', ',@tables);
60 my $where=join(' AND ',@where);
61 my $sql="SELECT DISTINCT $targets FROM $from WHERE $where";
62 $db->create_table_sql($name,$sql,\@columns)
63 }
64  
65  
66 1;