| 1 | =head1 LICENSE | ||
| 2 | |||
| 3 | See the NOTICE file distributed with this work for additional information | ||
| 4 | regarding copyright ownership. | ||
| 5 | |||
| 6 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 7 | you may not use this file except in compliance with the License. | ||
| 8 | You may obtain a copy of the License at | ||
| 9 | |||
| 10 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | |||
| 12 | Unless required by applicable law or agreed to in writing, software | ||
| 13 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 15 | See the License for the specific language governing permissions and | ||
| 16 | limitations under the License. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | |||
| 21 | =head1 CONTACT | ||
| 22 | |||
| 23 | Please email comments or questions to the public Ensembl | ||
| 24 | developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. | ||
| 25 | |||
| 26 | Questions may also be sent to the Ensembl help desk at | ||
| 27 | <http://www.ensembl.org/Help/Contact>. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | Bio::EnsEMBL::Analysis.pm - Stores details of an analysis run | ||
| 34 | |||
| 35 | =head1 SYNOPSIS | ||
| 36 | |||
| 37 | my $obj = new Bio::EnsEMBL::Analysis( | ||
| 38 | -id => $id, | ||
| 39 | -logic_name => 'SWIRBlast', | ||
| 40 | -db => $db, | ||
| 41 | -db_version => $db_version, | ||
| 42 | -db_file => $db_file, | ||
| 43 | -program => $program, | ||
| 44 | -program_version => $program_version, | ||
| 45 | -program_file => $program_file, | ||
| 46 | -gff_source => $gff_source, | ||
| 47 | -gff_feature => $gff_feature, | ||
| 48 | -module => $module, | ||
| 49 | -module_version => $module_version, | ||
| 50 | -parameters => $parameters, | ||
| 51 | -created => $created, | ||
| 52 | -description => 'some warm words about this analysis', | ||
| 53 | -display_label => 'UNIprot alignment', | ||
| 54 | -displayable => '1', | ||
| 55 | -web_data => 'web metadata info' | ||
| 56 | ); | ||
| 57 | |||
| 58 | =head1 DESCRIPTION | ||
| 59 | |||
| 60 | Object to store details of an analysis run. | ||
| 61 | |||
| 62 | =head1 METHODS | ||
| 63 | |||
| 64 | =cut | ||
| 65 | |||
| 66 | package Bio::EnsEMBL::Analysis; | ||
| 67 | $Bio::EnsEMBL::Analysis::VERSION = '114.0.0_50'; # TRIAL | ||
| 68 | $Bio::EnsEMBL::Analysis::VERSION = '114.0.050'; | ||
| 69 | use vars qw(@ISA); | ||
| 70 | use strict; | ||
| 71 | |||
| 72 | use Bio::EnsEMBL::Storable; | ||
| 73 | |||
| 74 | use Bio::EnsEMBL::Utils::Exception qw(throw); | ||
| 75 | use Bio::EnsEMBL::Utils::Argument qw(rearrange); | ||
| 76 | |||
| 77 | use base 'Bio::EnsEMBL::Storable'; | ||
| 78 | |||
| 79 | |||
| 80 | =head2 new | ||
| 81 | |||
| 82 | Arg [..] : Takes a set of named arguments | ||
| 83 | Example : $analysis = new Bio::EnsEMBL::Analysis::Analysis( | ||
| 84 | -id => $id, | ||
| 85 | -logic_name => 'SWIRBlast', | ||
| 86 | -db => $db, | ||
| 87 | -db_version => $db_version, | ||
| 88 | -db_file => $db_file, | ||
| 89 | -program => $program, | ||
| 90 | -program_version => $program_version, | ||
| 91 | -program_file => $program_file, | ||
| 92 | -gff_source => $gff_source, | ||
| 93 | -gff_feature => $gff_feature, | ||
| 94 | -module => $module, | ||
| 95 | -module_version => $module_version, | ||
| 96 | -parameters => $parameters, | ||
| 97 | -created => $created ); | ||
| 98 | Description: Creates a new Analysis object | ||
| 99 | Returntype : Bio::EnsEMBL::Analysis | ||
| 100 | Exceptions : none | ||
| 101 | Caller : general | ||
| 102 | Status : Stable | ||
| 103 | |||
| 104 | =cut | ||
| 105 | |||
| 106 | sub new { | ||
| 107 | my($class,@args) = @_; | ||
| 108 | |||
| 109 | my $self = bless {},$class; | ||
| 110 | |||
| 111 | my ($id, $adaptor, $db, $db_version, $db_file, $program, $program_version, | ||
| 112 | $program_file, $gff_source, $gff_feature, $module, $module_version, | ||
| 113 | $parameters, $created, $logic_name, $description, $display_label, | ||
| 114 | $displayable, $web_data) = | ||
| 115 | |||
| 116 | rearrange([qw(ID | ||
| 117 | ADAPTOR | ||
| 118 | DB | ||
| 119 | DB_VERSION | ||
| 120 | DB_FILE | ||
| 121 | PROGRAM | ||
| 122 | PROGRAM_VERSION | ||
| 123 | PROGRAM_FILE | ||
| 124 | GFF_SOURCE | ||
| 125 | GFF_FEATURE | ||
| 126 | MODULE | ||
| 127 | MODULE_VERSION | ||
| 128 | PARAMETERS | ||
| 129 | CREATED | ||
| 130 | LOGIC_NAME | ||
| 131 | DESCRIPTION | ||
| 132 | DISPLAY_LABEL | ||
| 133 | DISPLAYABLE | ||
| 134 | WEB_DATA | ||
| 135 | )],@args); | ||
| 136 | |||
| 137 | $displayable ||= 0; | ||
| 138 | |||
| 139 | $self->dbID ($id); | ||
| 140 | $self->adaptor ($adaptor); | ||
| 141 | $self->db ($db); | ||
| 142 | $self->db_version ($db_version); | ||
| 143 | $self->db_file ($db_file); | ||
| 144 | $self->program ($program); | ||
| 145 | $self->program_version($program_version); | ||
| 146 | $self->program_file ($program_file); | ||
| 147 | $self->module ($module); | ||
| 148 | $self->module_version ($module_version); | ||
| 149 | $self->gff_source ($gff_source); | ||
| 150 | $self->gff_feature ($gff_feature); | ||
| 151 | $self->parameters ($parameters); | ||
| 152 | $self->created ($created); | ||
| 153 | $self->logic_name ( $logic_name ); | ||
| 154 | $self->description( $description ); | ||
| 155 | $self->display_label( $display_label ); | ||
| 156 | $self->displayable( $displayable ); | ||
| 157 | $self->web_data ( $web_data ); | ||
| 158 | return $self; # success - we hope! | ||
| 159 | } | ||
| 160 | |||
| 161 | |||
| 162 | =head2 db | ||
| 163 | |||
| 164 | Arg [1] : string $db | ||
| 165 | Description: get/set for the attribute db | ||
| 166 | Returntype : string | ||
| 167 | Exceptions : none | ||
| 168 | Caller : general | ||
| 169 | Status : Stable | ||
| 170 | |||
| 171 | =cut | ||
| 172 | |||
| 173 | sub db { | ||
| 174 | my ($self,$arg) = @_; | ||
| 175 | |||
| 176 | if (defined($arg)) { | ||
| 177 | $self->{_db} = $arg; | ||
| 178 | } | ||
| 179 | |||
| 180 | return $self->{_db}; | ||
| 181 | } | ||
| 182 | |||
| 183 | |||
| 184 | =head2 db_version | ||
| 185 | |||
| 186 | Arg [1] : string $db_version | ||
| 187 | Description: get/set for attribute db_version | ||
| 188 | Returntype : string | ||
| 189 | Exceptions : none | ||
| 190 | Caller : general | ||
| 191 | Status : Stable | ||
| 192 | |||
| 193 | =cut | ||
| 194 | |||
| 195 | sub db_version { | ||
| 196 | my ($self,$arg) = @_; | ||
| 197 | |||
| 198 | if (defined($arg)) { | ||
| 199 | $self->{_db_version} = $arg; | ||
| 200 | } | ||
| 201 | |||
| 202 | return $self->{_db_version}; | ||
| 203 | } | ||
| 204 | |||
| 205 | |||
| 206 | =head2 db_file | ||
| 207 | |||
| 208 | Arg [1] : string $db_file | ||
| 209 | Description: get/set for attribute db_file | ||
| 210 | Returntype : string | ||
| 211 | Exceptions : none | ||
| 212 | Caller : general | ||
| 213 | Status : Stable | ||
| 214 | |||
| 215 | =cut | ||
| 216 | |||
| 217 | sub db_file { | ||
| 218 | my ($self,$arg) = @_; | ||
| 219 | |||
| 220 | if (defined($arg)) { | ||
| 221 | $self->{_db_file} = $arg; | ||
| 222 | } | ||
| 223 | |||
| 224 | return $self->{_db_file}; | ||
| 225 | } | ||
| 226 | |||
| 227 | |||
| 228 | |||
| 229 | =head2 program | ||
| 230 | |||
| 231 | Arg [1] : string $program | ||
| 232 | Description: get/set for attribute program | ||
| 233 | Returntype : string | ||
| 234 | Exceptions : none | ||
| 235 | Caller : general | ||
| 236 | Status : Stable | ||
| 237 | |||
| 238 | =cut | ||
| 239 | |||
| 240 | sub program { | ||
| 241 | my ($self,$arg) = @_; | ||
| 242 | |||
| 243 | if (defined($arg)) { | ||
| 244 | $self->{_program} = $arg; | ||
| 245 | } | ||
| 246 | |||
| 247 | return $self->{_program}; | ||
| 248 | } | ||
| 249 | |||
| 250 | |||
| 251 | =head2 program_version | ||
| 252 | |||
| 253 | Arg [1] : string $program_version | ||
| 254 | Description: get/set for attribute program_version | ||
| 255 | Returntype : string | ||
| 256 | Exceptions : none | ||
| 257 | Caller : general | ||
| 258 | Status : Stable | ||
| 259 | |||
| 260 | =cut | ||
| 261 | |||
| 262 | sub program_version { | ||
| 263 | my ($self,$arg) = @_; | ||
| 264 | |||
| 265 | if (defined($arg)) { | ||
| 266 | $self->{_program_version} = $arg; | ||
| 267 | } | ||
| 268 | |||
| 269 | return $self->{_program_version}; | ||
| 270 | } | ||
| 271 | |||
| 272 | |||
| 273 | =head2 program_file | ||
| 274 | |||
| 275 | Arg [1] : string $program_file | ||
| 276 | Description: get/set for attribute program_file | ||
| 277 | Returntype : string | ||
| 278 | Exceptions : none | ||
| 279 | Caller : general | ||
| 280 | Status : Stable | ||
| 281 | |||
| 282 | =cut | ||
| 283 | |||
| 284 | sub program_file { | ||
| 285 | my ($self,$arg) = @_; | ||
| 286 | |||
| 287 | if (defined($arg)) { | ||
| 288 | $self->{_program_file} = $arg; | ||
| 289 | } | ||
| 290 | |||
| 291 | return $self->{_program_file}; | ||
| 292 | } | ||
| 293 | |||
| 294 | |||
| 295 | =head2 module | ||
| 296 | |||
| 297 | Arg [1] : string $module | ||
| 298 | Description: get/set for attribute module. Usually a RunnableDB perl | ||
| 299 | module that executes this analysis job. | ||
| 300 | Returntype : string | ||
| 301 | Exceptions : none | ||
| 302 | Caller : general | ||
| 303 | Status : Stable | ||
| 304 | |||
| 305 | =cut | ||
| 306 | |||
| 307 | sub module { | ||
| 308 | my ($self,$arg) = @_; | ||
| 309 | |||
| 310 | if (defined($arg)) { | ||
| 311 | $self->{_module} = $arg; | ||
| 312 | } | ||
| 313 | |||
| 314 | return $self->{_module}; | ||
| 315 | } | ||
| 316 | |||
| 317 | |||
| 318 | =head2 module_version | ||
| 319 | |||
| 320 | Arg [1] : string $module_version | ||
| 321 | Description: get/set for attribute module_version | ||
| 322 | Returntype : string | ||
| 323 | Exceptions : none | ||
| 324 | Caller : general | ||
| 325 | Status : Stable | ||
| 326 | |||
| 327 | =cut | ||
| 328 | |||
| 329 | sub module_version { | ||
| 330 | my ($self,$arg) = @_; | ||
| 331 | |||
| 332 | if (defined($arg)) { | ||
| 333 | $self->{_module_version} = $arg; | ||
| 334 | } | ||
| 335 | |||
| 336 | return $self->{_module_version}; | ||
| 337 | } | ||
| 338 | |||
| 339 | |||
| 340 | =head2 gff_source | ||
| 341 | |||
| 342 | Arg [1] : string $gff_source | ||
| 343 | Description: get/set for attribute gff_source | ||
| 344 | Returntype : string | ||
| 345 | Exceptions : none | ||
| 346 | Caller : general | ||
| 347 | Status : Stable | ||
| 348 | |||
| 349 | =cut | ||
| 350 | |||
| 351 | sub gff_source { | ||
| 352 | my ($self,$arg) = @_; | ||
| 353 | |||
| 354 | if (defined($arg)) { | ||
| 355 | $self->{_gff_source} = $arg; | ||
| 356 | } | ||
| 357 | |||
| 358 | return $self->{_gff_source}; | ||
| 359 | } | ||
| 360 | |||
| 361 | |||
| 362 | =head2 gff_feature | ||
| 363 | |||
| 364 | Arg [1] : string $gff_feature | ||
| 365 | Description: get/set for attribute gff_feature | ||
| 366 | Returntype : string | ||
| 367 | Exceptions : none | ||
| 368 | Caller : general | ||
| 369 | Status : Stable | ||
| 370 | |||
| 371 | =cut | ||
| 372 | |||
| 373 | sub gff_feature { | ||
| 374 | my ($self,$arg) = @_; | ||
| 375 | |||
| 376 | if (defined($arg)) { | ||
| 377 | $self->{_gff_feature} = $arg; | ||
| 378 | } | ||
| 379 | |||
| 380 | return $self->{_gff_feature}; | ||
| 381 | } | ||
| 382 | |||
| 383 | |||
| 384 | =head2 parameters | ||
| 385 | |||
| 386 | Arg [1] : string $parameters | ||
| 387 | Description: get/set for attribute parameters. This should be evaluated | ||
| 388 | by the module if given or the program that is specified. | ||
| 389 | Returntype : string | ||
| 390 | Exceptions : none | ||
| 391 | Caller : general | ||
| 392 | Status : Stable | ||
| 393 | |||
| 394 | =cut | ||
| 395 | |||
| 396 | sub parameters { | ||
| 397 | my ($self,$arg) = @_; | ||
| 398 | |||
| 399 | if (defined($arg)) { | ||
| 400 | $self->{_parameters} = $arg; | ||
| 401 | } | ||
| 402 | |||
| 403 | return $self->{_parameters}; | ||
| 404 | } | ||
| 405 | |||
| 406 | |||
| 407 | =head2 created | ||
| 408 | |||
| 409 | Arg [1] : string $created | ||
| 410 | Description: get/set for attribute created time. | ||
| 411 | Returntype : string | ||
| 412 | Exceptions : none | ||
| 413 | Caller : general | ||
| 414 | Status : Stable | ||
| 415 | |||
| 416 | =cut | ||
| 417 | |||
| 418 | sub created { | ||
| 419 | my ($self,$arg) = @_; | ||
| 420 | |||
| 421 | if (defined($arg)) { | ||
| 422 | $self->{_created} = $arg; | ||
| 423 | } | ||
| 424 | |||
| 425 | return $self->{_created}; | ||
| 426 | } | ||
| 427 | |||
| 428 | |||
| 429 | =head2 logic_name | ||
| 430 | |||
| 431 | Arg [1] : string $logic_name | ||
| 432 | Description: Get/set method for the logic_name, the name under | ||
| 433 | which this typical analysis is known. | ||
| 434 | Returntype : string | ||
| 435 | Exceptions : none | ||
| 436 | Caller : general | ||
| 437 | Status : Stable | ||
| 438 | |||
| 439 | =cut | ||
| 440 | |||
| 441 | sub logic_name { | ||
| 442 | my ($self, $arg ) = @_; | ||
| 443 | ( defined $arg ) && | ||
| 444 | ($self->{_logic_name} = $arg); | ||
| 445 | $self->{_logic_name}; | ||
| 446 | } | ||
| 447 | |||
| 448 | |||
| 449 | =head2 has_database | ||
| 450 | |||
| 451 | Args : none | ||
| 452 | Description: tests if the db attribute is set, returns 1 if so, | ||
| 453 | 0 if not. | ||
| 454 | Returntype : int 0,1 | ||
| 455 | Exceptions : none | ||
| 456 | Caller : general | ||
| 457 | Status : Stable | ||
| 458 | |||
| 459 | =cut | ||
| 460 | |||
| 461 | sub has_database{ | ||
| 462 | my ($self,@args) = @_; | ||
| 463 | |||
| 464 | if( defined $self->db ){ return 1; } | ||
| 465 | return 0; | ||
| 466 | } | ||
| 467 | |||
| 468 | |||
| 469 | =head2 description | ||
| 470 | |||
| 471 | Arg [1] : string $description | ||
| 472 | Example : none | ||
| 473 | Description: get/set for attribute description | ||
| 474 | Returntype : string | ||
| 475 | Exceptions : none | ||
| 476 | Caller : general | ||
| 477 | Status : Stable | ||
| 478 | |||
| 479 | =cut | ||
| 480 | |||
| 481 | sub description { | ||
| 482 | my ($self,$arg) = @_; | ||
| 483 | |||
| 484 | if (defined($arg)) { | ||
| 485 | $self->{_description} = $arg; | ||
| 486 | } | ||
| 487 | |||
| 488 | return $self->{_description}; | ||
| 489 | } | ||
| 490 | |||
| 491 | |||
| 492 | =head2 display_label | ||
| 493 | |||
| 494 | Arg [1] : string $display_label | ||
| 495 | Description: get/set for attribute display_label | ||
| 496 | Returntype : string | ||
| 497 | Exceptions : none | ||
| 498 | Caller : general | ||
| 499 | Status : Stable | ||
| 500 | |||
| 501 | =cut | ||
| 502 | |||
| 503 | sub display_label { | ||
| 504 | my ($self,$arg) = @_; | ||
| 505 | |||
| 506 | if (defined($arg)) { | ||
| 507 | $self->{_display_label} = $arg; | ||
| 508 | } | ||
| 509 | |||
| 510 | return $self->{_display_label}; | ||
| 511 | } | ||
| 512 | |||
| 513 | =head2 displayable | ||
| 514 | |||
| 515 | Arg [1] : string $displayable | ||
| 516 | Description: get/set for attribute displayable | ||
| 517 | Returntype : string | ||
| 518 | Exceptions : none | ||
| 519 | Caller : general | ||
| 520 | Status : Stable | ||
| 521 | |||
| 522 | =cut | ||
| 523 | |||
| 524 | sub displayable { | ||
| 525 | my ($self,$arg) = @_; | ||
| 526 | |||
| 527 | if (defined($arg)) { | ||
| 528 | $self->{_displayable} = $arg; | ||
| 529 | } | ||
| 530 | |||
| 531 | return $self->{_displayable}; | ||
| 532 | } | ||
| 533 | |||
| 534 | |||
| 535 | =head2 web_data | ||
| 536 | |||
| 537 | Arg [1] : string $web_data | ||
| 538 | Description: get/set for attribute web_data | ||
| 539 | Returntype : string | ||
| 540 | Exceptions : none | ||
| 541 | Caller : general | ||
| 542 | Status : Stable | ||
| 543 | |||
| 544 | =cut | ||
| 545 | # See also _objFromHashref in AnalysisAdaptor for context. | ||
| 546 | sub web_data { | ||
| 547 | my ($self,$arg) = @_; | ||
| 548 | |||
| 549 | if (defined($arg)) { | ||
| 550 | $self->{_web_data} = $arg; | ||
| 551 | } | ||
| 552 | |||
| 553 | return $self->{_web_data}; | ||
| 554 | } | ||
| 555 | |||
| 556 | =head2 compare | ||
| 557 | |||
| 558 | Arg 1 : Bio::EnsEMBL::Analysis $ana | ||
| 559 | The analysis to compare to | ||
| 560 | Description: returns 1 if this analysis is special case of given analysis | ||
| 561 | returns 0 if they are equal | ||
| 562 | returns -1 if they are completely different | ||
| 563 | Returntype : int -1,0,1 | ||
| 564 | Exceptions : none | ||
| 565 | Caller : unknown | ||
| 566 | Status : Stable | ||
| 567 | |||
| 568 | =cut | ||
| 569 | |||
| 570 | sub compare { | ||
| 571 | my ($self, $ana ) = @_; | ||
| 572 | |||
| 573 | throw("Object is not a Bio::EnsEMBL::Analysis") | ||
| 574 | unless $ana->isa("Bio::EnsEMBL::Analysis"); | ||
| 575 | |||
| 576 | my $detail = 0; | ||
| 577 | |||
| 578 | foreach my $methodName ( 'program', 'program_version', 'program_file', | ||
| 579 | 'db','db_version','db_file','gff_source','gff_feature', 'module', | ||
| 580 | 'module_version', 'parameters','logic_name' ) { | ||
| 581 | if( defined $self->$methodName() && ! $ana->can($methodName )) { | ||
| 582 | $detail = 1; | ||
| 583 | } | ||
| 584 | if( defined $self->$methodName() && ! defined $ana->$methodName() ) { | ||
| 585 | $detail = 1; | ||
| 586 | } | ||
| 587 | # if given anal is different from this, defined or not, then its different | ||
| 588 | if( defined($ana->$methodName()) && defined($self->$methodName()) && | ||
| 589 | ( $self->$methodName() ne $ana->$methodName() )) { | ||
| 590 | return -1; | ||
| 591 | } | ||
| 592 | } | ||
| 593 | if( $detail == 1 ) { return 1 }; | ||
| 594 | return 0; | ||
| 595 | } | ||
| 596 | |||
| 597 | |||
| 598 | 1; | ||
| 599 | |||
| 600 | |||
| 601 | |||
| 602 | |||
| 603 | |||
| 604 | |||
| 605 | |||
| 606 | |||
| 607 | |||
| 608 | |||
| 609 | |||
| 610 | |||
| 611 | |||
| 612 | |||
| 613 | |||
| 614 |