DotQuery/InnerCs.pm untested

filter: Statementstmt 0.0% 0 / 67 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 92 CC 8 SCAR 29.4
CC
8
Cov
0%
db_execute
42.0
_init_self
12.0
BEGIN
2.0
CRAP 18.9
1 package Bio::ConnectDots::DotQuery::InnerCs;
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::CsMixin;
9 @ISA = qw(Bio::ConnectDots::DotQuery Bio::ConnectDots::DotQuery::CsMixin);
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 $cs_id=$self->cs_id;
30 my $preview = $self->dottable->preview;
31 my $plimit = $self->dottable->preview_limit;
32  
33 my(@targets,@columns,@tables,@where);
34 my $i=0;
35 my $cd0;
36 for my $output (@{$self->outputs}) {
37 my($output_name,$label_id)=($output->output_name,$output->label_id);
38 my $cd1="cd$i";
39 push(@targets,"$cd1.id AS $output_name");
40 push(@columns,$output_name);
41 if($preview) {
42 push(@tables,"(SELECT * FROM connectdot WHERE connectorset_id=$cs_id AND label_id=$label_id LIMIT $plimit) AS cd$i");
43 } else {
44 push(@tables,"connectdot AS cd$i");
45 }
46 push(@where,"$cd0.connector_id=$cd1.connector_id") unless $i==0;
47 push(@where,("$cd1.connectorset_id=$cs_id",
48 "$cd1.label_id=$label_id"));
49 $i++;
50 $cd0=$cd1;
51 }
52 for my $constraint (@{$self->constraints}) {
53 my $cd1="cd$i";
54 push(@tables,"connectdot AS $cd1"); # from
55 push(@where,"$cd0.connector_id=$cd1.connector_id") unless $i==0; # join
56 push(@where,$self->constraint_where($constraint,$cs_id,$cd1));
57 $i++;
58 $cd0=$cd1;
59 }
60 my $targets=join(', ',@targets);
61 my $from=join(', ',@tables);
62 my $where=join(' AND ',@where);
63 my $sql="SELECT DISTINCT $targets FROM $from WHERE $where";
64 $db->create_table_sql($name,$sql,\@columns)
65 }
66  
67  
68 1;