blast_ui.form_advanced_options.inc 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388
  1. <?php
  2. /**
  3. * @file
  4. * Contains helper functions related to program-specific advanced options.
  5. */
  6. /**
  7. * @section
  8. * BLASTn: Search a nucleotide database using a nucleotide query.
  9. * ----------------------------------------------------------------------------
  10. */
  11. /**
  12. * Adds the BLASTn Advanced Options to the passed in form.
  13. *
  14. * This form function is meant to be called within another form definition.
  15. *
  16. * @param $form
  17. * The form the advanced options should be added to. This form already
  18. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  19. * @param $formstate
  20. * The current state fo the form passed in as $form.
  21. */
  22. function blast_ui_blastn_advanced_options_form(&$form, $form_state) {
  23. // Edit and Resubmit functionality.
  24. // We want to pull up the details from a previous blast and fill them in as defaults
  25. // for this blast.
  26. if (isset($form_state['prev_blast'])) {
  27. $defaults = _get_default_values($form_state['prev_blast']->options, 'blastn');
  28. }
  29. else {
  30. $defaults = _get_default_values(array(), 'blastn');
  31. }
  32. // General parameters
  33. //.........................
  34. $form['ALG']['GParam'] = array(
  35. '#type' => 'fieldset',
  36. '#title' => t('General parameters'),
  37. '#collapsible' => FALSE,
  38. );
  39. $form['ALG']['GParam']['maxTarget'] = array(
  40. '#type' => 'select',
  41. '#title' => t('Max target sequences:'),
  42. '#options' => _get_max_target('blastn'),
  43. '#default_value' => $defaults['max_target_seqs'],
  44. '#description' => t('Select the maximum number of unique target sequences per query sequence to show results for.'),
  45. );
  46. /*eksc- remove until we learn how this is implemented by NCBI
  47. $form['ALG']['GParam']['shortQueries'] = array(
  48. '#type' => 'checkbox',
  49. '#title' => t('Automatically adjust parameters for short input sequences'),
  50. '#default_value' => $short_queries,
  51. );
  52. */
  53. $form['ALG']['GParam']['eVal'] = array(
  54. '#type' => 'textfield',
  55. '#title' => t('e-Value (Expected Threshold)'),
  56. '#default_value' => $defaults['evalue'],
  57. '#size' => 12,
  58. '#maxlength' => 20,
  59. '#description' => t('Expected number of chance matches in a random model. This number should be give in a decimal format. <a href="http://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>'),
  60. );
  61. $form['ALG']['GParam']['wordSize'] = array(
  62. '#type' => 'select',
  63. '#title' => t('Word size:'),
  64. '#options' => _get_word_size('blastn'),
  65. '#default_value' => $defaults['word_size'],
  66. '#description' => t('The length of the seed that initiates an alignment'),
  67. );
  68. $form['ALG']['GParam']['qRange'] = array(
  69. '#type' => 'textfield',
  70. '#title' => t('Max matches in a query range'),
  71. '#default_value' => $defaults['qRange'],
  72. '#size' => 12,
  73. '#maxlength' => 20,
  74. '#description' => t('Limit the number of matches to a query range. This option is useful if many strong matches to one part of a query may prevent BLAST from presenting weaker matches to another part of the query.'),
  75. );
  76. // Scoring parameters
  77. //.........................
  78. $form['ALG']['SParam'] = array(
  79. '#type' => 'fieldset',
  80. '#title' => t('Scoring parameters'),
  81. '#collapsible' => FALSE,
  82. );
  83. $form['ALG']['SParam']['M&MScores'] = array(
  84. '#type' => 'select',
  85. '#title' => t('Match/Mismatch Scores:'),
  86. '#options' => _get_match_mismatch('blastn'),
  87. '#default_value' => $defaults['matchmiss'],
  88. '#description' => t('Reward and penalty for matching and mismatching bases.'),
  89. );
  90. $form['ALG']['SParam']['gapCost'] = array(
  91. '#type' => 'select',
  92. '#title' => t('Gap Costs:'),
  93. '#options' => _get_gap('blastn'),
  94. '#default_value' => $defaults['gap'],
  95. '#description' => t('Cost to create and extend a gap in an alignment. Linear costs are available only with megablast and are determined by the match/mismatch scores.'),
  96. );
  97. }
  98. /**
  99. * Validate the advanced options provided by the BLASTn form above.
  100. *
  101. * @see blast_ui_blastn_advanced_options_form().
  102. */
  103. function blast_ui_blastn_advanced_options_form_validate($form, $form_state) {
  104. // Ensure that our textfields are what we expect them to be since we will
  105. // use them to generate the BLAST command.
  106. // First up, e-value. We expect the evalue to be a very small yet still
  107. // positive number. It may be given in scientific notation which is
  108. // luckily supported by is_numeric().
  109. if (!is_numeric($form_state['values']['eVal'])) {
  110. form_set_error('eVal', 'The e-value should be a very small number (scientific notation is supported). For example, <em>0.001</em> or, even better, <em>1e-10</em>.');
  111. }
  112. // Next textfield up, "Max matches in a query range" which is also expected
  113. // to be a positive number.
  114. if (!is_numeric($form_state['values']['qRange'])) {
  115. form_set_error('qRange', 'The "Max matches in a query range" should be a positive integer.');
  116. }
  117. }
  118. /**
  119. * Processed the advanced options provided by the BLASTn form above.
  120. *
  121. * @see blast_ui_blastn_advanced_options_form().
  122. */
  123. function blast_ui_blastn_advanced_options_form_submit($form, $form_state) {
  124. $eVal = $form_state['values']['eVal'];
  125. $trgtKey = $form_state['values']['maxTarget'];
  126. $numAlign = $form['ALG']['GParam']['maxTarget']['#options'][$trgtKey];
  127. $wsKey = $form_state['values']['wordSize'];
  128. $wordSize = $form['ALG']['GParam']['wordSize']['#options'][$wsKey];
  129. // Expand Gap Cost key into open and extend penalties
  130. $gap = _set_gap($form_state['values']['gapCost']);
  131. // Expand Match/Mismatch option into penalty/reward values
  132. $m_m = _set_match_mismatch($form_state['values']['M&MScores']);
  133. // Limit number of query hits
  134. $qRange = $form_state['values']['qRange'];
  135. return array(
  136. 'max_target_seqs' => $numAlign,
  137. 'evalue' => $eVal,
  138. 'word_size' => $wordSize,
  139. 'gapopen' => $gap['gapOpen'],
  140. 'gapextend' => $gap['gapExtend'],
  141. 'penalty' => $m_m['penalty'],
  142. 'reward' => $m_m['reward'],
  143. 'culling_limit' => $qRange,
  144. );
  145. }
  146. /**
  147. * @section
  148. * BLASTx: Search protein database using a translated nucleotide query.
  149. * ----------------------------------------------------------------------------
  150. */
  151. /**
  152. * Adds the BLASTx Advanced Options to the passed in form.
  153. *
  154. * This form function is meant to be called within another form definition.
  155. *
  156. * @param $form
  157. * The form the advanced options should be added to. This form already
  158. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  159. * @param $formstate
  160. * The current state fo the form passed in as $form.
  161. */
  162. function blast_ui_blastx_advanced_options_form(&$form, $form_state) {
  163. // Edit and Resubmit functionality.
  164. // We want to pull up the details from a previous blast and fill them in as defaults
  165. // for this blast.
  166. if (isset($form_state['prev_blast'])) {
  167. $defaults = _get_default_values($form_state['prev_blast']->options, 'blastn');
  168. }
  169. else {
  170. $defaults = _get_default_values(array(), 'blastx');
  171. }
  172. $form['ALG']['GParam'] = array(
  173. '#type' => 'fieldset',
  174. '#title' => t('General parameters'),
  175. '#collapsible' => FALSE,
  176. );
  177. $form['ALG']['GParam']['maxTarget'] = array(
  178. '#type' => 'select',
  179. '#title' => t('Max target sequences:'),
  180. '#options' => _get_max_target('blastx'),
  181. '#default_value' => $defaults['max_target_seqs'],
  182. '#description' => t('Select the maximum number of aligned sequences to display'),
  183. );
  184. $form['ALG']['GParam']['eVal'] = array(
  185. '#type' => 'textfield',
  186. '#title' => t('e-Value (Expected Threshold)'),
  187. '#default_value' => $defaults['evalue'],
  188. '#size' => 12,
  189. '#maxlength' => 20,
  190. '#description' => t('Expected number of chance matches in a random model. This number should be give in a decimal format. <a href="http://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 vedio tutorial</a>'),
  191. );
  192. /*eksc- need to learn how this is implemented for blastx
  193. $form['ALG']['GParam']['shortQueries'] = array(
  194. '#type' => 'checkbox',
  195. '#title' => t('Automatically adjust parameters for short input sequences'),
  196. '#default_value' => TRUE,
  197. );
  198. */
  199. $form['ALG']['GParam']['wordSize'] = array(
  200. '#type' => 'select',
  201. '#title' => t('Word size:'),
  202. '#options' => _get_word_size('blastx'),
  203. '#default_value' => $defaults['word_size'],
  204. '#description' => t('The length of the seed that initiates an alignment'),
  205. );
  206. // Scoring parameters
  207. //.........................
  208. $form['ALG']['SParam'] = array(
  209. '#type' => 'fieldset',
  210. '#title' => t('Scoring parameters'),
  211. '#collapsible' => FALSE,
  212. );
  213. $matrix_options = _get_matrix_options();
  214. $form['ALG']['SParam']['Matrix'] = array(
  215. '#type' => 'select',
  216. '#title' => 'Matrix',
  217. '#options' => $matrix_options,
  218. '#default_value' => $defaults['matrix'],
  219. '#description' => t('Assigns a score for aligning pairs of residues, and determines overall alignment score..'),
  220. '#ajax' => array(
  221. 'callback' => 'ajax_dependent_dropdown_callback',
  222. 'wrapper' => 'dropdown-second-replace',
  223. ),
  224. );
  225. $form['ALG']['GParam']['qRange'] = array(
  226. '#type' => 'textfield',
  227. '#title' => t('Max matches in a query range'),
  228. '#default_value' => $defaults['qRange'],
  229. '#size' => 12,
  230. '#maxlength' => 20,
  231. '#description' => t('Limit the number of matches to a query range. This option is useful if many strong matches to one part of a query may prevent BLAST from presenting weaker matches to another part of the query.'),
  232. );
  233. /*eksc- NOT match/mismatch but instead computational adjustments;
  234. need to learn how there are implemented for blastx
  235. $form['ALG']['SParam']['M&MScores'] = array(
  236. '#type' => 'select',
  237. '#title' => t('Match/Mismatch Scores:'),
  238. '#options' => array(
  239. 0 => t('No adjustment'),
  240. 1 => t('Composition-based statistics'),
  241. 2 => t('Conditional compositional score matrix adjustment'),
  242. 3 => t('Universal composition score matrix adjustment '),
  243. ),
  244. '#default_value' => 2,
  245. '#description' => t('Matrix adjustment method to compensate for amino acid composition of sequences'),
  246. );
  247. */
  248. }
  249. /**
  250. * Validate the advanced options provided by the BLASTn form above.
  251. *
  252. * @see blast_ui_blastx_advanced_options_form().
  253. */
  254. function blast_ui_blastx_advanced_options_form_validate($form, $form_state) {
  255. // Ensure that our textfields are what we expect them to be since we will
  256. // use them to generate the BLAST command.
  257. // First up, e-value. We expect the evalue to be a very small yet still
  258. // positive number. It may be given in scientific notation which is
  259. // luckily supported by is_numeric().
  260. if (!is_numeric($form_state['values']['eVal'])) {
  261. form_set_error('eVal', 'The e-value should be a very small number (scientific notation is supported). For example, <em>0.001</em> or, even better, <em>1e-10</em>.');
  262. }
  263. // Next textfield up, "Max matches in a query range" which is also expected
  264. // to be a positive number.
  265. if (!is_numeric($form_state['values']['qRange'])) {
  266. form_set_error('qRange', 'The "Max matches in a query range" should be a positive integer.');
  267. }
  268. }
  269. /**
  270. * Processed the advanced options provided by the BLASTx form above.
  271. *
  272. * @see blast_ui_blastx_advanced_options_form().
  273. */
  274. function blast_ui_blastx_advanced_options_form_submit($form, $form_state) {
  275. // Same as blastp form submit
  276. return blast_ui_blastp_advanced_options_form_submit($form, $form_state);
  277. }
  278. /**
  279. * @section
  280. * BLASTp: Search protein database using a protein query.
  281. * ----------------------------------------------------------------------------
  282. */
  283. /**
  284. * Adds the BLASTp Advanced Options to the passed in form.
  285. *
  286. * This form function is meant to be called within another form definition.
  287. *
  288. * @param $form
  289. * The form the advanced options should be added to. This form already
  290. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  291. * @param $formstate
  292. * The current state fo the form passed in as $form.
  293. */
  294. function blast_ui_blastp_advanced_options_form(&$form, $form_state) {
  295. // Edit and Resubmit functionality.
  296. // We want to pull up the details from a previous blast and fill them in as defaults
  297. // for this blast.
  298. if (isset($form_state['prev_blast'])) {
  299. $defaults = _get_default_values($form_state['prev_blast']->options, 'blastn');
  300. }
  301. else {
  302. $defaults = _get_default_values(array(), 'blastp');
  303. }
  304. //General parameters
  305. $form['ALG']['GParam'] = array(
  306. '#type' => 'fieldset',
  307. '#title' => t('General parameters'),
  308. '#collapsible' => FALSE,
  309. );
  310. $form['ALG']['GParam']['maxTarget'] = array(
  311. '#type' => 'select',
  312. '#title' => t('Max target sequences:'),
  313. '#options' => _get_max_target('blastp'),
  314. '#default_value' => $defaults['max_target_seqs'],
  315. '#description' => t('Select the maximum number of aligned sequences to display'),
  316. );
  317. /*eksc- remove until we learn how this is implemented
  318. $form['ALG']['GParam']['shortQueries'] = array(
  319. '#type' => 'checkbox',
  320. '#title' => t('Automatically adjust parameters for short input sequences'),
  321. '#default_value' => TRUE,
  322. );
  323. */
  324. $form['ALG']['GParam']['eVal'] = array(
  325. '#type' => 'textfield',
  326. '#title' => t('e-value(Expect threshold)'),
  327. '#default_value' => $defaults['evalue'],
  328. '#size' => 12,
  329. '#maxlength' => 20,
  330. '#description' => t('Expected number of chance matches in a random model.'),
  331. );
  332. $form['ALG']['GParam']['wordSize'] = array(
  333. '#type' => 'select',
  334. '#title' => t('Word size:'),
  335. '#options' => _get_word_size('blastp'),
  336. '#default_value' => $defaults['word_size'],
  337. '#description' => t('The length of the seed that initiates an alignment'),
  338. );
  339. $form['ALG']['GParam']['qRange'] = array(
  340. '#type' => 'textfield',
  341. '#title' => t('Max matches in a query range'),
  342. '#default_value' => $defaults['qRange'],
  343. '#size' => 12,
  344. '#maxlength' => 20,
  345. '#description' => t('Limit the number of matches to a query range. This option is useful if many strong matches to one part of a query may prevent BLAST from presenting weaker matches to another part of the query.'),
  346. );
  347. // Scoring parameters
  348. $form['ALG']['SParam'] = array(
  349. '#type' => 'fieldset',
  350. '#title' => t('Scoring parameters'),
  351. '#collapsible' => FALSE,
  352. );
  353. $matrix_options = _get_matrix_options();
  354. $form['ALG']['SParam']['Matrix'] = array(
  355. '#type' => 'select',
  356. '#title' => 'Matrix',
  357. '#options' => $matrix_options,
  358. '#default_value' => $defaults['matrix'],
  359. '#description' => t('Assigns a score for aligning pairs of residues, and determines overall alignment score..'),
  360. '#ajax' => array(
  361. 'callback' => 'ajax_dependent_dropdown_callback',
  362. 'wrapper' => 'dropdown-second-replace',
  363. ),
  364. );
  365. /*eksc- probably not used for blastp
  366. $form['ALG']['SParam']['gapCost'] = array(
  367. '#type' => 'select',
  368. '#title' => t('Gap Costs:'),
  369. '#prefix' => '<div id="dropdown-second-replace">',
  370. '#suffix' => '</div>',
  371. '#options' => _get_gap_for_matrix($selected),
  372. '#default_value' => 2,
  373. '#description' => t('Cost to create and extend a gap in an alignment.'),
  374. );
  375. */
  376. /*eksc- NOT match/mismatch but instead computational adjustments;
  377. need to learn how there are implemented for blastp
  378. $form['ALG']['SParam']['M&MScores'] = array(
  379. '#type' => 'select',
  380. '#title' => t('Match/Mismatch Scores:'),
  381. '#options' => array(
  382. 0 => t('No adjustment'),
  383. 1 => t('Composition-based statistics'),
  384. 2 => t('Conditional compositional score matrix adjustment'),
  385. 3 => t('Universal composition score matrix adjustment '),
  386. ),
  387. '#default_value' => 2,
  388. '#description' => t('Matrix adjustment method to compensate for amino acid composition of sequences'),
  389. );
  390. */
  391. }
  392. /**
  393. * Validate the advanced options provided by the BLASTp form above.
  394. *
  395. * @see blast_ui_blastp_advanced_options_form().
  396. */
  397. function blast_ui_blastp_advanced_options_form_validate($form, $form_state) {
  398. // Ensure that our textfields are what we expect them to be since we will
  399. // use them to generate the BLAST command.
  400. // First up, e-value. We expect the evalue to be a very small yet still
  401. // positive number. It may be given in scientific notation which is
  402. // luckily supported by is_numeric().
  403. if (!is_numeric($form_state['values']['eVal'])) {
  404. form_set_error('eVal', 'The e-value should be a very small number (scientific notation is supported). For example, <em>0.001</em> or, even better, <em>1e-10</em>.');
  405. }
  406. // Next textfield up, "Max matches in a query range" which is also expected
  407. // to be a positive number.
  408. if (!is_numeric($form_state['values']['qRange'])) {
  409. form_set_error('qRange', 'The "Max matches in a query range" should be a positive integer.');
  410. }
  411. }
  412. /**
  413. * Processed the advanced options provided by the BLASTp form above.
  414. *
  415. * @see blast_ui_blastp_advanced_options_form().
  416. */
  417. function blast_ui_blastp_advanced_options_form_submit($form, $form_state) {
  418. $eVal = $form_state['values']['eVal'];
  419. $trgtKey = $form_state['values']['maxTarget'];
  420. $numAlign = $form['ALG']['GParam']['maxTarget']['#options'][$trgtKey];
  421. $wsKey = $form_state['values']['wordSize'];
  422. $wordSize = $form['ALG']['GParam']['wordSize']['#options'][$wsKey];
  423. $qRange = $form_state['values']['qRange'];
  424. // Expand Gap Cost key into open and extend penalties
  425. $matrix = $form_state['values']['Matrix'];
  426. switch ($matrix) {
  427. case 'PAM30':
  428. $gapKey = $form_state['values']['gapCost'];
  429. switch ($gapKey) {
  430. case 0:
  431. $gapOpen = 7;
  432. $gapExtend = 2;
  433. break;
  434. case 1:
  435. $gapOpen = 6;
  436. $gapExtend = 2;
  437. break;
  438. case 2:
  439. $gapOpen = 5;
  440. $gapExtend = 2;
  441. break;
  442. case 3:
  443. $gapOpen = 10;
  444. $gapExtend = 1;
  445. break;
  446. case 4:
  447. $gapOpen = 9;
  448. $gapExtend = 1;
  449. break;
  450. case 5:
  451. $gapOpen = 8;
  452. $gapExtend = 1;
  453. break;
  454. }
  455. break;
  456. case 'PAM70':
  457. $gapKey = $form_state['values']['gapCost'];
  458. switch ($gapKey) {
  459. case 0:
  460. $gapOpen = 8;
  461. $gapExtend = 2;
  462. break;
  463. case 1:
  464. $gapOpen = 7;
  465. $gapExtend = 2;
  466. break;
  467. case 2:
  468. $gapOpen = 6;
  469. $gapExtend = 2;
  470. break;
  471. case 3:
  472. $gapOpen = 11;
  473. $gapExtend = 1;
  474. break;
  475. case 4:
  476. $gapOpen = 10;
  477. $gapExtend = 1;
  478. break;
  479. case 5:
  480. $gapOpen = 9;
  481. $gapExtend = 1;
  482. break;
  483. }
  484. break;
  485. case 'PAM250':
  486. $gapKey = $form_state['values']['gapCost'];
  487. switch ($gapKey) {
  488. case 0:
  489. $gapOpen = 15;
  490. $gapExtend = 3;
  491. break;
  492. case 1:
  493. $gapOpen = 14;
  494. $gapExtend = 3;
  495. break;
  496. case 2:
  497. $gapOpen = 13;
  498. $gapExtend = 3;
  499. break;
  500. case 3:
  501. $gapOpen = 12;
  502. $gapExtend = 3;
  503. break;
  504. case 4:
  505. $gapOpen = 11;
  506. $gapExtend = 3;
  507. break;
  508. case 5:
  509. $gapOpen = 17;
  510. $gapExtend = 2;
  511. break;
  512. case 6:
  513. $gapOpen = 16;
  514. $gapExtend = 2;
  515. break;
  516. case 7:
  517. $gapOpen = 15;
  518. $gapExtend = 2;
  519. break;
  520. case 8:
  521. $gapOpen = 14;
  522. $gapExtend = 2;
  523. break;
  524. case 9:
  525. $gapOpen = 13;
  526. $gapExtend = 2;
  527. break;
  528. case 10:
  529. $gapOpen = 21;
  530. $gapExtend = 1;
  531. break;
  532. case 11:
  533. $gapOpen = 20;
  534. $gapExtend = 1;
  535. break;
  536. case 12:
  537. $gapOpen = 19;
  538. $gapExtend = 1;
  539. break;
  540. case 13:
  541. $gapOpen = 18;
  542. $gapExtend = 1;
  543. break;
  544. case 14:
  545. $gapOpen = 17;
  546. $gapExtend = 1;
  547. break;
  548. }
  549. break;
  550. case 'BLOSUM80':
  551. $gapKey = $form_state['values']['gapCost'];
  552. switch ($gapKey) {
  553. case 0:
  554. $gapOpen = 8;
  555. $gapExtend = 2;
  556. break;
  557. case 1:
  558. $gapOpen = 7;
  559. $gapExtend = 2;
  560. break;
  561. case 2:
  562. $gapOpen = 6;
  563. $gapExtend = 2;
  564. break;
  565. case 3:
  566. $gapOpen = 11;
  567. $gapExtend = 1;
  568. break;
  569. case 4:
  570. $gapOpen = 10;
  571. $gapExtend = 1;
  572. break;
  573. case 5:
  574. $gapOpen = 9;
  575. $gapExtend = 1;
  576. break;
  577. }
  578. break;
  579. case 'BLOSUM62':
  580. $gapKey = $form_state['values']['gapCost'];
  581. switch ($gapKey) {
  582. case 0:
  583. $gapOpen = 11;
  584. $gapExtend = 2;
  585. break;
  586. case 1:
  587. $gapOpen = 10;
  588. $gapExtend = 2;
  589. break;
  590. case 2:
  591. $gapOpen = 9;
  592. $gapExtend = 2;
  593. break;
  594. case 3:
  595. $gapOpen = 8;
  596. $gapExtend = 2;
  597. break;
  598. case 4:
  599. $gapOpen = 7;
  600. $gapExtend = 2;
  601. break;
  602. case 5:
  603. $gapOpen = 6;
  604. $gapExtend = 2;
  605. break;
  606. case 6:
  607. $gapOpen = 13;
  608. $gapExtend = 1;
  609. break;
  610. case 7:
  611. $gapOpen = 12;
  612. $gapExtend = 1;
  613. break;
  614. case 8:
  615. $gapOpen = 11;
  616. $gapExtend = 1;
  617. break;
  618. case 9:
  619. $gapOpen = 10;
  620. $gapExtend = 1;
  621. break;
  622. case 10:
  623. $gapOpen = 9;
  624. $gapExtend = 1;
  625. break;
  626. }
  627. break;
  628. case 'BLOSUM45':
  629. $gapKey = $form_state['values']['gapCost'];
  630. switch ($gapKey) {
  631. case 0:
  632. $gapOpen = 13;
  633. $gapExtend = 3;
  634. break;
  635. case 1:
  636. $gapOpen = 12;
  637. $gapExtend = 3;
  638. break;
  639. case 2:
  640. $gapOpen = 11;
  641. $gapExtend = 3;
  642. break;
  643. case 3:
  644. $gapOpen = 10;
  645. $gapExtend = 3;
  646. break;
  647. case 4:
  648. $gapOpen = 15;
  649. $gapExtend = 2;
  650. break;
  651. case 5:
  652. $gapOpen = 14;
  653. $gapExtend = 2;
  654. break;
  655. case 6:
  656. $gapOpen = 13;
  657. $gapExtend = 2;
  658. break;
  659. case 7:
  660. $gapOpen = 12;
  661. $gapExtend = 2;
  662. break;
  663. case 8:
  664. $gapOpen = 19;
  665. $gapExtend = 1;
  666. break;
  667. case 9:
  668. $gapOpen = 18;
  669. $gapExtend = 1;
  670. break;
  671. case 10:
  672. $gapOpen = 17;
  673. $gapExtend = 1;
  674. break;
  675. case 11:
  676. $gapOpen = 16;
  677. $gapExtend = 1;
  678. break;
  679. }
  680. break;
  681. case 'BLOSUM50':
  682. $gapKey = $form_state['values']['gapCost'];
  683. switch ($gapKey) {
  684. case 0:
  685. $gapOpen = 13;
  686. $gapExtend = 3;
  687. break;
  688. case 1:
  689. $gapOpen = 12;
  690. $gapExtend = 3;
  691. break;
  692. case 2:
  693. $gapOpen = 11;
  694. $gapExtend = 3;
  695. break;
  696. case 3:
  697. $gapOpen = 10;
  698. $gapExtend = 3;
  699. break;
  700. case 4:
  701. $gapOpen = 9;
  702. $gapExtend = 3;
  703. break;
  704. case 5:
  705. $gapOpen = 16;
  706. $gapExtend = 2;
  707. break;
  708. case 6:
  709. $gapOpen = 15;
  710. $gapExtend = 2;
  711. break;
  712. case 7:
  713. $gapOpen = 14;
  714. $gapExtend = 2;
  715. break;
  716. case 8:
  717. $gapOpen = 13;
  718. $gapExtend = 2;
  719. break;
  720. case 9:
  721. $gapOpen = 12;
  722. $gapExtend = 2;
  723. break;
  724. case 10:
  725. $gapOpen = 19;
  726. $gapExtend = 1;
  727. break;
  728. case 11:
  729. $gapOpen = 18;
  730. $gapExtend = 1;
  731. break;
  732. case 12:
  733. $gapOpen = 17;
  734. $gapExtend = 1;
  735. break;
  736. case 13:
  737. $gapOpen = 16;
  738. $gapExtend = 1;
  739. break;
  740. case 14:
  741. $gapOpen = 15;
  742. $gapExtend = 1;
  743. break;
  744. }
  745. break;
  746. case 'BLOSUM90':
  747. $gapKey = $form_state['values']['gapCost'];
  748. switch ($gapKey) {
  749. case 0:
  750. $gapOpen = 9;
  751. $gapExtend = 2;
  752. break;
  753. case 1:
  754. $gapOpen = 8;
  755. $gapExtend = 2;
  756. break;
  757. case 2:
  758. $gapOpen = 7;
  759. $gapExtend = 2;
  760. break;
  761. case 3:
  762. $gapOpen = 6;
  763. $gapExtend = 2;
  764. break;
  765. case 4:
  766. $gapOpen = 11;
  767. $gapExtend = 1;
  768. break;
  769. case 5:
  770. $gapOpen = 10;
  771. $gapExtend = 1;
  772. break;
  773. case 6:
  774. $gapOpen = 9;
  775. $gapExtend = 1;
  776. break;
  777. }
  778. break;
  779. }
  780. //eksc- need to implement query range limit
  781. // q_range
  782. return array(
  783. 'max_target_seqs' => $numAlign,
  784. 'evalue' => $eVal,
  785. 'word_size' => $wordSize,
  786. 'gapopen' => $gapOpen,
  787. 'gapextend' => $gapExtend,
  788. 'culling_limit' => $qRange,
  789. 'matrix' => $matrix,
  790. );
  791. }//blast_ui_blastp_advanced_options_form_submit
  792. /**
  793. * Fill the matrix dropdown list with appropriate options
  794. *
  795. * @return
  796. * An array consisting of matrices name for the first dropdown list
  797. */
  798. function _get_matrix_options() {
  799. return drupal_map_assoc(array(
  800. t('PAM30'),
  801. t('PAM70'),
  802. t('PAM250'),
  803. t('BLOSUM80'),
  804. t('BLOSUM62'),
  805. t('BLOSUM45'),
  806. t('BLOSUM50'),
  807. t('BLOSUM90'),
  808. ));
  809. }
  810. /**
  811. * Fill the gap penalty dropdown list with appropriate options given selected matrix
  812. *
  813. * @return
  814. * An array containing open and extension gap values for the chosen matrix (to fill the second dropdown list)
  815. */
  816. function _get_gap_for_matrix($key = '') {
  817. $options = array(
  818. t('PAM30') => drupal_map_assoc(array(
  819. t('Existence: 7 Extension: 2'),
  820. t('Existence: 6 Extension: 2'),
  821. t('Existence: 5 Extension: 2'),
  822. t('Existence: 10 Extension: 1'),
  823. t('Existence: 9 Extension: 1'),
  824. t('Existence: 8 Extension: 1'),
  825. )),
  826. t('PAM70') => drupal_map_assoc(array(
  827. t('Existence: 8 Extension: 2'),
  828. t('Existence: 7 Extension: 2'),
  829. t('Existence: 6 Extension: 2'),
  830. t('Existence: 11 Extension: 1'),
  831. t('Existence: 10 Extension: 1'),
  832. t('Existence: 9 Extension: 1'),
  833. )),
  834. t('PAM250') => drupal_map_assoc(array(
  835. t('Existence: 15 Extension: 3'),
  836. t('Existence: 14 Extension: 3'),
  837. t('Existence: 13 Extension: 3'),
  838. t('Existence: 12 Extension: 3'),
  839. t('Existence: 11 Extension: 3'),
  840. t('Existence: 17 Extension: 2'),
  841. t('Existence: 16 Extension: 2'),
  842. t('Existence: 15 Extension: 2'),
  843. t('Existence: 14 Extension: 2'),
  844. t('Existence: 13 Extension: 2'),
  845. t('Existence: 21 Extension: 1'),
  846. t('Existence: 20 Extension: 1'),
  847. t('Existence: 19 Extension: 1'),
  848. t('Existence: 18 Extension: 1'),
  849. t('Existence: 17 Extension: 1'),
  850. )),
  851. t('BLOSUM80') => drupal_map_assoc(array(
  852. t('Existence: 8 Extension: 2'),
  853. t('Existence: 7 Extension: 2'),
  854. t('Existence: 6 Extension: 2'),
  855. t('Existence: 11 Extension: 1'),
  856. t('Existence: 10 Extension: 1'),
  857. t('Existence: 9 Extension: 1'),
  858. )),
  859. t('BLOSUM62') => drupal_map_assoc(array(
  860. t('Existence: 11 Extension: 2'),
  861. t('Existence: 10 Extension: 2'),
  862. t('Existence: 9 Extension: 2'),
  863. t('Existence: 8 Extension: 2'),
  864. t('Existence: 7 Extension: 2'),
  865. t('Existence: 6 Extension: 2'),
  866. t('Existence: 13 Extension: 1'),
  867. t('Existence: 12 Extension: 1'),
  868. t('Existence: 11 Extension: 1'),
  869. t('Existence: 10 Extension: 1'),
  870. t('Existence: 9 Extension: 1'),
  871. )),
  872. t('BLOSUM45') => drupal_map_assoc(array(
  873. t('Existence: 13 Extension: 3'),
  874. t('Existence: 12 Extension: 3'),
  875. t('Existence: 11 Extension: 3'),
  876. t('Existence: 10 Extension: 3'),
  877. t('Existence: 15 Extension: 2'),
  878. t('Existence: 14 Extension: 2'),
  879. t('Existence: 13 Extension: 2'),
  880. t('Existence: 12 Extension: 2'),
  881. t('Existence: 19 Extension: 1'),
  882. t('Existence: 18 Extension: 1'),
  883. t('Existence: 17 Extension: 1'),
  884. t('Existence: 16 Extension: 1'),
  885. )),
  886. t('BLOSUM50') => drupal_map_assoc(array(
  887. t('Existence: 13 Extension: 3'),
  888. t('Existence: 12 Extension: 3'),
  889. t('Existence: 11 Extension: 3'),
  890. t('Existence: 10 Extension: 3'),
  891. t('Existence: 9 Extension: 3'),
  892. t('Existence: 16 Extension: 2'),
  893. t('Existence: 15 Extension: 2'),
  894. t('Existence: 14 Extension: 2'),
  895. t('Existence: 13 Extension: 2'),
  896. t('Existence: 12 Extension: 2'),
  897. t('Existence: 19 Extension: 1'),
  898. t('Existence: 18 Extension: 1'),
  899. t('Existence: 17 Extension: 1'),
  900. t('Existence: 16 Extension: 1'),
  901. t('Existence: 15 Extension: 1'),
  902. )),
  903. t('BLOSUM90') => drupal_map_assoc(array(
  904. t('Existence: 9 Extension: 2'),
  905. t('Existence: 8 Extension: 2'),
  906. t('Existence: 7 Extension: 2'),
  907. t('Existence: 6 Extension: 2'),
  908. t('Existence: 11 Extension: 1'),
  909. t('Existence: 10 Extension: 1'),
  910. t('Existence: 9 Extension: 1'),
  911. )),
  912. );
  913. if (isset($options[$key])) {
  914. return $options[$key];
  915. }
  916. else {
  917. return array();
  918. }
  919. }//_get_gap_for_matrix
  920. /**
  921. * Respond to Ajax dropdown call
  922. */
  923. function ajax_dependent_dropdown_callback($form, $form_state) {
  924. return $form['ALG']['SParam']['gapCost'];
  925. }
  926. /**
  927. * @section
  928. * tBLASTn: Search translated nucleotide database using a protein query.
  929. * ----------------------------------------------------------------------------
  930. */
  931. /**
  932. * Adds the tBLASTn Advanced Options to the passed in form.
  933. *
  934. * This form function is meant to be called within another form definition.
  935. *
  936. * @param $form
  937. * The form the advanced options should be added to. This form already
  938. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  939. * @param $formstate
  940. * The current state fo the form passed in as $form.
  941. */
  942. function blast_ui_tblastn_advanced_options_form(&$form, $form_state) {
  943. // Edit and Resubmit functionality.
  944. // We want to pull up the details from a previous blast and fill them in as defaults
  945. // for this blast.
  946. if (isset($form_state['prev_blast'])) {
  947. $defaults = _get_default_values($form_state['prev_blast']->options, 'blastn');
  948. }
  949. else {
  950. $defaults = _get_default_values(array(), 'tblastn');
  951. }
  952. $form['ALG']['GParam'] = array(
  953. '#type' => 'fieldset',
  954. '#title' => t('General parameters'),
  955. '#collapsible' => FALSE,
  956. );
  957. $form['ALG']['GParam']['maxTarget'] = array(
  958. '#type' => 'select',
  959. '#title' => t('Max target sequences:'),
  960. '#options' => _get_max_target('tblastn'),
  961. '#default_value' => $defaults['max_target_seqs'],
  962. '#description' => t('Select the maximum number of aligned sequences to display'),
  963. );
  964. $form['ALG']['GParam']['eVal'] = array(
  965. '#type' => 'textfield',
  966. '#title' => t('e-Value (Expected Threshold)'),
  967. '#default_value' => $defaults['evalue'],
  968. '#size' => 12,
  969. '#maxlength' => 20,
  970. '#description' => t('Expected number of chance matches in a random model. This number should be give in a decimal format. <a href="http://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 vedio tutorial</a>'),
  971. );
  972. /*eksc- need to learn how this is implemented for tblastn
  973. $form['ALG']['GParam']['shortQueries'] = array(
  974. '#type' => 'checkbox',
  975. '#title' => t('Automatically adjust parameters for short input sequences'),
  976. '#default_value' => TRUE,
  977. );
  978. */
  979. $form['ALG']['GParam']['wordSize'] = array(
  980. '#type' => 'select',
  981. '#title' => t('Word size:'),
  982. '#options' => _get_word_size('tblastn'),
  983. '#default_value' => $defaults['word_size'],
  984. '#description' => t('The length of the seed that initiates an alignment'),
  985. );
  986. // Scoring parameters
  987. //.........................
  988. $form['ALG']['SParam'] = array(
  989. '#type' => 'fieldset',
  990. '#title' => t('Scoring parameters'),
  991. '#collapsible' => FALSE,
  992. );
  993. $matrix_options = _get_matrix_options();
  994. $form['ALG']['SParam']['Matrix'] = array(
  995. '#type' => 'select',
  996. '#title' => 'Matrix',
  997. '#options' => $matrix_options,
  998. '#default_value' => $defaults['matrix'],
  999. '#description' => t('Assigns a score for aligning pairs of residues, and determines overall alignment score..'),
  1000. '#ajax' => array(
  1001. 'callback' => 'ajax_dependent_dropdown_callback',
  1002. 'wrapper' => 'dropdown-second-replace',
  1003. ),
  1004. );
  1005. $form['ALG']['SParam']['gapCost'] = array(
  1006. '#type' => 'select',
  1007. '#title' => t('Gap Costs:'),
  1008. '#prefix' => '<div id="dropdown-second-replace">',
  1009. '#suffix' => '</div>',
  1010. '#options' => _get_gap_for_matrix($defaults['matrix']),
  1011. '#default_value' => 2,
  1012. '#description' => t('Cost to create and extend a gap in an alignment.'),
  1013. );
  1014. $form['ALG']['GParam']['qRange'] = array(
  1015. '#type' => 'textfield',
  1016. '#title' => t('Max matches in a query range'),
  1017. '#default_value' => $defaults['qRange'],
  1018. '#size' => 12,
  1019. '#maxlength' => 20,
  1020. '#description' => t('Limit the number of matches to a query range. This option is useful if many strong matches to one part of a query may prevent BLAST from presenting weaker matches to another part of the query.'),
  1021. );
  1022. }
  1023. /**
  1024. * Validate the advanced options provided by the tBLASTn form above.
  1025. *
  1026. * @see blast_ui_tblastn_advanced_options_form().
  1027. */
  1028. function blast_ui_tblastn_advanced_options_form_validate($form, $form_state) {
  1029. // Ensure that our textfields are what we expect them to be since we will
  1030. // use them to generate the BLAST command.
  1031. // First up, e-value. We expect the evalue to be a very small yet still
  1032. // positive number. It may be given in scientific notation which is
  1033. // luckily supported by is_numeric().
  1034. if (!is_numeric($form_state['values']['eVal'])) {
  1035. form_set_error('eVal', 'The e-value should be a very small number (scientific notation is supported). For example, <em>0.001</em> or, even better, <em>1e-10</em>.');
  1036. }
  1037. // Next textfield up, "Max matches in a query range" which is also expected
  1038. // to be a positive number.
  1039. if (!is_numeric($form_state['values']['qRange'])) {
  1040. form_set_error('qRange', 'The "Max matches in a query range" should be a positive integer.');
  1041. }
  1042. }
  1043. /**
  1044. * Processed the advanced options provided by the tBLASTn form above.
  1045. *
  1046. * @see blast_ui_tblastn_advanced_options_form().
  1047. */
  1048. function blast_ui_tblastn_advanced_options_form_submit($form, $form_state) {
  1049. return blast_ui_blastp_advanced_options_form_submit($form, $form_state);
  1050. }
  1051. /**
  1052. * Get default form values; may come from saved job data if user is re-running
  1053. * a previous job.
  1054. */
  1055. function _get_default_values($options) {
  1056. // restore previous values or set to default
  1057. $max_target = (isset($options['max_target_seqs']))
  1058. ? $options['max_target_seqs'] : 0;
  1059. $short_queries = (isset($options['shortQueries']))
  1060. ? $options['shortQueries'] : true;
  1061. $evalue = (isset($options['evalue']))
  1062. ? $options['evalue'] : variable_get('eVal', 0.001);
  1063. $word_size = (isset($options['word_size']))
  1064. ? $options['word_size'] : 11;
  1065. $qRange = (isset($options['culling_limit']))
  1066. ? $options['culling_limit'] : variable_get('qRange',0);
  1067. $matchmiss = 0;
  1068. $reward = (isset($options['reward']))
  1069. ? $options['reward'] : 1;
  1070. $penalty = (isset($options['penalty']))
  1071. ? $options['penalty'] : -2;
  1072. if ($reward == 1) {
  1073. switch ($penalty) {
  1074. case -1: $matchmiss = 5; break;
  1075. case -2: $matchmiss = 0; break;
  1076. case -3: $matchmiss = 1; break;
  1077. case -4: $matchmiss = 2; break;
  1078. }
  1079. }
  1080. else if ($reward == 2) {
  1081. $matchmiss = 3;
  1082. }
  1083. else if ($reward == 3) {
  1084. $matchmis = 4;
  1085. }
  1086. else if ($eward == 4) {
  1087. $matchmiss = 5;
  1088. }
  1089. $gap = 0;
  1090. $gapopen = (isset($options['gapopen']))
  1091. ? $options['gapopen'] : 5;
  1092. $gapextend = (isset($options['gapextend']))
  1093. ? $options['gapextend'] : 2;
  1094. if ($gapextend == 2) {
  1095. switch ($gapopen) {
  1096. case 5: $gap = 0; break;
  1097. case 2: $gap = 1; break;
  1098. case 1: $gap = 2; break;
  1099. case 0: $gap = 3; break;
  1100. }
  1101. }
  1102. else if ($gapextend == 1) {
  1103. switch ($gapopen) {
  1104. case 3: $gap = 4;
  1105. case 2: $gap = 5;
  1106. case 1: $gap = 6;
  1107. }
  1108. }
  1109. // eksc- need to implement query range limit
  1110. // $q_range = 0;
  1111. $matrix = (isset($options['matrix']))
  1112. ? $options['matrix'] : 'PAM30';
  1113. return array(
  1114. 'max_target_seqs' => $max_target,
  1115. 'short_queries' => $short_queries,
  1116. 'word_size' => $word_size,
  1117. 'evalue' => $evalue,
  1118. 'matchmiss' => $matchmiss,
  1119. 'gap' => $gap,
  1120. 'qRange' => $qRange,
  1121. 'matrix' => $matrix,
  1122. );
  1123. }//_get_default_values
  1124. /**
  1125. * Get a list of options for the max_target_seq blast option.
  1126. *
  1127. * The options are the same for all programs
  1128. * and describe the maximum number of aligned sequences to keep.
  1129. */
  1130. function _get_max_target($which) {
  1131. switch ($which) {
  1132. case 'blastn':
  1133. case 'blastx':
  1134. case 'blastp':
  1135. case 'tblastn':
  1136. return array(
  1137. 0 => t(' '),
  1138. 10 => t('10'),
  1139. 50 => t('50'),
  1140. 100 => t('100'),
  1141. 250 => t('250'),
  1142. 500 => t('500'),
  1143. 1000 => t('1000'),
  1144. 5000 => t('5000'),
  1145. 10000 => t('10000'),
  1146. 20000 => t('20000'),
  1147. );
  1148. }//switch
  1149. }
  1150. /**
  1151. * Get a list of options for work size.
  1152. */
  1153. function _get_word_size($which) {
  1154. switch ($which) {
  1155. case 'blastn':
  1156. return array(
  1157. 7 => t('7'),
  1158. 11 => t('11'),
  1159. 15 => t('15'),
  1160. 16 => t('16'),
  1161. 20 => t('20'),
  1162. 24 => t('24'),
  1163. 28 => t('28'),
  1164. 32 => t('32'),
  1165. 48 => t('48'),
  1166. 64 => t('64'),
  1167. 128 => t('128'),
  1168. 256 => t('256'),
  1169. );
  1170. case 'blastx':
  1171. case 'blastp':
  1172. case 'tblastn':
  1173. return array(
  1174. // 2 => t('2'),
  1175. 3 => t('3'),
  1176. 6 => t('6'),
  1177. );
  1178. }//switch
  1179. }
  1180. /**
  1181. * Get a list of options for match/mismatch ratio.
  1182. */
  1183. function _get_match_mismatch($which) {
  1184. switch ($which) {
  1185. case 'blastn':
  1186. return array(
  1187. 0 => t('1,-2'),
  1188. 1 => t('1,-3'),
  1189. 2 => t('1,-4'),
  1190. 3 => t('2,-3'),
  1191. 4 => t('4,-5'),
  1192. 5 => t('1,-1'),
  1193. );
  1194. }//switch
  1195. }
  1196. /**
  1197. * Get a list of options for gaps.
  1198. */
  1199. function _get_gap($which) {
  1200. switch ($which) {
  1201. case 'blastn':
  1202. return array(
  1203. 0 => t('Existence: 5 Extension: 2'),
  1204. 1 => t('Existence: 2 Extension: 2'),
  1205. 2 => t('Existence: 1 Extension: 2'),
  1206. 3 => t('Existence: 0 Extension: 2'),
  1207. 4 => t('Existence: 3 Extension: 1'),
  1208. 5 => t('Existence: 2 Extension: 1'),
  1209. 6 => t('Existence: 1 Extension: 1'),
  1210. );
  1211. }//switch
  1212. }
  1213. /**
  1214. * Translate above gap options into blast gap open and extend costs.
  1215. */
  1216. function _set_gap($gap_key) {
  1217. switch ($gap_key) {
  1218. case 0:
  1219. $gapOpen = 5;
  1220. $gapExtend = 2;
  1221. break;
  1222. case 1:
  1223. $gapOpen = 2;
  1224. $gapExtend = 2;
  1225. break;
  1226. case 2:
  1227. $gapOpen = 1;
  1228. $gapExtend = 2;
  1229. break;
  1230. case 3:
  1231. $gapOpen = 0;
  1232. $gapExtend = 2;
  1233. break;
  1234. case 4:
  1235. $gapOpen = 3;
  1236. $gapExtend = 1;
  1237. break;
  1238. case 5:
  1239. $gapOpen = 2;
  1240. $gapExtend = 1;
  1241. break;
  1242. case 6:
  1243. $gapOpen = 1;
  1244. $gapExtend = 1;
  1245. break;
  1246. }//switch
  1247. return array('gapOpen' => $gapOpen, 'gapExtend' => $gapExtend);
  1248. }
  1249. /**
  1250. * Translate mismatch/match ratio option into blast penalty/reward options.
  1251. */
  1252. function _set_match_mismatch($m_m) {
  1253. switch ($m_m) {
  1254. case 0:
  1255. $penalty = -2;
  1256. $reward = 1;
  1257. break;
  1258. case 1:
  1259. $penalty = -3;
  1260. $reward = 1;
  1261. break;
  1262. case 2:
  1263. $penalty = -4;
  1264. $reward = 1;
  1265. break;
  1266. case 3:
  1267. $penalty = -3;
  1268. $reward = 2;
  1269. break;
  1270. case 4:
  1271. $penalty = -5;
  1272. $reward = 4;
  1273. break;
  1274. case 5:
  1275. $penalty = -1;
  1276. $reward = 1;
  1277. break;
  1278. }//switch
  1279. return array('penalty' => $penalty, 'reward' => $reward);
  1280. }