AnalysisJob.pm 3.42 KB
Newer Older
Jessica Severin's avatar
Jessica Severin committed
1 2 3 4 5 6 7
#
# You may distribute this module under the same terms as perl itself

=pod 

=head1 NAME

Jessica Severin's avatar
Jessica Severin committed
8
  Bio::EnsEMBL::Hive::AnalysisJob
Jessica Severin's avatar
Jessica Severin committed
9 10

=head1 DESCRIPTION
Jessica Severin's avatar
Jessica Severin committed
11

12
  An AnalysisJob is the link between the input_id control data, the analysis and
Jessica Severin's avatar
Jessica Severin committed
13
  the rule system.  It also tracks the state of the job as it is processed
Jessica Severin's avatar
Jessica Severin committed
14 15

=head1 CONTACT
Jessica Severin's avatar
Jessica Severin committed
16

17
  Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.
Jessica Severin's avatar
Jessica Severin committed
18 19

=head1 APPENDIX
Jessica Severin's avatar
Jessica Severin committed
20

21 22
  The rest of the documentation details each of the object methods.
  Internal methods are usually preceded with a _
Jessica Severin's avatar
Jessica Severin committed
23

Jessica Severin's avatar
Jessica Severin committed
24 25
=cut

26

Jessica Severin's avatar
Jessica Severin committed
27 28 29 30 31 32 33 34
package Bio::EnsEMBL::Hive::AnalysisJob;

use strict;

use Bio::EnsEMBL::Analysis;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::Worker;

35 36 37 38 39
sub new {
  my ($class,@args) = @_;
  my $self = bless {}, $class;
  return $self;
}
Jessica Severin's avatar
Jessica Severin committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53

sub adaptor {
  my $self = shift;
  $self->{'_adaptor'} = shift if(@_);
  return $self->{'_adaptor'};
}

sub dbID {
  my $self = shift;
  $self->{'_dbID'} = shift if(@_);
  return $self->{'_dbID'};
}

sub input_id {
54 55
  my $self = shift;
  $self->{'_input_id'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
56 57 58
  return $self->{'_input_id'};
}

Leo Gordon's avatar
Leo Gordon committed
59
sub worker_id {
Jessica Severin's avatar
Jessica Severin committed
60
  my $self = shift;
Leo Gordon's avatar
Leo Gordon committed
61 62
  $self->{'_worker_id'} = shift if(@_);
  return $self->{'_worker_id'};
Jessica Severin's avatar
Jessica Severin committed
63 64 65
}

sub analysis_id {
66 67
  my $self = shift;
  $self->{'_analysis_id'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
68 69 70 71
  return $self->{'_analysis_id'};
}

sub job_claim {
72 73
  my $self = shift;
  $self->{'_job_claim'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
74 75 76 77
  return $self->{'_job_claim'};
}

sub status {
78 79
  my $self = shift;
  $self->{'_status'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
80 81 82
  return $self->{'_status'};
}

83 84 85 86 87 88 89
sub update_status {
  my ($self, $status ) = @_;
  return unless($self->adaptor);
  $self->status($status);
  $self->adaptor->update_status($self);
}

Jessica Severin's avatar
Jessica Severin committed
90
sub retry_count {
91 92
  my $self = shift;
  $self->{'_retry_count'} = shift if(@_);
93
  $self->{'_retry_count'} = 0 unless(defined($self->{'_retry_count'}));
Jessica Severin's avatar
Jessica Severin committed
94 95 96 97
  return $self->{'_retry_count'};
}

sub completed {
98 99
  my $self = shift;
  $self->{'_completed'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
100 101 102
  return $self->{'_completed'};
}

103
sub runtime_msec {
104 105
  my $self = shift;
  $self->{'_runtime_msec'} = shift if(@_);
106 107 108 109 110
  $self->{'_runtime_msec'} = 0 unless(defined($self->{'_runtime_msec'}));
  return $self->{'_runtime_msec'};
}

sub query_count {
111 112
  my $self = shift;
  $self->{'_query_count'} = shift if(@_);
113 114 115 116
  $self->{'_query_count'} = 0 unless(defined($self->{'_query_count'}));
  return $self->{'_query_count'};
}

Jessica Severin's avatar
Jessica Severin committed
117
sub branch_code {
118 119
  my $self = shift;
  $self->{'_branch_code'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
120 121 122 123
  $self->{'_branch_code'} = 1 unless(defined($self->{'_branch_code'}));
  return $self->{'_branch_code'};
}

124 125 126 127 128 129 130 131 132 133 134 135 136
sub semaphore_count {
  my $self = shift;
  $self->{'_semaphore_count'} = shift if(@_);
  $self->{'_semaphore_count'} = 0 unless(defined($self->{'_semaphore_count'}));
  return $self->{'_semaphore_count'};
}

sub semaphored_job_id {
  my $self = shift;
  $self->{'_semaphored_job_id'} = shift if(@_);
  return $self->{'_semaphored_job_id'};
}

Jessica Severin's avatar
Jessica Severin committed
137
sub stdout_file {
138 139
  my $self = shift;
  $self->{'_stdout_file'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
140 141 142 143
  return $self->{'_stdout_file'};
}

sub stderr_file {
144 145
  my $self = shift;
  $self->{'_stderr_file'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
146 147 148 149 150
  return $self->{'_stderr_file'};
}

sub print_job {
  my $self = shift;
Leo Gordon's avatar
Leo Gordon committed
151 152 153 154 155
  my $logic_name = $self->adaptor()
      ? $self->adaptor->db->get_AnalysisAdaptor->fetch_by_dbID($self->analysis_id)->logic_name()
      : '';

  printf("job_id=%d %35s(%5d) retry=%d input_id='%s'\n", 
Jessica Severin's avatar
Jessica Severin committed
156 157 158 159 160
       $self->dbID,
       $logic_name,
       $self->analysis_id,
       $self->retry_count,
       $self->input_id);
Jessica Severin's avatar
Jessica Severin committed
161 162 163
}

1;