Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
blast_tool.hpp
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
21 #ifndef BLAST_TOOL_HPP
22 #define BLAST_TOOL_HPP
23 
24 #include <vector>
25 
26 #include "blast_app_parameters.h"
27 #include "blast_formatter.h"
28 #include "blast_service_api.h"
29 #include "byte_buffer.h"
30 
31 #include "service_job.h"
32 
33 
34 /* forward declaration */
35 struct BlastServiceData;
36 struct BlastServiceJob;
37 
44 {
45 public:
46 
57  BlastTool (BlastServiceJob *job_p, const char *name_s, const char *factory_s, const BlastServiceData *data_p, const uint32 output_format, const char *custom_output_s);
58 
59 
68  BlastTool (BlastServiceJob *job_p, const BlastServiceData *data_p, const json_t *json_p);
69 
70 
74  virtual ~BlastTool ();
75 
76 
83  uint32 GetOutputFormat () const;
84 
85 
92  virtual OperationStatus Run () = 0;
93 
94 
106  virtual bool ParseParameters (ParameterSet *param_set_p, BlastAppParameters *app_params_p) = 0;
107 
115  virtual bool SetInputFilename (const char * const filename_s) = 0;
116 
117 
124  virtual bool SetUpOutputFile () = 0;
125 
126 
130  virtual bool PreRun ();
131 
132 
136  virtual void PostRun ();
137 
146  virtual OperationStatus GetStatus (bool update_flag = true);
147 
148 
158  virtual char *GetResults (BlastFormatter *formatter_p) = 0;
159 
166  virtual char *GetLog () = 0;
167 
168 
169  virtual bool AddErrorDetails ();
170 
171 
178  const uuid_t &GetUUID () const;
179 
185  const char *GetName () const;
186 
187 
195  json_t *GetAsJSON ();
196 
197 
203  const char *GetFactoryName () const;
204 
205 
206  bool SetCustomOutputColumns (const char *custom_columns_s);
207 
208 
209 
210 protected:
211 
212 
218  char *bt_name_s;
219 
225  char *bt_factory_name_s;
226 
227 
233 
234 
240 
241 
248  BlastServiceJob *bt_job_p;
249 
255  const BlastServiceData *bt_service_data_p;
256 
257 
268  virtual bool AddToJSON (json_t *root_p);
269 
270 private:
271  static const char * const BT_NAME_S;
272  static const char * const BT_FACTORY_NAME_S;
273  static const char * const BT_OUTPUT_FORMAT_S;
274  static const char * const BT_CUSTOM_OUTPUT_COLUMNS_S;
275 
276 };
277 
278 
279 /*
280 * I can see that potentially we could use a variety of methods:
281 *
282 * 1. Fork a new process.
283 * 2. Create a DBApplication and run it inline.
284 * 3. Create a DBApplication and run it in a separate thread using pthreads or similar.
285 * 4. Create a job submission script and call it, this would be on HPC or similar.
286 *
287 * So we need a way to call any of these and check on their status, the obvious answer
288 * is subclassing with virtual calls.
289 */
290 
291 
292 #ifdef __cplusplus
293 extern "C"
294 {
295 #endif
296 
297 
305 
306 
307 
317 
326 
327 
337 
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
343 
344 #endif /* #ifndef BLAST_TOOL_HPP */
345 
BlastTool::RunBlast
OperationStatus RunBlast(BlastTool *tool_p)
Run Blast using the parameters that have been previously using ConvertArguments.
BlastServiceJob
This datatype stores the ServiceJob and its associated BlastTool.
Definition: blast_service_job.h:66
BlastTool::IsBlastToolSynchronous
bool IsBlastToolSynchronous(BlastTool *tool_p)
Is the BlastTool going to run asynchronously?
BlastAppParameters
This datatype is used to parse a given ParameterSet in a method suitable for a particular BLAST confi...
Definition: blast_app_parameters.h:47
BlastServiceData
The configuration data for the Blast Service.
Definition: blast_service.h:143
BlastTool::bt_custom_output_columns_s
char * bt_custom_output_columns_s
Any custom columns for tabular output formats.
Definition: blast_tool.hpp:239
BlastTool::GetBlastStatus
OperationStatus GetBlastStatus(BlastTool *tool_p)
Get the current OperationStatus of a BlastTool.
blast_service_api.h
BlastTool::bt_output_format
uint32 bt_output_format
The output format code to use.
Definition: blast_tool.hpp:232
blast_formatter.h
BLAST_SERVICE_LOCAL
#define BLAST_SERVICE_LOCAL
Definition: blast_service_api.h:48
BlastTool
The base class for running Blast.
Definition: blast_tool.hpp:43
OperationStatus
OperationStatus
The current status of an Operation.
Definition: operation.h:96
byte_buffer.h
service_job.h
blast_app_parameters.h
BlastFormatter
This class is for converting the output of a blast job between the available different formats.
Definition: blast_formatter.h:47
ParameterSet
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
BlastTool::FreeBlastTool
void FreeBlastTool(BlastTool *tool_p)
Free a BlastTool.
uuid_t
Definition: windows_uuid.h:43