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_service.h
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 
23 #ifndef BLAST_SERVICE_H
24 #define BLAST_SERVICE_H
25 
26 
27 #include "blast_app_parameters.h"
28 #include "blast_formatter.h"
29 #include "blast_service_api.h"
30 #include "parameter_set.h"
31 #include "temp_file.hpp"
32 #include "async_tasks_manager.h"
33 
34 
43 {
46 
49 
52 } DatabaseType;
53 
54 
63 {
66 
69 
72 
76 
84 {
86  const char *di_name_s;
87 
89  const char *di_filename_s;
90 
92  const char *di_description_s;
93 
96 
98  const char *di_download_uri_s;
99 
101  const char *di_info_uri_s;
102 
108 
111 
119  const char *di_scaffold_key_s;
120 
127  const char *di_scaffold_regex_s;
128 
129 } DatabaseInfo;
130 
131 
132 
133 /* forward class declarations */
134 class BlastToolFactory;
135 struct BlastServiceJob;
136 
144 {
147 
153 
159 
162 
165 
166 
169 
170 
172 
173 
175 
176 
186 typedef bool (*AddAdditionalParamsFn) (BlastServiceData *data_p, ParameterSet *param_set_p, ParameterGroup *group_p, const void *callback_data_p);
187 
188 
189 #ifndef DOXYGEN_SHOULD_SKIP_THIS
190 
191 #ifdef ALLOCATE_BLAST_SERVICE_CONSTANTS
192  #define BLAST_SERVICE_PREFIX BLAST_SERVICE_LOCAL
193  #define BLAST_SERVICE_VAL(x) = x
194  #define BLAST_SERVICE_STRUCT_VAL(x,y) = { x, y}
195 #else
196  #define BLAST_SERVICE_PREFIX extern
197  #define BLAST_SERVICE_VAL(x)
198  #define BLAST_SERVICE_STRUCT_VAL(x,y)
199 #endif
200 
201 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
202 
203 
209 #define BS_DEFAULT_OUTPUT_FORMAT (11)
210 
212 BLAST_SERVICE_PREFIX const char *BS_INPUT_SUFFIX_S BLAST_SERVICE_VAL (".input");
213 
215 BLAST_SERVICE_PREFIX const char *BS_OUTPUT_SUFFIX_S BLAST_SERVICE_VAL (".output");
216 
218 BLAST_SERVICE_PREFIX const char *BS_LOG_SUFFIX_S BLAST_SERVICE_VAL (".log");
219 
225 BLAST_SERVICE_PREFIX const char *BS_DEFAULT_OUTPUT_FORMAT_S BLAST_SERVICE_VAL ("11");
226 
228 BLAST_SERVICE_PREFIX const char *BS_DATABASE_GROUP_NAME_S BLAST_SERVICE_VAL ("Available Databases");
229 
230 
231 BLAST_SERVICE_PREFIX const char *BS_DATABASES_S BLAST_SERVICE_VAL ("databases");
232 
236 BLAST_SERVICE_PREFIX const char *BS_TOOL_TYPE_NAME_S BLAST_SERVICE_VAL ("blast_tool");
237 
241 BLAST_SERVICE_PREFIX const char *BS_COMMAND_NAME_S BLAST_SERVICE_VAL ("blast_command");
242 
243 
247 BLAST_SERVICE_PREFIX const char *BS_APP_NAME_S BLAST_SERVICE_VAL ("blast_app_type");
248 
249 
251 #define BS_GROUP_ALIAS_PREFIX_S "blast"
252 
253 
254 #ifdef __cplusplus
255 extern "C"
256 {
257 #endif
258 
268 
269 
277 
278 
279 
291 BLAST_SERVICE_LOCAL ServiceJobSet *RunBlastService (Service *service_p, ParameterSet *param_set_p, User *user_p, ProvidersStateTable *providers_p, BlastAppParameters *app_params_p);
292 
293 
304 
305 
315 
316 
324 
325 
335 
336 
349 
350 
364 BLAST_SERVICE_LOCAL bool AddBaseBlastServiceParameters (Service *blast_service_p, ParameterSet *param_set_p, DataResource *resource_p, const DatabaseType db_type, AddAdditionalParamsFn query_sequence_callback_fn, void *callback_data_p);
365 
366 
367 BLAST_SERVICE_LOCAL bool GetBaseBlastServiceParameterTypeForNamedParameter (const Service *service_p, const char *param_name_s, ParameterType *pt_p);
368 
369 
378 
379 
389 
390 
400 
401 
412 BLAST_SERVICE_LOCAL TempFile *GetInputTempFile (const ParameterSet *params_p, const char *working_directory_s, const uuid_t job_id);
413 
414 
426 BLAST_SERVICE_LOCAL char *GetBlastResultByUUID (const BlastServiceData *data_p, const uuid_t job_id, const uint32 output_format_code, const char *output_format_params_s);
427 
428 
440 BLAST_SERVICE_LOCAL char *GetBlastResultByUUIDString (const BlastServiceData *data_p, const char *job_id_s, const uint32 output_format_code, const char *output_format_params_s);
441 
442 
456 BLAST_SERVICE_LOCAL ServiceJobSet *GetPreviousJobResults (LinkedList *ids_p, BlastServiceData *blast_data_p, const uint32 output_format_code, const char *output_format_params_s);
457 
458 
471 
472 
482 BLAST_SERVICE_LOCAL void PrepareBlastServiceJobs (const DatabaseInfo *db_p, const ParameterSet * const param_set_p, Service *service_p, BlastServiceData *data_p);
483 
492 BLAST_SERVICE_LOCAL ServiceJob *BuildBlastServiceJob (struct Service *service_p, const json_t *service_job_json_p);
493 
494 
506 BLAST_SERVICE_LOCAL json_t *BuildBlastServiceJobJSON (Service * UNUSED_PARAM (service_p), ServiceJob *service_job_p, bool omit_results_flag);
507 
508 
518 
519 
529 BLAST_SERVICE_LOCAL const char *GetMatchingDatabaseFilename (const BlastServiceData *data_p, const char *name_s);
530 
531 
541 BLAST_SERVICE_LOCAL const char *GetMatchingDatabaseName (const BlastServiceData *data_p, const char *filename_s);
542 
543 
544 
546 
547 
557 BLAST_SERVICE_LOCAL const DatabaseInfo *GetMatchingDatabaseByFilename (const BlastServiceData *data_p, const char *filename_s);
558 
559 
561 
562 
564 
565 
566 #ifdef __cplusplus
567 }
568 #endif
569 
570 
571 
572 #endif /* #ifndef BLAST_SERVICE_H */
BlastServiceJob
This datatype stores the ServiceJob and its associated BlastTool.
Definition: blast_service_job.h:66
BlastServiceData::bsd_tool_factory_p
BlastToolFactory * bsd_tool_factory_p
The BlastToolFactory used to generate each BlastTool that actually run the Blast jobs.
Definition: blast_service.h:164
ParameterGroup
A datatype to tell the system that certain parameters should be grouped together in the client's user...
Definition: parameter_group.h:85
BLAST_SERVICE_API
#define BLAST_SERVICE_API
Definition: blast_service_api.h:47
DatabaseInfo::di_search_description_s
const char * di_search_description_s
The description to use for indexing in the Grassroots search service.
Definition: blast_service.h:95
DatabaseInfo::di_filename_s
const char * di_filename_s
The filename for the database.
Definition: blast_service.h:89
DatabaseInfo::di_active_flag
bool di_active_flag
Sets whether the database defaults to being searched against or not.
Definition: blast_service.h:107
RunBlastService
ServiceJobSet * RunBlastService(Service *service_p, ParameterSet *param_set_p, User *user_p, ProvidersStateTable *providers_p, BlastAppParameters *app_params_p)
Run a Blast Service.
CreateJobsForPreviousResults
ServiceJobSet * CreateJobsForPreviousResults(ParameterSet *params_p, const char *ids_s, BlastServiceData *blast_data_p)
Get the results of previously ran BlastServiceJobs in a given output format.
AddAdditionalParamsFn
bool(* AddAdditionalParamsFn)(BlastServiceData *data_p, ParameterSet *param_set_p, ParameterGroup *group_p, const void *callback_data_p)
A callback function used to amend a given ParameterSet.
Definition: blast_service.h:186
DatabaseInfo::di_type
DatabaseType di_type
The DatabaseType for this database.
Definition: blast_service.h:110
GetMatchingDatabaseName
const char * GetMatchingDatabaseName(const BlastServiceData *data_p, const char *filename_s)
For a given BLAST database filename, find the corresponding service-configured name.
ParameterType
ParameterType
The different types that a Parameter can take.
Definition: parameter_type.h:35
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
ServiceJob
A datatype to represent a running task.
Definition: service_job.h:72
GetMatchingDatabaseByFilename
const DatabaseInfo * GetMatchingDatabaseByFilename(const BlastServiceData *data_p, const char *filename_s)
For a given BLAST database filename, find the corresponding DatabaseInfo object.
parameter_set.h
BlastServiceData::bsd_databases_p
DatabaseInfo * bsd_databases_p
A NULL-terminated array of the databases available to search.
Definition: blast_service.h:161
BlastServiceData
The configuration data for the Blast Service.
Definition: blast_service.h:143
BST_BLASTX
A search using the BlastX program.
Definition: blast_service.h:71
IsResourceForBlastService
ParameterSet * IsResourceForBlastService(Service *service_p, DataResource *resource_p, Handler *handler_p)
Check whether a given Resource is suitable for running a Blast Service for and if so return the parti...
DataResource
A datatype representing a URI.
Definition: data_resource.h:40
DatabaseType
DatabaseType
An enumeration for differentiating between the different types of database that the BLAST algorithms ...
Definition: blast_service.h:42
BlastServiceData::AllocateBlastServiceData
BlastServiceData * AllocateBlastServiceData(Service *blast_service_p, DatabaseType database_type)
Allocate a BlastServiceData.
BS_DATABASE_GROUP_NAME_S
const char * BS_DATABASE_GROUP_NAME_S
The prefix to use for the ParameterGroup names for available databases from all of the connected serv...
Definition: blast_service.h:228
BlastServiceData::bsd_formatter_p
BlastFormatter * bsd_formatter_p
The BlastFormatter used to convert the Blast output between the different output formats.
Definition: blast_service.h:158
BS_LOG_SUFFIX_S
const char * BS_LOG_SUFFIX_S
The suffix to use for Blast Service log files.
Definition: blast_service.h:218
BS_OUTPUT_SUFFIX_S
const char * BS_OUTPUT_SUFFIX_S
The suffix to use for Blast Service output files.
Definition: blast_service.h:215
DT_PROTEIN
The database is a protein sequence.
Definition: blast_service.h:48
BS_DATABASES_S
const char * BS_DATABASES_S
Definition: blast_service.h:231
blast_service_api.h
ReleaseServices
void ReleaseServices(ServicesArray *services_p)
Free the ServicesArray and its associated BLAST Services.
ServiceMetadata
A datatype for describing the type of application that a Service provides.
Definition: service_metadata.h:39
BlastToolFactory
The base class for generating blast tools.
Definition: blast_tool_factory.hpp:43
BlastServiceJob::CustomiseBlastServiceJob
void CustomiseBlastServiceJob(Service *service_p, ServiceJob *job_p)
Initialise a BlastServiceJob with its required functions for updating and freeing itself.
ReleaseBlastService
void ReleaseBlastService(Service *service_p)
Service
A datatype which defines an available service, its capabilities and its parameters.
Definition: service.h:153
BlastServiceData::FreeBlastServiceData
void FreeBlastServiceData(BlastServiceData *data_p)
Free a BlastServiceData.
blast_formatter.h
async_tasks_manager.h
ServicesArray
A datatype for having a set of Services.
Definition: service.h:422
BlastServiceData::bsd_base_data
ServiceData bsd_base_data
The base ServiceData.
Definition: blast_service.h:146
GetMatchingDatabaseFilename
const char * GetMatchingDatabaseFilename(const BlastServiceData *data_p, const char *name_s)
For a given service-configured name, find the corresponding BLAST database filename.
GetBlastServiceStatus
OperationStatus GetBlastServiceStatus(Service *service_p, const uuid_t service_id)
Get the OperationStatus for a BlastServiceJob with the given job id.
BLAST_SERVICE_LOCAL
#define BLAST_SERVICE_LOCAL
Definition: blast_service_api.h:48
BST_BLASTP
A search using the BlastP program.
Definition: blast_service.h:68
BuildBlastServiceJob
ServiceJob * BuildBlastServiceJob(struct Service *service_p, const json_t *service_job_json_p)
Create a BlastServiceJob from a JSON-based serialisation.
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
GetServices
ServicesArray * GetServices(User *user_p, GrassrootsServer *grassroots_p)
Get the Services available for running BLAST jobs.
BuildBlastServiceJobJSON
json_t * BuildBlastServiceJobJSON(Service *service_p, ServiceJob *service_job_p, bool omit_results_flag)
Get the JSON representation of a BlastServiceJob.
ProvidersStateTable
This is a datatype that is used to keep track of which servers and services have already been process...
Definition: providers_state_table.h:49
PrepareBlastServiceJobs
void PrepareBlastServiceJobs(const DatabaseInfo *db_p, const ParameterSet *const param_set_p, Service *service_p, BlastServiceData *data_p)
Prepare a ServiceJobSet of BlastServiceJobs prior to running them.
DT_NUCLEOTIDE
The database is a nucleotide sequence.
Definition: blast_service.h:45
BS_APP_NAME_S
const char * BS_APP_NAME_S
The configuration key used to declare the type of Blast application to use.
Definition: blast_service.h:247
OperationStatus
OperationStatus
The current status of an Operation.
Definition: operation.h:96
DatabaseInfo::di_name_s
const char * di_name_s
The name of the database to display to the user.
Definition: blast_service.h:86
BS_TOOL_TYPE_NAME_S
const char * BS_TOOL_TYPE_NAME_S
The configuration key used to declare which type of BlastTool to use.
Definition: blast_service.h:236
ReleaseBlastServiceParameters
void ReleaseBlastServiceParameters(Service *service_p, ParameterSet *params_p)
Free a ParameterSet of Blast Service parameters.
TempFile
Create a temporary file to read and write data to.
Definition: blast/include/temp_file.hpp:46
GetInputTempFile
TempFile * GetInputTempFile(const ParameterSet *params_p, const char *working_directory_s, const uuid_t job_id)
Get the TempFile detailing the query for a given BlastServiceJob UUID.
AsyncTasksManager
A datatype for storing AsyncTasks in a collection.
Definition: async_tasks_manager.h:24
BlastServiceData::bsd_type
DatabaseType bsd_type
Specifies whether the databases are nucleotide or protein databases.
Definition: blast_service.h:168
GetBlastResultByUUID
char * GetBlastResultByUUID(const BlastServiceData *data_p, const uuid_t job_id, const uint32 output_format_code, const char *output_format_params_s)
Get the result of a previously ran BlastServiceJob in a given output format.
GrassrootsServer
Definition: grassroots_server.h:45
BST_BLASTN
A search using the BlastN program.
Definition: blast_service.h:65
DatabaseInfo
A datatype describing the details of each database available to search against.
Definition: blast_service.h:83
DatabaseInfo::di_download_uri_s
const char * di_download_uri_s
The URI to download any associated resources for this database.
Definition: blast_service.h:98
BlastServiceData::bsd_working_dir_s
char * bsd_working_dir_s
The directory where the Blast input, output and log files will be stored.
Definition: blast_service.h:152
ServiceJobSet
A datatype to represent a collection of ServiceJobs.
Definition: service_job.h:185
DatabaseInfo::di_scaffold_key_s
const char * di_scaffold_key_s
The key used to get the scaffold name for any hits from BLAST searches from within the "BlastOutput2....
Definition: blast_service.h:119
blast_app_parameters.h
DatabaseInfo::di_description_s
const char * di_description_s
The description of the database to display to the user.
Definition: blast_service.h:92
User
A datatype to store user credentials.
Definition: user_details.h:40
GetGeneralBlastServiceMetadata
ServiceMetadata * GetGeneralBlastServiceMetadata(Service *service_p)
BST_NUM_TYPES
The number of different Blast service types.
Definition: blast_service.h:74
BS_COMMAND_NAME_S
const char * BS_COMMAND_NAME_S
The configuration key used to declare the Blast executable file to use.
Definition: blast_service.h:241
BS_DEFAULT_OUTPUT_FORMAT_S
const char * BS_DEFAULT_OUTPUT_FORMAT_S
The default output format as a string to use.
Definition: blast_service.h:225
DT_NUM_TYPES
The number of different database types.
Definition: blast_service.h:51
ServiceData
A datatype for holding the configuration data for a Service.
Definition: service.h:126
BS_INPUT_SUFFIX_S
const char * BS_INPUT_SUFFIX_S
The suffix to use for Blast Service input files.
Definition: blast_service.h:212
BlastServiceData::GetBlastServiceConfig
bool GetBlastServiceConfig(BlastServiceData *data_p)
Check whether the required configuration details contain the required information for a Blast Service...
BlastFormatter
This class is for converting the output of a blast job between the available different formats.
Definition: blast_formatter.h:47
GetBaseBlastServiceParameterTypeForNamedParameter
bool GetBaseBlastServiceParameterTypeForNamedParameter(const Service *service_p, const char *param_name_s, ParameterType *pt_p)
Handler
A Handler is a datatype for accessing data.
Definition: handler.h:72
ParameterSet
A set of Parameters along with an optional name and description.
Definition: parameter_set.h:46
GetBlastIndexingData
json_t * GetBlastIndexingData(Service *service_p)
GetPreviousJobResults
ServiceJobSet * GetPreviousJobResults(LinkedList *ids_p, BlastServiceData *blast_data_p, const uint32 output_format_code, const char *output_format_params_s)
Get the results of previously ran BlastServiceJobs in a given output format.
temp_file.hpp
DatabaseInfo::di_scaffold_regex_s
const char * di_scaffold_regex_s
The regular expression used to get the scaffold name for the value associated with the value retrieve...
Definition: blast_service.h:127
BlastServiceType
BlastServiceType
An enumeration for differentiating between the differentBLAST algorithms that can be used.
Definition: blast_service.h:62
GetBlastResultByUUIDString
char * GetBlastResultByUUIDString(const BlastServiceData *data_p, const char *job_id_s, const uint32 output_format_code, const char *output_format_params_s)
Get the result of a previously ran BlastServiceJob in a given output format.
CloseBlastService
bool CloseBlastService(Service *service_p)
Close a Blast Service.
DetermineBlastResult
bool DetermineBlastResult(struct BlastServiceJob *job_p)
Get the results of a given BlastServiceJob and store them within it.
AddBaseBlastServiceParameters
bool AddBaseBlastServiceParameters(Service *blast_service_p, ParameterSet *param_set_p, DataResource *resource_p, const DatabaseType db_type, AddAdditionalParamsFn query_sequence_callback_fn, void *callback_data_p)
Add the common Blast Service parameters to a given ParameterSet.
BlastServiceData::bsd_task_manager_p
AsyncTasksManager * bsd_task_manager_p
Definition: blast_service.h:171
DatabaseInfo::di_info_uri_s
const char * di_info_uri_s
The URI to for any supplementary information about the database.
Definition: blast_service.h:101
uuid_t
Definition: windows_uuid.h:43