DotQuery/CsMixin.pm untested

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 84 CC 7 SCAR 24.1
CC
7
Cov
0%
_init_self
30.0
validate_outputs
6.0
validate_constraints
6.0
CRAP 11.2
1 package Bio::ConnectDots::DotQuery::CsMixin;
2 use vars qw(@ISA @AUTO_ATTRIBUTES @OTHER_ATTRIBUTES %SYNONYMS %DEFAULTS);
3 use strict;
4 use Class::AutoClass;
5 use Bio::ConnectDots::DotQuery::Output;
6 use Bio::ConnectDots::DotQuery::Constraint;
7 @ISA = qw(Class::AutoClass);
8  
9 @AUTO_ATTRIBUTES=qw(cs);
10 %SYNONYMS=();
11 @OTHER_ATTRIBUTES=qw();
12 %DEFAULTS=();
13 Class::AutoClass::declare(__PACKAGE__);
14  
15 sub _init_self {
16 my($self,$class,$args)=@_;
17 return unless $class eq __PACKAGE__; # to prevent subclasses from re-running this
18 my $input=$self->input;
19 my $version = $args->get_args('cs_version');
20  
21 if(!$version) {
22 foreach my $ver (keys %{$self->connectdots->name2cs->{$input}}) {
23 $version = $ver if $ver gt $version;
24 }
25 }
26
27 my $cs=$self->connectdots->name2cs->{$input}->{$version};
28 $self->throw("Invalid -input: must be ConnectorSet name") unless $cs;
29 $self->cs($cs);
30 }
31 sub cs_id {$_[0]->cs->db_id;}
32 sub cs_name {$_[0]->cs->name;}
33 sub label2labelid {$_[0]->cs->label2labelid;}
34  
35 # outputs must have label, no column; label must be valid for input ConnectorSet
36 sub validate_outputs {
37 my($self)=@_;
38 my $cs=$self->cs;
39 for my $output (@{$self->outputs}) {
40 $self->throw("Invalid output ".$output->as_string.
41 ": ConnectorSet outputs cannot have column") if $output->column;
42 $output->validate($cs);
43  
44 # add outputs to alias2info
45 my $alias = $output->output_name;
46 my $cs_id = $cs->db_id;
47 my $label_id = $output->{_term}->{label_ids}->[0];
48 my $dotset = $output->dotset;
49 $self->{dottable}->{alias2info}->{$alias}->{dotset}= $dotset;
50 $self->{dottable}->{alias2info}->{$alias}->{label_id} = $label_id;
51 $self->{dottable}->{alias2info}->{$alias}->{cs_id} = $cs->db_id;
52 }
53 }
54 # constraint-terms must have labels, no column
55 # labels must be valid for input ConnectorSet (handled by Term::validate)
56 sub validate_constraints {
57 my($self)=@_;
58 my $cs=$self->cs;
59 for my $constraint (@{$self->constraints}) {
60 my $term=$constraint->term;
61 $self->throw("Invalid constraint ".$constraint->as_string.
62 ": ConnectorSet constraints cannot have column") if $term->column;
63 $term->validate($cs);
64 }
65 }
66  
67 1;
68