AnalysisJob.pm 2.92 KB
Newer Older
Jessica Severin's avatar
Jessica Severin committed
1
2
3
4
5
6
7
8
9
#
# You may distribute this module under the same terms as perl itself
#
# POD documentation - main docs before the code

=pod 

=head1 NAME

Jessica Severin's avatar
Jessica Severin committed
10
  Bio::EnsEMBL::Hive::AnalysisJob
Jessica Severin's avatar
Jessica Severin committed
11
12

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

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

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

19
20
  Contact Jessica Severin on EnsEMBL::Hive implemetation/design detail: jessica@ebi.ac.uk
  Contact Ewan Birney on EnsEMBL in general: birney@sanger.ac.uk
Jessica Severin's avatar
Jessica Severin committed
21
22

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

24
25
  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
26

Jessica Severin's avatar
Jessica Severin committed
27
28
29
30
31
32
33
34
35
36
=cut

package Bio::EnsEMBL::Hive::AnalysisJob;

use strict;

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

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

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 {
56
57
  my $self = shift;
  $self->{'_input_id'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
58
59
60
61
62
63
64
65
66
67
  return $self->{'_input_id'};
}

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

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

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

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

85
86
87
88
89
90
91
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
92
sub retry_count {
93
94
  my $self = shift;
  $self->{'_retry_count'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
95
96
97
98
  return $self->{'_retry_count'};
}

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

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

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

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

sub stdout_file {
126
127
  my $self = shift;
  $self->{'_stdout_file'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
128
129
130
131
  return $self->{'_stdout_file'};
}

sub stderr_file {
132
133
  my $self = shift;
  $self->{'_stderr_file'} = shift if(@_);
Jessica Severin's avatar
Jessica Severin committed
134
135
136
137
138
139
140
141
142
143
144
145
  return $self->{'_stderr_file'};
}

sub print_job {
  my $self = shift;
  print("WORKER: hive_id=",$self->hive_id,
     " host=",$self->host,
     " ppid=",$self->process_id,
     "\n");  
}

1;