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