-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtripal_analysis_blast.module
executable file
·245 lines (218 loc) · 7.66 KB
/
tripal_analysis_blast.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
require_once "api/tripal_analysis_blast.api.inc";
require_once "includes/tripal_analysis_blast.fields.inc";
require_once "theme/tripal_analysis_blast.theme.inc";
//*.chado_node.inc is required to support legacy template
require_once "includes/tripal_analysis_blast.chado_node.inc";
/**
* Implements hook_menu().
*/
function tripal_analysis_blast_menu() {
$items['admin/tripal/extension/tripal_blast_analysis'] = array(
'title' => 'BLAST Analyses',
'description' => 'Administrative pages for the Tripal Blast Analysis module.',
'page callback' => 'drupal_get_form',
'page arguments' => array('tripal_analysis_blast_settings_form'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/tripal_analysis_blast.admin.inc',
'file path' => drupal_get_path('module', 'tripal_analysis_blast'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/tripal/extension/tripal_blast_analysis/configuration'] = array(
'title' => 'Settings',
'description' => 'Settings for the displays of BLAST analysis results.',
'page callback' => 'drupal_get_form',
'page arguments' => array('tripal_analysis_blast_settings_form'),
'access arguments' => array('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 1
);
if (module_exists('tripal_core')) {
$items['admin/tripal/extension/tripal_blast_analysis/sync'] = array(
'title' => ' Sync',
'description' => 'Create pages on this site for BLAST analyses',
'page callback' => 'drupal_get_form',
'page arguments' => array('chado_node_sync_form', 'tripal_analysis_blast', 'chado_analysis_blast'),
'access arguments' => array('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 2
);
}
return $items;
}
/**
*
*
* @ingroup tripal_analysis_blast
*/
function tripal_analysis_blast_block($op = 'list', $delta = 0, $edit=array()) {
switch ($op) {
case 'list':
$blocks['blast_base']['info'] = t('Analysis: Blast Details');
$blocks['blast_base']['cache'] = BLOCK_NO_CACHE;
$blocks['featureblast']['info'] = t('Tripal Feature Blast Results');
$blocks['featureblast']['cache'] = BLOCK_NO_CACHE;
return $blocks;
case 'view':
if (user_access('access chado_analysis_blast content') and arg(0) == 'node' and is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load($nid);
$block = array();
switch ($delta) {
case 'blast_base':
$block['subject'] = t('Blast Details');
$block['content'] = theme('tripal_analysis_blast_base', $node);
break;
case 'featureblast':
$block['subject'] = t('Homology');
$block['content'] = theme('tripal_feature_blast_results', $node);
break;
default :
}
return $block;
}
}
}
/**
* We need to let drupal know about our theme functions and their arguments.
* We create theme functions to allow users of the module to customize the
* look and feel of the output generated in this module
*/
function tripal_analysis_blast_theme($existing, $type, $theme, $path) {
$core_path = drupal_get_path('module', 'tripal_core');
$items = array (
'node__chado_analysis_blast' => array (
'template' => 'node--chado-generic',
'render element' => 'node',
'base hook' => 'node',
'path' => "$core_path/theme/templates"
),
'tripal_analysis_blast_base' => array(
'variables' => array('node' => NULL),
'template' => 'tripal_analysis_blast_base',
'path' => "$path/theme/templates",
),
'tripal_analysis_blast_teaser' => array(
'variables' => array('node' => NULL),
'template' => 'tripal_analysis_blast_teaser',
'path' => "$path/theme/templates",
),
// tripal_feature theme
'tripal_feature_blast_results' => array (
'template' => 'tripal_feature_blast_results',
'variables' => array ('node' => NULL),
'path' => "$path/theme/templates"
),
);
return $items;
}
/**
*
*/
function chado_analysis_blast_submit_jobs($node) {
global $user;
// add a job if the user wants to parse the XML
if ($node->blastjob) {
$job_args = array(
$node->analysis_id,
$node->blastdb,
$node->blastfile,
$node->no_parsed,
$node->blastfile_ext,
$node->query_re,
$node->query_type,
$node->query_uniquename,
$node->is_concat,
$node->search_keywords,
);
tripal_add_job("Parse blast: $node->blastfile", 'tripal_analysis_blast',
'tripal_analysis_blast_parseXMLFile', $job_args, $user->uid);
}
}
/*******************************************************************************
* Set the permission types that the chado module uses. Essentially we
* want permissionis that protect creation, editing and deleting of chado
* data objects
*/
function tripal_analysis_blast_permission() {
$permissions = array();
// For Tripal v2 backwards compatibility, we have permissions for node types.
if (module_exists('tripal_core')) {
$permissions['access chado_analysis_blast content'] = array(
'title' => t('View Chado Analysis Blast'),
'description' => t('Allow users to view chado analysis blast pages.'),
);
$permissions['create chado_analysis_blast content'] = array(
'title' => t('Create Chado Analysis Blast'),
'description' => t('Allow users to create new chado analysis blast pages.'),
);
$permissions['delete chado_analysis_blast content']= array(
'title' => t('Delete Chado Analysis Blast'),
'description' => t('Allow users to delete chado analysis blast pages.'),
);
$permissions['edit chado_analysis_blast content']= array(
'title' => t('Edit Chado Analysis Blast'),
'description' => t('Allow users to edit chado analysis blast pages.'),
);
}
return $permissions;
}
/**
*
*
* @ingroup tripal_feature
*/
function tripal_analysis_blast_job_describe_args($callback, $args) {
$new_args = array();
if ($callback == 'tripal_analysis_blast_parseXMLFile') {
// add in the analysis
if ($args[0]) {
$analysis = chado_select_record('analysis', array('name'), array('analysis_id' => $args[0]));
}
$new_args['Analysis'] = $analysis[0]->name;
// add in the database
if ($args[1]) {
$db = chado_select_record('db', array('name'), array('db_id' => $args[1]));
}
$new_args['Database'] = $db[0]->name;
$new_args['File or Directory Name'] = $args[2];
if ($args[8] == 1) {
$new_args['Is XML file concatenated'] = 'Yes';
}
else {
$new_args['Is XML file concatenated'] = 'No';
}
$new_args['File Extension (if directory)'] = $args[4];
$new_args['Number matches parsed per query'] = $args[3];
$new_args['Query name regular expression'] = $args[5];
$new_args['Query type'] = $args[6];
if ($args[7] == 1) {
$new_args['Feature identifier'] = 'feature unique name';
}
else {
$new_args['Feature identifier'] = 'feature name';
}
if ($args[9]) {
$new_args['Tripal Views Integration'] = 'Yes';
}
else {
$new_args['Tripal Views Integration'] = 'No';
}
}
return $new_args;
}
/**
* Implementation of hook_form_alter()
*
* @param $form
* @param $form_state
* @param $form_id
*
*
*/
function tripal_analysis_blast_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == "chado_analysis_blast_node_form") {
// turn of preview button for insert/updates
$form['actions']['preview']['#access'] = FALSE;
}
}