-
Notifications
You must be signed in to change notification settings - Fork 14
/
TripalBlastProgramBlastn.php
182 lines (161 loc) · 5.98 KB
/
TripalBlastProgramBlastn.php
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
<?php
/**
* @file
* Form definition of BLASTn program.
*/
namespace Drupal\tripal_blast\Services;
use Drupal\tripal_blast\Services\TripalBlastProgramHelper;
/**
* BLASTn program class.
*/
class TripalBlastProgramBlastn {
const BLASTn = 'blastn';
/**
* Advanced field names used - refer to this value when
* validating and submitting fields under advanced options.
*/
public function formFieldNames() {
// Keys match field names used in form definition below.
$field_name_validator = [
'maxTarget' => [],
'eVal' => ['number'],
'wordSize' => [],
'M&MScores' => [],
'gabCost' => []
];
return $field_name_validator;
}
/**
* Adds the BLASTn Advanced Options to the passed in form.
* This form function is meant to be called within another form definition.
*
* @param $blast_cache
* BLAST job history to reference information information contained.
*
* @return array
* Additional form field definitions.
*/
public function formOptions($blast_cache) {
$blast = self::BLASTn;
// Edit and Resubmit functionality.
// We want to pull up the details from a previous blast and fill them in as defaults
// for this blast.
$options = (isset($blast_cache)) ? $blast_cache : [];
$defaults = TripalBlastProgramHelper::programGetDefaultValues($options, $blast);
$form_alter = [];
$container = 'ALG' ;
$form_alter[ $container ] = [
'#type' => 'details',
'#title' => t('Advanced Options'),
'#open' => FALSE
];
// @TODO: previous job details.
$form_alter[ $container ]['general'] = [
'#type' => 'details',
'#title' => t('General Parameters'),
'#open' => TRUE
];
//
// # FIELD: MAXIMUM TARGET.
$max_target_options = TripalBlastProgramHelper::programGetMaxTarget($blast);
$form_alter[ $container ]['general']['maxTarget'] = [
'#type' => 'select',
'#title' => t('Max target sequences:'),
'#options' => $max_target_options,
'#default_value' => $defaults['max_target_seqs'],
'#description' => t('Select the maximum number of unique target sequences per
query sequence to show results for. Results returned may not be the highest scoring hits.
<a href="https://academic.oup.com/bioinformatics/article/35/9/1613/5106166" target="_blank">More Information</a>'),
];
//
// # FIELD: EVAL.
$form_alter[ $container ]['general']['eVal'] = [
'#type' => 'textfield',
'#title' => t('e-Value (Expected Threshold)'),
'#default_value' => $defaults['evalue'],
'#size' => 12,
'#maxlength' => 20,
'#description' => t('Expected number of chance matches in a random model. This number should be give in a decimal format.
<a href="https://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml#expect" target="_blank">More Information</a> |
<a href="https://www.youtube.com/watch?v=nO0wJgZRZJs" target="_blank">Expect value video tutorial</a>'),
];
//
// # FIELD: WORDSIZE.
$word_size_options = TripalBlastProgramHelper::programGetWordSize($blast);
$form_alter[ $container ]['general']['wordSize'] = [
'#type' => 'select',
'#title' => t('Word size'),
'#options' => $word_size_options,
'#default_value' => $defaults['word_size'],
'#description' => t('The length of the seed that initiates an alignment'),
];
$form_alter[ $container ]['scoring_param'] = [
'#type' => 'details',
'#title' => t('Scoring parameters'),
'#open' => TRUE,
];
//
// # FIELD: MATCH AND MISMATCH.
$mm_options = TripalBlastProgramHelper::programGetMatchMismatch($blast);
$form_alter[ $container ]['scoring_param']['M&MScores'] = [
'#type' => 'select',
'#title' => t('Match/Mismatch Scores:'),
'#options' => $mm_options,
'#default_value' => $defaults['matchmiss'],
'#description' => t('Reward and penalty for matching and mismatching bases.'),
'#ajax' => [
'callback' => '::ajaxFieldUpdateCallback',
'wrapper' => 'tripal-blast-wrapper-fld-select-gap-cost',
'method' => 'replace',
'event' => 'change',
'effect' => 'fade',
'progress' => 'throbber',
'message' => '',
],
];
//
// # FIELD: GAP COST.
$mm_set = $defaults['matchmiss'];
$gap_cost_options = TripalBlastProgramHelper::programGetGapCost($blast, $mm_set);
$form_alter[ $container ]['scoring_param']['gapCost'] = [
'#type' => 'select',
'#title' => t('Gap Costs:'),
'#options' => $gap_cost_options,
'#default_value' => $mm_set,
'#description' => t('Cost to create and extend a gap in an alignment.'),
'#id' => 'tripal-blast-fld-select-gap-cost',
'#prefix' => '<div id="tripal-blast-wrapper-fld-select-gap-cost">',
'#suffix' => '</div>',
];
return $form_alter;
}
/**
* Map advanced options specific to this program to BLAST keywords.
*
* @param $advanced_field_names
* Values set from form ($form_state).
*
* @return array
* Form values mapped to BLAST keywords.
*/
public function formFieldBlastKey($advanced_field_values) {
$eval = $advanced_field_values['eVal'];
$max_target = $advanced_field_values['maxTarget'];
$word_size = $advanced_field_values['wordSize'];
$gap = TripalBlastProgramHelper::programSetGap($advanced_field_values['gapCost']);
$gap_open = $gap['gapOpen'];
$gap_extend = $gap['gapExtend'];
$mm = TripalBlastProgramHelper::programSetMatchMismatch($advanced_field_values['M&MScores']);
$penalty = $mm['penalty'];
$reward = $mm['reward'];
return [
'max_target_seqs' => $max_target,
'evalue' => $eval,
'word_size' => $word_size,
'gapopen' => $gap_open,
'gapextend' => $gap_extend,
'penalty' => $penalty,
'reward' => $reward,
];
}
}