| 1 | package Test::Chado::Cvterm; | ||||||||||
| 2 | { | ||||||||||
| 3 | 1 | $Test::Chado::Cvterm::VERSION = 'v4.1.1'; | |||||||||
| 4 | } | ||||||||||
| 5 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use MooX::ClassAttribute; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Test::Chado::Types qw/TB/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Test::Builder; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Sub::Exporter -setup => { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | exports => { | ||||||||||
| 11 | 'count_cvterm_ok' => \&_count_cvterm, | ||||||||||
| 12 | 'count_obsolete_cvterm_ok' => \&_count_obsolete_cvterm, | ||||||||||
| 13 | 'count_relationship_cvterm_ok' => \&_count_relationship_cvterm, | ||||||||||
| 14 | 'count_synonym_ok' => \&_count_synonym, | ||||||||||
| 15 | 'count_alt_id_ok' => \&_count_alt_id, | ||||||||||
| 16 | 'count_subject_ok' => \&_count_subject, | ||||||||||
| 17 | 'count_object_ok' => \&_count_object, | ||||||||||
| 18 | 'count_comment_ok' => \&_count_comment, | ||||||||||
| 19 | 'has_synonym' => \&_has_synonym, | ||||||||||
| 20 | 'has_alt_id' => \&_has_alt_id, | ||||||||||
| 21 | 'has_comment' => \&_has_comment, | ||||||||||
| 22 | 'has_relationship' => \&_has_relationship, | ||||||||||
| 23 | 'has_xref' => \&_has_xref, | ||||||||||
| 24 | 'is_obsolete_cvterm' => \&_is_obsolete_cvterm | ||||||||||
| 25 | }, | ||||||||||
| 26 | groups => { | ||||||||||
| 27 | 'count' => [ | ||||||||||
| 28 | qw/count_alt_id_ok count_cvterm_ok count_synonym_ok count_subject_ok count_object_ok | ||||||||||
| 29 | count_comment_ok count_obsolete_cvterm_ok count_relationship_cvterm_ok/ | ||||||||||
| 30 | ], | ||||||||||
| 31 | 'check' => [ | ||||||||||
| 32 | qw/has_synonym has_alt_id has_comment has_relationship is_related has_xref is_obsolete_term/ | ||||||||||
| 33 | ], | ||||||||||
| 34 | 'relationship' => [ | ||||||||||
| 35 | qw/count_object_ok count_subject_ok has_relationship is_related count_relationship_cvterm_ok/ | ||||||||||
| 36 | ] | ||||||||||
| 37 | } | ||||||||||
| 38 | 1 | }; | |||||||||
| 39 | |||||||||||
| 40 | class_has 'test_builder' => ( | ||||||||||
| 41 | is => 'ro', | ||||||||||
| 42 | lazy => 1, | ||||||||||
| 43 | isa => TB, | ||||||||||
| 44 | 0 | ▶ | default => sub { Test::Builder->new } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 45 | 1 | ); | |||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub _check_params_or_die { | ||||||||
|
Subroutine
_check_params_or_die: not called CC=3 SCAR=24.8
| |||||||||||
| 48 | 0 | my ( $class, $args, $param ) = @_; | |||||||||
| 49 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 50 | 0 | for my $key (@$args) { | |||||||||
| 51 | 0 | ▶ | if ( not defined $param->{$key} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | $test_builder->croak("need $key parameter"); | |||||||||
| 53 | } | ||||||||||
| 54 | } | ||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 1 | ▶ | sub _is_obsolete_cvterm { | ||||||||
|
Subroutine
_is_obsolete_cvterm: called CC=1 SCAR=5.5
| |||||||||||
| 58 | 1 | my ($class) = @_; | |||||||||
| 59 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 60 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 61 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 62 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | $class->_check_params_or_die( [qw/cv term/], $param ); | |||||||||
| 65 | |||||||||||
| 66 | 0 | my $result_class; | |||||||||
| 67 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | $result_class = 'Cv::Cvterm'; | |||||||||
| 69 | } | ||||||||||
| 70 | else { | ||||||||||
| 71 | 0 | $result_class = 'Cvterm'; | |||||||||
| 72 | } | ||||||||||
| 73 | my $count = $schema->resultset($result_class)->count( | ||||||||||
| 74 | { 'cv.name' => $param->{cv}, | ||||||||||
| 75 | 'is_obsolete' => 1, | ||||||||||
| 76 | 'me.name' => $param->{term} | ||||||||||
| 77 | }, | ||||||||||
| 78 | 0 | { join => 'cv' } | |||||||||
| 79 | ); | ||||||||||
| 80 | 0 | $test_builder->ok( $count, $msg ); | |||||||||
| 81 | 0 | return $count; | |||||||||
| 82 | 1 | }; | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 1 | ▶ | sub _count_cvterm { | ||||||||
|
Subroutine
_count_cvterm: called CC=1 SCAR=5.4
| |||||||||||
| 86 | 1 | my ($class) = @_; | |||||||||
| 87 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 88 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 89 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 90 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 0 | $class->_check_params_or_die( [qw/cv count/], $param ); | |||||||||
| 93 | |||||||||||
| 94 | 0 | my $result_class; | |||||||||
| 95 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | 0 | $result_class = 'Cv::Cvterm'; | |||||||||
| 97 | } | ||||||||||
| 98 | else { | ||||||||||
| 99 | 0 | $result_class = 'Cvterm'; | |||||||||
| 100 | } | ||||||||||
| 101 | my $count = $schema->resultset($result_class)->count( | ||||||||||
| 102 | { 'cv.name' => $param->{cv}, | ||||||||||
| 103 | 0 | 'is_obsolete' => 0, | |||||||||
| 104 | 'is_relationshiptype' => 0 | ||||||||||
| 105 | }, | ||||||||||
| 106 | { join => 'cv' } | ||||||||||
| 107 | ); | ||||||||||
| 108 | 0 | return $test_builder->is_num( $count, $param->{count}, $msg ); | |||||||||
| 109 | 1 | }; | |||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | 1 | ▶ | sub _count_obsolete_cvterm { | ||||||||
|
Subroutine
_count_obsolete_cvterm: called CC=1 SCAR=5.4
| |||||||||||
| 113 | 1 | my ($class) = @_; | |||||||||
| 114 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 115 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 116 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 117 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 118 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 119 | 0 | $class->_check_params_or_die( [qw/cv count/], $param ); | |||||||||
| 120 | |||||||||||
| 121 | 0 | my $result_class; | |||||||||
| 122 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 123 | 0 | $result_class = 'Cv::Cvterm'; | |||||||||
| 124 | } | ||||||||||
| 125 | else { | ||||||||||
| 126 | 0 | $result_class = 'Cvterm'; | |||||||||
| 127 | } | ||||||||||
| 128 | my $count = $schema->resultset($result_class)->count( | ||||||||||
| 129 | { 'cv.name' => $param->{cv}, | ||||||||||
| 130 | 0 | 'is_obsolete' => 1, | |||||||||
| 131 | }, | ||||||||||
| 132 | { join => 'cv' } | ||||||||||
| 133 | ); | ||||||||||
| 134 | 0 | return $test_builder->is_num( $count, $param->{count}, $msg ); | |||||||||
| 135 | 1 | }; | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | 1 | ▶ | sub _count_relationship_cvterm { | ||||||||
|
Subroutine
_count_relationship_cvterm: called CC=1 SCAR=5.4
| |||||||||||
| 139 | 1 | my ($class) = @_; | |||||||||
| 140 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 141 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 142 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 143 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 144 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 145 | 0 | $class->_check_params_or_die( [qw/cv count/], $param ); | |||||||||
| 146 | |||||||||||
| 147 | 0 | my $result_class; | |||||||||
| 148 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 149 | 0 | $result_class = 'Cv::Cvterm'; | |||||||||
| 150 | } | ||||||||||
| 151 | else { | ||||||||||
| 152 | 0 | $result_class = 'Cvterm'; | |||||||||
| 153 | } | ||||||||||
| 154 | my $count = $schema->resultset($result_class)->count( | ||||||||||
| 155 | { 'cv.name' => $param->{cv}, | ||||||||||
| 156 | 0 | 'is_relationshiptype' => 1, | |||||||||
| 157 | 'is_obsolete' => 0, | ||||||||||
| 158 | 'me.name' => { -not_in => 'is_a' } | ||||||||||
| 159 | }, | ||||||||||
| 160 | { join => 'cv' } | ||||||||||
| 161 | ); | ||||||||||
| 162 | 0 | return $test_builder->is_num( $count, $param->{count}, $msg ); | |||||||||
| 163 | 1 | }; | |||||||||
| 164 | } | ||||||||||
| 165 | |||||||||||
| 166 | 1 | ▶ | sub _count_comment { | ||||||||
|
Subroutine
_count_comment: called CC=1 SCAR=5.4
| |||||||||||
| 167 | 1 | my ($class) = @_; | |||||||||
| 168 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 169 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 170 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 171 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 172 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 173 | 0 | $class->_check_params_or_die( [qw/cv count/], $param ); | |||||||||
| 174 | |||||||||||
| 175 | 0 | my $result_class; | |||||||||
| 176 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 177 | 0 | $result_class = 'Cv::Cvtermprop'; | |||||||||
| 178 | } | ||||||||||
| 179 | else { | ||||||||||
| 180 | 0 | $result_class = 'Cvtermprop'; | |||||||||
| 181 | } | ||||||||||
| 182 | my $count = $schema->resultset($result_class)->count( | ||||||||||
| 183 | { 'cv.name' => $param->{cv}, | ||||||||||
| 184 | 0 | 'cv_2.name' => 'cvterm_property_type', | |||||||||
| 185 | 'type.name' => 'comment' | ||||||||||
| 186 | }, | ||||||||||
| 187 | { join => [ { 'cvterm' => 'cv' }, { 'type' => 'cv' } ] } | ||||||||||
| 188 | ); | ||||||||||
| 189 | 0 | return $test_builder->is_num( $count, $param->{count}, $msg ); | |||||||||
| 190 | 1 | }; | |||||||||
| 191 | } | ||||||||||
| 192 | |||||||||||
| 193 | 1 | ▶ | sub _count_synonym { | ||||||||
|
Subroutine
_count_synonym: called CC=1 SCAR=5.4
| |||||||||||
| 194 | 1 | my ($class) = @_; | |||||||||
| 195 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 196 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 197 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 198 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 199 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 200 | 0 | $class->_check_params_or_die( [qw/cv count/], $param ); | |||||||||
| 201 | |||||||||||
| 202 | 0 | my $result_class; | |||||||||
| 203 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 204 | 0 | $result_class = 'Cv::Cvtermsynonym'; | |||||||||
| 205 | } | ||||||||||
| 206 | else { | ||||||||||
| 207 | 0 | $result_class = 'Cvtermsynonym'; | |||||||||
| 208 | } | ||||||||||
| 209 | my $count = $schema->resultset($result_class)->count( | ||||||||||
| 210 | { 'cv.name' => $param->{cv} }, | ||||||||||
| 211 | 0 | { join => { 'cvterm' => 'cv' } } | |||||||||
| 212 | ); | ||||||||||
| 213 | 0 | return $test_builder->is_num( $count, $param->{count}, $msg ); | |||||||||
| 214 | 1 | }; | |||||||||
| 215 | } | ||||||||||
| 216 | |||||||||||
| 217 | 1 | ▶ | sub _count_alt_id { | ||||||||
|
Subroutine
_count_alt_id: called CC=1 SCAR=5.4
| |||||||||||
| 218 | 1 | my ($class) = @_; | |||||||||
| 219 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 220 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 221 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 222 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 223 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 224 | 0 | $class->_check_params_or_die( [qw/count db/], $param ); | |||||||||
| 225 | |||||||||||
| 226 | 0 | my $result_class; | |||||||||
| 227 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 228 | 0 | $result_class = 'Cv::CvtermDbxref'; | |||||||||
| 229 | } | ||||||||||
| 230 | else { | ||||||||||
| 231 | 0 | $result_class = 'CvtermDbxref'; | |||||||||
| 232 | } | ||||||||||
| 233 | my $count | ||||||||||
| 234 | = $schema->resultset($result_class) | ||||||||||
| 235 | 0 | ->count( { 'db.name' => [ $param->{db}, $param->{cv} ] }, | |||||||||
| 236 | { join => [ { 'dbxref' => 'db' } ] } ); | ||||||||||
| 237 | 0 | return $test_builder->is_num( $count, $param->{count}, $msg ); | |||||||||
| 238 | 1 | }; | |||||||||
| 239 | } | ||||||||||
| 240 | |||||||||||
| 241 | 1 | ▶ | sub _count_subject { | ||||||||
|
Subroutine
_count_subject: called CC=1 SCAR=5.6
| |||||||||||
| 242 | 1 | my ($class) = @_; | |||||||||
| 243 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||
| 244 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 245 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 246 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 247 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 248 | 0 | $class->_check_params_or_die( [qw/cv object count/], $param ); | |||||||||
| 249 | |||||||||||
| 250 | 0 | my $result_class; | |||||||||
| 251 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 252 | 0 | $result_class = 'Cv::CvtermRelationship'; | |||||||||
| 253 | } | ||||||||||
| 254 | else { | ||||||||||
| 255 | 0 | $result_class = 'CvtermRelationship'; | |||||||||
| 256 | } | ||||||||||
| 257 | |||||||||||
| 258 | my $query | ||||||||||
| 259 | = $param->{relationship} | ||||||||||
| 260 | ? { | ||||||||||
| 261 | 'cv.name' => $param->{cv}, | ||||||||||
| 262 | 'object.name' => $param->{object}, | ||||||||||
| 263 | 'type.name' => $param->{relationship} | ||||||||||
| 264 | } | ||||||||||
| 265 | : { | ||||||||||
| 266 | 'object.name' => $param->{object}, | ||||||||||
| 267 | 'cv.name' => $param->{cv} | ||||||||||
| 268 | 0 | ▶ | }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 269 | 0 | my $count | |||||||||
| 270 | = $schema->resultset($result_class) | ||||||||||
| 271 | ->count( $query, { join => [ { 'object' => 'cv' }, 'type' ] } ); | ||||||||||
| 272 | 0 | return $test_builder->is_num( $count, $param->{count}, $msg ); | |||||||||
| 273 | 1 | }; | |||||||||
| 274 | } | ||||||||||
| 275 | |||||||||||
| 276 | 1 | ▶ | sub _count_object { | ||||||||
|
Subroutine
_count_object: called CC=1 SCAR=5.6
| |||||||||||
| 277 | 1 | my ($class) = @_; | |||||||||
| 278 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||
| 279 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 280 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 281 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 282 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 283 | 0 | $class->_check_params_or_die( [qw/cv subject count/], $param ); | |||||||||
| 284 | |||||||||||
| 285 | 0 | my $result_class; | |||||||||
| 286 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 287 | 0 | $result_class = 'Cv::CvtermRelationship'; | |||||||||
| 288 | } | ||||||||||
| 289 | else { | ||||||||||
| 290 | 0 | $result_class = 'CvtermRelationship'; | |||||||||
| 291 | } | ||||||||||
| 292 | |||||||||||
| 293 | my $query | ||||||||||
| 294 | = $param->{relationship} | ||||||||||
| 295 | ? { | ||||||||||
| 296 | 'cv.name' => $param->{cv}, | ||||||||||
| 297 | 'subject.name' => $param->{subject}, | ||||||||||
| 298 | 'type.name' => $param->{relationship} | ||||||||||
| 299 | } | ||||||||||
| 300 | : { | ||||||||||
| 301 | 'cv.name' => $param->{cv}, | ||||||||||
| 302 | 'subject.name' => $param->{subject} | ||||||||||
| 303 | 0 | ▶ | }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 304 | 0 | my $count | |||||||||
| 305 | = $schema->resultset($result_class) | ||||||||||
| 306 | ->count( $query, { join => [ { 'subject' => 'cv' }, 'type' ] } ); | ||||||||||
| 307 | 0 | return $test_builder->is_num( $count, $param->{count}, $msg ); | |||||||||
| 308 | 1 | }; | |||||||||
| 309 | } | ||||||||||
| 310 | |||||||||||
| 311 | 1 | ▶ | sub _has_synonym { | ||||||||
|
Subroutine
_has_synonym: called CC=1 SCAR=5.8
| |||||||||||
| 312 | 1 | my ($class) = @_; | |||||||||
| 313 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||
| 314 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 315 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 316 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 317 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 318 | 0 | $class->_check_params_or_die( [qw/cv term synonym/], $param ); | |||||||||
| 319 | |||||||||||
| 320 | 0 | my $result_class; | |||||||||
| 321 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 322 | 0 | $result_class = 'Cv::Cvterm'; | |||||||||
| 323 | } | ||||||||||
| 324 | else { | ||||||||||
| 325 | 0 | $result_class = 'Cvterm'; | |||||||||
| 326 | } | ||||||||||
| 327 | |||||||||||
| 328 | 0 | my $count; | |||||||||
| 329 | 0 | ▶ | if ( defined $param->{cv} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 330 | $count = $schema->resultset($result_class)->count( | ||||||||||
| 331 | { 'cv.name' => $param->{cv}, | ||||||||||
| 332 | 'me.name' => $param->{term}, | ||||||||||
| 333 | 'cvtermsynonyms.synonym' => $param->{synonym}, | ||||||||||
| 334 | 0 | 'type.name' => { -in => [qw/BROAD EXACT NARROW RELATED/] } | |||||||||
| 335 | }, | ||||||||||
| 336 | { join => [ 'cv', { 'cvtermsynonyms' => 'type' } ] } | ||||||||||
| 337 | ); | ||||||||||
| 338 | } | ||||||||||
| 339 | else { | ||||||||||
| 340 | $count = $schema->resultset($result_class)->count( | ||||||||||
| 341 | { 'me.name' => $param->{term}, | ||||||||||
| 342 | 'cvtermsynonyms.synonym' => $param->{synonym}, | ||||||||||
| 343 | 0 | 'type.name' => { -in => [qw/BROAD EXACT NARROW RELATED/] } | |||||||||
| 344 | }, | ||||||||||
| 345 | { join => [ { 'cvtermsynonyms' => 'type' } ] } | ||||||||||
| 346 | ); | ||||||||||
| 347 | } | ||||||||||
| 348 | 0 | $test_builder->ok( $count, $msg ); | |||||||||
| 349 | 0 | return $count; | |||||||||
| 350 | 1 | }; | |||||||||
| 351 | } | ||||||||||
| 352 | |||||||||||
| 353 | 1 | ▶ | sub _has_alt_id { | ||||||||
|
Subroutine
_has_alt_id: called CC=1 SCAR=6.0
| |||||||||||
| 354 | 1 | my ($class) = @_; | |||||||||
| 355 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||
| 356 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 357 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 358 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 359 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 360 | 0 | $class->_check_params_or_die( [qw/cv term alt_id/], $param ); | |||||||||
| 361 | |||||||||||
| 362 | 0 | my $result_class; | |||||||||
| 363 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 364 | 0 | $result_class = 'Cv::Cvterm'; | |||||||||
| 365 | } | ||||||||||
| 366 | else { | ||||||||||
| 367 | 0 | $result_class = 'Cvterm'; | |||||||||
| 368 | } | ||||||||||
| 369 | 0 | my ( $db, $id ); | |||||||||
| 370 | 0 | ▶ | if ( $param->{alt_id} =~ /:/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 371 | 0 | ( $db, $id ) = split /:/, $param->{alt_id}, 2; | |||||||||
| 372 | } | ||||||||||
| 373 | else { | ||||||||||
| 374 | 0 | $db = $param->{cv}; | |||||||||
| 375 | 0 | $id = $param->{alt_id}; | |||||||||
| 376 | } | ||||||||||
| 377 | |||||||||||
| 378 | 0 | my $count; | |||||||||
| 379 | 0 | ▶ | if ( defined $param->{cv} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 380 | $count = $schema->resultset($result_class)->search( | ||||||||||
| 381 | { 'cv.name' => $param->{cv}, | ||||||||||
| 382 | 'me.name' => $param->{term}, | ||||||||||
| 383 | }, | ||||||||||
| 384 | 0 | { join => 'cv' } | |||||||||
| 385 | )->search_related( 'cvterm_dbxrefs', {} )->search_related( | ||||||||||
| 386 | 'dbxref', | ||||||||||
| 387 | { 'accession' => $id, 'db.name' => $db }, | ||||||||||
| 388 | { join => 'db' } | ||||||||||
| 389 | )->count; | ||||||||||
| 390 | } | ||||||||||
| 391 | else { | ||||||||||
| 392 | $count | ||||||||||
| 393 | = $schema->resultset($result_class) | ||||||||||
| 394 | ->search( { 'name' => $param->{term} } ) | ||||||||||
| 395 | 0 | ->search_related( 'cvterm_dbxrefs', {} )->search_related( | |||||||||
| 396 | 'dbxref', | ||||||||||
| 397 | { 'accession' => $id, 'db.name' => $db }, | ||||||||||
| 398 | { join => 'db' } | ||||||||||
| 399 | )->count; | ||||||||||
| 400 | |||||||||||
| 401 | } | ||||||||||
| 402 | 0 | $test_builder->ok( $count, $msg ); | |||||||||
| 403 | 0 | return $count; | |||||||||
| 404 | 1 | }; | |||||||||
| 405 | } | ||||||||||
| 406 | |||||||||||
| 407 | 1 | ▶ | sub _has_xref { | ||||||||
|
Subroutine
_has_xref: called CC=1 SCAR=6.0
| |||||||||||
| 408 | 1 | my ($class) = @_; | |||||||||
| 409 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||
| 410 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 411 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 412 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 413 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 414 | 0 | $class->_check_params_or_die( [qw/cv term xref/], $param ); | |||||||||
| 415 | |||||||||||
| 416 | 0 | my $result_class; | |||||||||
| 417 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 418 | 0 | $result_class = 'Cv::Cvterm'; | |||||||||
| 419 | } | ||||||||||
| 420 | else { | ||||||||||
| 421 | 0 | $result_class = 'Cvterm'; | |||||||||
| 422 | } | ||||||||||
| 423 | 0 | my ( $db, $id ); | |||||||||
| 424 | 0 | ▶ | if ( $param->{xref} =~ /:/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 425 | 0 | ( $db, $id ) = split /:/, $param->{xref}, 2; | |||||||||
| 426 | } | ||||||||||
| 427 | else { | ||||||||||
| 428 | 0 | $db = '_global'; | |||||||||
| 429 | 0 | $id = $param->{xref}; | |||||||||
| 430 | } | ||||||||||
| 431 | |||||||||||
| 432 | 0 | my $count; | |||||||||
| 433 | 0 | ▶ | if ( defined $param->{cv} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 434 | $count = $schema->resultset($result_class)->search( | ||||||||||
| 435 | { 'cv.name' => $param->{cv}, | ||||||||||
| 436 | 'me.name' => $param->{term}, | ||||||||||
| 437 | }, | ||||||||||
| 438 | 0 | { join => 'cv' } | |||||||||
| 439 | )->search_related( 'cvterm_dbxrefs', {} )->search_related( | ||||||||||
| 440 | 'dbxref', | ||||||||||
| 441 | { 'accession' => $id, 'db.name' => $db }, | ||||||||||
| 442 | { join => 'db' } | ||||||||||
| 443 | )->count; | ||||||||||
| 444 | } | ||||||||||
| 445 | else { | ||||||||||
| 446 | $count | ||||||||||
| 447 | = $schema->resultset($result_class) | ||||||||||
| 448 | ->search( { 'name' => $param->{term} } ) | ||||||||||
| 449 | 0 | ->search_related( 'cvterm_dbxrefs', {} )->search_related( | |||||||||
| 450 | 'dbxref', | ||||||||||
| 451 | { 'accession' => $id, 'db.name' => $db }, | ||||||||||
| 452 | { join => 'db' } | ||||||||||
| 453 | )->count; | ||||||||||
| 454 | |||||||||||
| 455 | } | ||||||||||
| 456 | 0 | $test_builder->ok( $count, $msg ); | |||||||||
| 457 | 0 | return $count; | |||||||||
| 458 | 1 | }; | |||||||||
| 459 | } | ||||||||||
| 460 | |||||||||||
| 461 | 1 | ▶ | sub _has_comment { | ||||||||
|
Subroutine
_has_comment: called CC=1 SCAR=5.8
| |||||||||||
| 462 | 1 | my ($class) = @_; | |||||||||
| 463 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||
| 464 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 465 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 466 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 467 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 468 | 0 | $class->_check_params_or_die( [qw/cv term comment/], $param ); | |||||||||
| 469 | |||||||||||
| 470 | 0 | my $result_class; | |||||||||
| 471 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 472 | 0 | $result_class = 'Cv::Cvterm'; | |||||||||
| 473 | } | ||||||||||
| 474 | else { | ||||||||||
| 475 | 0 | $result_class = 'Cvterm'; | |||||||||
| 476 | } | ||||||||||
| 477 | |||||||||||
| 478 | 0 | my $count; | |||||||||
| 479 | 0 | ▶ | if ( $param->{cv} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 480 | $count = $schema->resultset($result_class)->search( | ||||||||||
| 481 | { 'cv.name' => $param->{cv}, | ||||||||||
| 482 | 'me.name' => $param->{term}, | ||||||||||
| 483 | }, | ||||||||||
| 484 | { join => 'cv' } | ||||||||||
| 485 | )->search_related( | ||||||||||
| 486 | 'cvtermprops', | ||||||||||
| 487 | { 'value' => $param->{comment}, | ||||||||||
| 488 | 0 | 'type.name' => 'comment', | |||||||||
| 489 | 'cv_2.name' => 'cvterm_property_type' | ||||||||||
| 490 | }, | ||||||||||
| 491 | { join => { 'type' => 'cv' } } | ||||||||||
| 492 | )->count; | ||||||||||
| 493 | } | ||||||||||
| 494 | else { | ||||||||||
| 495 | $count | ||||||||||
| 496 | = $schema->resultset($result_class) | ||||||||||
| 497 | ->search( { 'name' => $param->{term}, }, )->search_related( | ||||||||||
| 498 | 'cvtermprops', | ||||||||||
| 499 | { 'value' => $param->{comment}, | ||||||||||
| 500 | 0 | 'type.name' => 'comment', | |||||||||
| 501 | 'cv_2.name' => 'cvterm_property_type' | ||||||||||
| 502 | }, | ||||||||||
| 503 | { join => { 'type' => 'cv' } } | ||||||||||
| 504 | )->count; | ||||||||||
| 505 | |||||||||||
| 506 | } | ||||||||||
| 507 | 0 | $test_builder->ok( $count, $msg ); | |||||||||
| 508 | 0 | return $count; | |||||||||
| 509 | 1 | }; | |||||||||
| 510 | } | ||||||||||
| 511 | |||||||||||
| 512 | 1 | ▶ | sub _has_relationship { | ||||||||
|
Subroutine
_has_relationship: called CC=1 SCAR=5.5
| |||||||||||
| 513 | 1 | my ($class) = @_; | |||||||||
| 514 | 0 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 515 | 0 | my ( $schema, $param, $msg ) = @_; | |||||||||
| 516 | 0 | my $test_builder = $class->test_builder; | |||||||||
| 517 | 0 | ▶ | $test_builder->croak('need a schema') if !$schema; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 518 | 0 | ▶ | $test_builder->croak('need options') if !$param; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 519 | 0 | $class->_check_params_or_die( [qw/object subject relationship/], | |||||||||
| 520 | $param ); | ||||||||||
| 521 | |||||||||||
| 522 | 0 | my $result_class; | |||||||||
| 523 | 0 | ▶ | if ( $schema->isa('Bio::Chado::Schema') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 524 | 0 | $result_class = 'Cv::CvtermRelationship'; | |||||||||
| 525 | } | ||||||||||
| 526 | else { | ||||||||||
| 527 | 0 | $result_class = 'CvtermRelationship'; | |||||||||
| 528 | } | ||||||||||
| 529 | |||||||||||
| 530 | my $count = $schema->resultset($result_class)->count( | ||||||||||
| 531 | { 'object.name' => $param->{object}, | ||||||||||
| 532 | 'subject.name' => $param->{subject}, | ||||||||||
| 533 | 'type.name' => $param->{relationship} | ||||||||||
| 534 | }, | ||||||||||
| 535 | 0 | { join => [ 'subject', 'object', 'type' ] } | |||||||||
| 536 | ); | ||||||||||
| 537 | 0 | $test_builder->ok( $count, $msg ); | |||||||||
| 538 | 0 | return $count; | |||||||||
| 539 | } | ||||||||||
| 540 | 1 | } | |||||||||
| 541 | |||||||||||
| 542 | 1 | 1; | |||||||||
| 543 | |||||||||||
| 544 | __END__ | ||||||||||