blast_ui.form_advanced_options.inc 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  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. // General parameters
  24. //.........................
  25. $form['ALG']['GParam'] = array(
  26. '#type' => 'fieldset',
  27. '#title' => t('General parameters'),
  28. '#collapsible' => FALSE,
  29. );
  30. $form['ALG']['GParam']['maxTarget'] = array(
  31. '#type' => 'select',
  32. '#title' => t('Max target sequences:'),
  33. '#options' => array(
  34. 0 => t('10'),
  35. 1 => t('50'),
  36. 2 => t('100'),
  37. 3 => t('250'),
  38. 4 => t('500'),
  39. 5 => t('1000'),
  40. 6 => t('5000'),
  41. 7 => t('10000'),
  42. 8 => t('20000'),
  43. ),
  44. '#default_value' => 2,
  45. '#description' => t('Select the maximum number of aligned sequences to display'),
  46. );
  47. $form['ALG']['GParam']['shortQueries'] = array(
  48. '#type' => 'checkbox',
  49. '#title' => t('Automatically adjust parameters for short input sequences'),
  50. '#default_value' => TRUE,
  51. );
  52. $form['ALG']['GParam']['eVal'] = array(
  53. '#type' => 'textfield',
  54. '#title' => t('e-Value (Expected Threshold)'),
  55. '#default_value' => 10,
  56. '#size' => 12,
  57. '#maxlength' => 20,
  58. '#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>'),
  59. );
  60. $form['ALG']['GParam']['wordSize'] = array(
  61. '#type' => 'select',
  62. '#title' => t('Word size:'),
  63. '#options' => array(
  64. 0 => t('16'),
  65. 1 => t('20'),
  66. 2 => t('24'),
  67. 3 => t('28'),
  68. 4 => t('32'),
  69. 5 => t('48'),
  70. 6 => t('64'),
  71. 7 => t('128'),
  72. 8 => t('256'),
  73. ),
  74. '#default_value' => 3,
  75. '#description' => t('The length of the seed that initiates an alignment'),
  76. );
  77. $form['ALG']['GParam']['qRange'] = array(
  78. '#type' => 'textfield',
  79. '#title' => t('Max matches in a query range'),
  80. '#default_value' => 0,
  81. '#size' => 12,
  82. '#maxlength' => 20,
  83. '#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.'),
  84. );
  85. // Scoring parameters
  86. //.........................
  87. $form['ALG']['SParam'] = array(
  88. '#type' => 'fieldset',
  89. '#title' => t('Scoring parameters'),
  90. '#collapsible' => FALSE,
  91. );
  92. $form['ALG']['SParam']['M&MScores'] = array(
  93. '#type' => 'select',
  94. '#title' => t('Match/Mismatch Scores:'),
  95. '#options' => array(
  96. 0 => t('1,-2'),
  97. 1 => t('1,-3'),
  98. 2 => t('1,-4'),
  99. 3 => t('2,-3'),
  100. 4 => t('4,-5'),
  101. 5 => t('1,-1'),
  102. ),
  103. '#default_value' => 0,
  104. '#description' => t('Reward and penalty for matching and mismatching bases.'),
  105. );
  106. $form['ALG']['SParam']['gapCost'] = array(
  107. '#type' => 'select',
  108. '#title' => t('Gap Costs:'),
  109. '#options' => array(
  110. 0 => t('Existence: 5 Extension: 2'),
  111. 1 => t('Existence: 2 Extension: 2'),
  112. 2 => t('Existence: 1 Extension: 2'),
  113. 3 => t('Existence: 0 Extension: 2'),
  114. 4 => t('Existence: 3 Extension: 1'),
  115. 5 => t('Existence: 2 Extension: 1'),
  116. 6 => t('Existence: 1 Extension: 1'),
  117. ),
  118. '#default_value' => 0,
  119. '#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.'),
  120. );
  121. }
  122. /**
  123. * Validate the advanced options provided by the BLASTn form above.
  124. *
  125. * @see blast_ui_blastn_advanced_options_form().
  126. */
  127. function blast_ui_blastn_advanced_options_form_validate($form, $form_state) { }
  128. /**
  129. * Processed the advanced options provided by the BLASTn form above.
  130. *
  131. * @see blast_ui_blastn_advanced_options_form().
  132. */
  133. function blast_ui_blastn_advanced_options_form_submit($form, $form_state) {
  134. $eVal = $form_state['values']['eVal'];
  135. $trgtKey = $form_state['values']['maxTarget'];
  136. $numAlign = $form['ALG']['GParam']['maxTarget']['#options'][$trgtKey];
  137. $wsKey = $form_state['values']['wordSize'];
  138. $wordSize = $form['ALG']['GParam']['wordSize']['#options'][$wsKey];
  139. // Expand Gap Cost key into open and extend penalties
  140. $gapKey = $form_state['values']['gapCost'];
  141. switch ($gapKey) {
  142. case 0:
  143. $gapOpen = 5;
  144. $gapExtend = 2;
  145. break;
  146. case 1:
  147. $gapOpen = 2;
  148. $gapExtend = 2;
  149. break;
  150. case 2:
  151. $gapOpen = 1;
  152. $gapExtend = 2;
  153. break;
  154. case 3:
  155. $gapOpen = 0;
  156. $gapExtend = 2;
  157. break;
  158. case 4:
  159. $gapOpen = 3;
  160. $gapExtend = 1;
  161. break;
  162. case 5:
  163. $gapOpen = 2;
  164. $gapExtend = 1;
  165. break;
  166. case 6:
  167. $gapOpen = 1;
  168. $gapExtend = 1;
  169. break;
  170. }
  171. // Epand Match/Mismatch option into penalty/reward values
  172. // @todo Amir: Is the switch supposed to be for $scoreKey?
  173. $scoreKey = $form_state['values']['M&MScores'];
  174. switch ($gapKey) {
  175. case 0:
  176. $penalty = -2;
  177. $reward = 1;
  178. break;
  179. case 1:
  180. $penalty = -3;
  181. $reward = 1;
  182. break;
  183. case 2:
  184. $penalty = -4;
  185. $reward = 1;
  186. break;
  187. case 3:
  188. $penalty = -3;
  189. $reward = 2;
  190. break;
  191. case 4:
  192. $penalty = -5;
  193. $reward = 4;
  194. break;
  195. case 5:
  196. $penalty = -1;
  197. $reward = 1;
  198. break;
  199. }
  200. return array(
  201. 'evalue' => $eVal,
  202. 'word_size' => $wordSize,
  203. 'gapopen' => $gapOpen,
  204. 'gapextend' => $gapExtend,
  205. 'penalty' => $penalty,
  206. 'reward' => $reward
  207. );
  208. }
  209. /**
  210. * @section
  211. * BLASTx: Search protein database using a translated nucleotide query.
  212. * ----------------------------------------------------------------------------
  213. */
  214. /**
  215. * Adds the BLASTx Advanced Options to the passed in form.
  216. *
  217. * This form function is meant to be called within another form definition.
  218. *
  219. * @param $form
  220. * The form the advanced options should be added to. This form already
  221. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  222. * @param $formstate
  223. * The current state fo the form passed in as $form.
  224. */
  225. function blast_ui_blastx_advanced_options_form(&$form, $form_state) {
  226. $form['ALG']['GParam'] = array(
  227. '#type' => 'fieldset',
  228. '#title' => t('General parameters'),
  229. '#collapsible' => FALSE,
  230. );
  231. $form['ALG']['GParam']['maxTarget'] = array(
  232. '#type' => 'select',
  233. '#title' => t('Max target sequences:'),
  234. '#options' => array(
  235. 0 => t('10'),
  236. 1 => t('50'),
  237. 2 => t('100'),
  238. 3 => t('250'),
  239. 4 => t('500'),
  240. 5 => t('1000'),
  241. 6 => t('5000'),
  242. 7 => t('10000'),
  243. 8 => t('20000'),
  244. ),
  245. '#default_value' => 2,
  246. '#description' => t('Select the maximum number of aligned sequences to display'),
  247. );
  248. $form['ALG']['GParam']['eVal'] = array(
  249. '#type' => 'textfield',
  250. '#title' => t('e-Value (Expected Threshold)'),
  251. '#default_value' => 10,
  252. '#size' => 12,
  253. '#maxlength' => 20,
  254. '#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>'),
  255. );
  256. }
  257. /**
  258. * Validate the advanced options provided by the BLASTn form above.
  259. *
  260. * @see blast_ui_blastx_advanced_options_form().
  261. */
  262. function blast_ui_blastx_advanced_options_form_validate($form, $form_state) { }
  263. /**
  264. * Processed the advanced options provided by the BLASTx form above.
  265. *
  266. * @see blast_ui_blastx_advanced_options_form().
  267. */
  268. function blast_ui_blastx_advanced_options_form_submit($form, $form_state) {
  269. $eVal = $form_state['values']['eVal'];
  270. $trgtKey = $form_state['values']['maxTarget'];
  271. $numAlign = $form['ALG']['GParam']['maxTarget']['#options'][$trgtKey];
  272. return array(
  273. 'evalue' => $eVal,
  274. );
  275. }
  276. /**
  277. * @section
  278. * BLASTp: Search protein database using a protein query.
  279. * ----------------------------------------------------------------------------
  280. */
  281. /**
  282. * Adds the BLASTp Advanced Options to the passed in form.
  283. *
  284. * This form function is meant to be called within another form definition.
  285. *
  286. * @param $form
  287. * The form the advanced options should be added to. This form already
  288. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  289. * @param $formstate
  290. * The current state fo the form passed in as $form.
  291. */
  292. function blast_ui_blastp_advanced_options_form(&$form, $form_state) {
  293. //General parameters
  294. $form['ALG']['GParam'] = array(
  295. '#type' => 'fieldset',
  296. '#title' => t('General parameters'),
  297. '#collapsible' => FALSE,
  298. );
  299. $form['ALG']['GParam']['maxTarget'] = array(
  300. '#type' => 'select',
  301. '#title' => t('Max target sequences:'),
  302. '#options' => array(
  303. 0 => t('10'),
  304. 1 => t('50'),
  305. 2 => t('100'),
  306. 3 => t('250'),
  307. 4 => t('500'),
  308. 5 => t('1000'),
  309. 6 => t('5000'),
  310. 7 => t('10000'),
  311. 8 => t('20000'),
  312. ),
  313. '#default_value' => 2,
  314. '#description' => t('Select the maximum number of aligned sequences to display'),
  315. );
  316. $form['ALG']['GParam']['shortQueries'] = array(
  317. '#type' => 'checkbox',
  318. '#title' => t('Automatically adjust parameters for short input sequences'),
  319. '#default_value' => TRUE,
  320. );
  321. $form['ALG']['GParam']['eVal'] = array(
  322. '#type' => 'textfield',
  323. '#title' => t('e-value(Expect threshold)'),
  324. '#default_value' => 10,
  325. '#size' => 12,
  326. '#maxlength' => 20,
  327. '#description' => t('Expected number of chance matches in a random model.'),
  328. );
  329. $form['ALG']['GParam']['wordSize'] = array(
  330. '#type' => 'select',
  331. '#title' => t('Word size:'),
  332. '#options' => array(
  333. 0 => t('2'),
  334. 1 => t('3'),
  335. ),
  336. '#default_value' => 1,
  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' => 0,
  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. $options_first = _ajax_example_get_first_dropdown_options();
  354. $selected = isset($form_state['values']['MATRIX'] ) ? $form_state['values']['MATRIX'] : key($options_first);
  355. $form['ALG']['SParam']['MATRIX'] = array(
  356. '#type' => 'select',
  357. '#title' => 'Matrix',
  358. '#options' => $options_first,
  359. '#default_value' => $selected,
  360. '#description' => t('Assigns a score for aligning pairs of residues, and determines overall alignment score..'),
  361. '#ajax' => array(
  362. 'callback' => 'ajax_example_dependent_dropdown_callback',
  363. 'wrapper' => 'dropdown-second-replace',
  364. ),
  365. );
  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' => _ajax_example_get_second_dropdown_options($selected),
  372. '#default_value' => 2,
  373. '#description' => t('Cost to create and extend a gap in an alignment.'),
  374. );
  375. $form['ALG']['SParam']['M&MScores'] = array(
  376. '#type' => 'select',
  377. '#title' => t('Match/Mismatch Scores:'),
  378. '#options' => array(
  379. 0 => t('No adjustment'),
  380. 1 => t('Composition-based statistics'),
  381. 2 => t('Conditional compositional score matrix adjustment'),
  382. 3 => t('Universal composition score matrix adjustment '),
  383. ),
  384. '#default_value' => 2,
  385. '#description' => t('Matrix adjustment method to compensate for amino acid composition of sequences'),
  386. );
  387. }
  388. /**
  389. * Validate the advanced options provided by the BLASTn form above.
  390. *
  391. * @see blast_ui_blastp_advanced_options_form().
  392. */
  393. function blast_ui_blastp_advanced_options_form_validate($form, $form_state) { }
  394. /**
  395. * Processed the advanced options provided by the BLASTp form above.
  396. *
  397. * @see blast_ui_blastp_advanced_options_form().
  398. */
  399. function blast_ui_blastp_advanced_options_form_submit($form, $form_state) {
  400. $eVal = $form_state['values']['eVal'];
  401. $trgtKey = $form_state['values']['maxTarget'];
  402. $numAlign = $form['ALG']['GParam']['maxTarget']['#options'][$trgtKey];
  403. $wsKey = $form_state['values']['wordSize'];
  404. $wordSize = $form['ALG']['GParam']['wordSize']['#options'][$wsKey];
  405. // Expand Gap Cost key into open and extend penalties
  406. $gapKey = $form_state['values']['MATRIX'];
  407. switch ($gapKey) {
  408. case 0:
  409. $matrix ="PAM30";
  410. $gapKey = $form_state['values']['gapCost'];
  411. switch ($gapKey) {
  412. case 0:
  413. $gapOpen = 7;
  414. $gapExtend = 2;
  415. break;
  416. case 1:
  417. $gapOpen = 6;
  418. $gapExtend = 2;
  419. break;
  420. case 2:
  421. $gapOpen = 5;
  422. $gapExtend = 2;
  423. break;
  424. case 3:
  425. $gapOpen = 10;
  426. $gapExtend = 1;
  427. break;
  428. case 4:
  429. $gapOpen = 9;
  430. $gapExtend = 1;
  431. break;
  432. case 5:
  433. $gapOpen = 8;
  434. $gapExtend = 1;
  435. break;
  436. }
  437. break;
  438. case 1:
  439. $matrix ="PAM70";
  440. $gapKey = $form_state['values']['gapCost'];
  441. switch ($gapKey) {
  442. case 0:
  443. $gapOpen = 8;
  444. $gapExtend = 2;
  445. break;
  446. case 1:
  447. $gapOpen = 7;
  448. $gapExtend = 2;
  449. break;
  450. case 2:
  451. $gapOpen = 6;
  452. $gapExtend = 2;
  453. break;
  454. case 3:
  455. $gapOpen = 11;
  456. $gapExtend = 1;
  457. break;
  458. case 4:
  459. $gapOpen = 10;
  460. $gapExtend = 1;
  461. break;
  462. case 5:
  463. $gapOpen = 9;
  464. $gapExtend = 1;
  465. break;
  466. }
  467. break;
  468. case 2:
  469. $matrix ="PAM250";
  470. $gapKey = $form_state['values']['gapCost'];
  471. switch ($gapKey) {
  472. case 0:
  473. $gapOpen = 15;
  474. $gapExtend = 3;
  475. break;
  476. case 1:
  477. $gapOpen = 14;
  478. $gapExtend = 3;
  479. break;
  480. case 2:
  481. $gapOpen = 13;
  482. $gapExtend = 3;
  483. break;
  484. case 3:
  485. $gapOpen = 12;
  486. $gapExtend = 3;
  487. break;
  488. case 4:
  489. $gapOpen = 11;
  490. $gapExtend = 3;
  491. break;
  492. case 5:
  493. $gapOpen = 17;
  494. $gapExtend = 2;
  495. break;
  496. case 6:
  497. $gapOpen = 16;
  498. $gapExtend = 2;
  499. break;
  500. case 7:
  501. $gapOpen = 15;
  502. $gapExtend = 2;
  503. break;
  504. case 8:
  505. $gapOpen = 14;
  506. $gapExtend = 2;
  507. break;
  508. case 9:
  509. $gapOpen = 13;
  510. $gapExtend = 2;
  511. break;
  512. case 10:
  513. $gapOpen = 21;
  514. $gapExtend = 1;
  515. break;
  516. case 11:
  517. $gapOpen = 20;
  518. $gapExtend = 1;
  519. break;
  520. case 12:
  521. $gapOpen = 19;
  522. $gapExtend = 1;
  523. break;
  524. case 13:
  525. $gapOpen = 18;
  526. $gapExtend = 1;
  527. break;
  528. case 14:
  529. $gapOpen = 17;
  530. $gapExtend = 1;
  531. break;
  532. }
  533. break;
  534. case 3:
  535. $matrix ="BLOSUM80";
  536. $gapKey = $form_state['values']['gapCost'];
  537. switch ($gapKey) {
  538. case 0:
  539. $gapOpen = 8;
  540. $gapExtend = 2;
  541. break;
  542. case 1:
  543. $gapOpen = 7;
  544. $gapExtend = 2;
  545. break;
  546. case 2:
  547. $gapOpen = 6;
  548. $gapExtend = 2;
  549. break;
  550. case 3:
  551. $gapOpen = 11;
  552. $gapExtend = 1;
  553. break;
  554. case 4:
  555. $gapOpen = 10;
  556. $gapExtend = 1;
  557. break;
  558. case 5:
  559. $gapOpen = 9;
  560. $gapExtend = 1;
  561. break;
  562. }
  563. break;
  564. case 4:
  565. $matrix ="BLOSUM62";
  566. $gapKey = $form_state['values']['gapCost'];
  567. switch ($gapKey) {
  568. case 0:
  569. $gapOpen = 11;
  570. $gapExtend = 2;
  571. break;
  572. case 1:
  573. $gapOpen = 10;
  574. $gapExtend = 2;
  575. break;
  576. case 2:
  577. $gapOpen = 9;
  578. $gapExtend = 2;
  579. break;
  580. case 3:
  581. $gapOpen = 8;
  582. $gapExtend = 2;
  583. break;
  584. case 4:
  585. $gapOpen = 7;
  586. $gapExtend = 2;
  587. break;
  588. case 5:
  589. $gapOpen = 6;
  590. $gapExtend = 2;
  591. break;
  592. case 6:
  593. $gapOpen = 13;
  594. $gapExtend = 1;
  595. break;
  596. case 7:
  597. $gapOpen = 12;
  598. $gapExtend = 1;
  599. break;
  600. case 8:
  601. $gapOpen = 11;
  602. $gapExtend = 1;
  603. break;
  604. case 9:
  605. $gapOpen = 10;
  606. $gapExtend = 1;
  607. break;
  608. case 10:
  609. $gapOpen = 9;
  610. $gapExtend = 1;
  611. break;
  612. }
  613. break;
  614. case 5:
  615. $matrix ="BLOSUM45";
  616. $gapKey = $form_state['values']['gapCost'];
  617. switch ($gapKey) {
  618. case 0:
  619. $gapOpen = 13;
  620. $gapExtend = 3;
  621. break;
  622. case 1:
  623. $gapOpen = 12;
  624. $gapExtend = 3;
  625. break;
  626. case 2:
  627. $gapOpen = 11;
  628. $gapExtend = 3;
  629. break;
  630. case 3:
  631. $gapOpen = 10;
  632. $gapExtend = 3;
  633. break;
  634. case 4:
  635. $gapOpen = 15;
  636. $gapExtend = 2;
  637. break;
  638. case 5:
  639. $gapOpen = 14;
  640. $gapExtend = 2;
  641. break;
  642. case 6:
  643. $gapOpen = 13;
  644. $gapExtend = 2;
  645. break;
  646. case 7:
  647. $gapOpen = 12;
  648. $gapExtend = 2;
  649. break;
  650. case 8:
  651. $gapOpen = 19;
  652. $gapExtend = 1;
  653. break;
  654. case 9:
  655. $gapOpen = 18;
  656. $gapExtend = 1;
  657. break;
  658. case 10:
  659. $gapOpen = 17;
  660. $gapExtend = 1;
  661. break;
  662. case 11:
  663. $gapOpen = 16;
  664. $gapExtend = 1;
  665. break;
  666. }
  667. break;
  668. case 6:
  669. $matrix ="BLOSUM50";
  670. $gapKey = $form_state['values']['gapCost'];
  671. switch ($gapKey) {
  672. case 0:
  673. $gapOpen = 13;
  674. $gapExtend = 3;
  675. break;
  676. case 1:
  677. $gapOpen = 12;
  678. $gapExtend = 3;
  679. break;
  680. case 2:
  681. $gapOpen = 11;
  682. $gapExtend = 3;
  683. break;
  684. case 3:
  685. $gapOpen = 10;
  686. $gapExtend = 3;
  687. break;
  688. case 4:
  689. $gapOpen = 9;
  690. $gapExtend = 3;
  691. break;
  692. case 5:
  693. $gapOpen = 16;
  694. $gapExtend = 2;
  695. break;
  696. case 6:
  697. $gapOpen = 15;
  698. $gapExtend = 2;
  699. break;
  700. case 7:
  701. $gapOpen = 14;
  702. $gapExtend = 2;
  703. break;
  704. case 8:
  705. $gapOpen = 13;
  706. $gapExtend = 2;
  707. break;
  708. case 9:
  709. $gapOpen = 12;
  710. $gapExtend = 2;
  711. break;
  712. case 10:
  713. $gapOpen = 19;
  714. $gapExtend = 1;
  715. break;
  716. case 11:
  717. $gapOpen = 18;
  718. $gapExtend = 1;
  719. break;
  720. case 12:
  721. $gapOpen = 17;
  722. $gapExtend = 1;
  723. break;
  724. case 13:
  725. $gapOpen = 16;
  726. $gapExtend = 1;
  727. break;
  728. case 14:
  729. $gapOpen = 15;
  730. $gapExtend = 1;
  731. break;
  732. }
  733. break;
  734. case 7:
  735. $matrix ="BLOSUM90";
  736. $gapKey = $form_state['values']['gapCost'];
  737. switch ($gapKey) {
  738. case 0:
  739. $gapOpen = 9;
  740. $gapExtend = 2;
  741. break;
  742. case 1:
  743. $gapOpen = 8;
  744. $gapExtend = 2;
  745. break;
  746. case 2:
  747. $gapOpen = 7;
  748. $gapExtend = 2;
  749. break;
  750. case 3:
  751. $gapOpen = 6;
  752. $gapExtend = 2;
  753. break;
  754. case 4:
  755. $gapOpen = 11;
  756. $gapExtend = 1;
  757. break;
  758. case 5:
  759. $gapOpen = 10;
  760. $gapExtend = 1;
  761. break;
  762. case 6:
  763. $gapOpen = 9;
  764. $gapExtend = 1;
  765. break;
  766. }
  767. break;
  768. }
  769. return array(
  770. 'evalue' => $eVal,
  771. 'word_size' => $wordSize,
  772. 'gapopen' => $gapOpen,
  773. 'gapextend' => $gapExtend,
  774. 'matrix' => $matrix
  775. );
  776. }
  777. /**
  778. * Fill the first dropdown list with appropriate options
  779. *
  780. * @return
  781. * An array consisting of matrices name for the first dropdown list
  782. */
  783. function _ajax_example_get_first_dropdown_options() {
  784. return drupal_map_assoc(array(
  785. t('PAM30'),
  786. t('PAM70'),
  787. t('PAM250'),
  788. t('BLOSUM80'),
  789. t('BLOSUM62'),
  790. t('BLOSUM45'),
  791. t('BLOSUM50'),
  792. t('BLOSUM90'),
  793. ));
  794. }
  795. /**
  796. * Fill the second dropdown list with appropriate options
  797. *
  798. * @return
  799. * An array containing open and extension gap values for the chosen matrix (to fill the second dropdown list)
  800. */
  801. function _ajax_example_get_second_dropdown_options($key = '') {
  802. $options = array(
  803. t('PAM30') => drupal_map_assoc(array(
  804. t('Existence: 7 Extension: 2'),
  805. t('Existence: 6 Extension: 2'),
  806. t('Existence: 5 Extension: 2'),
  807. t('Existence: 10 Extension: 1'),
  808. t('Existence: 9 Extension: 1'),
  809. t('Existence: 8 Extension: 1'),
  810. )),
  811. t('PAM70') => drupal_map_assoc(array(
  812. t('Existence: 8 Extension: 2'),
  813. t('Existence: 7 Extension: 2'),
  814. t('Existence: 6 Extension: 2'),
  815. t('Existence: 11 Extension: 1'),
  816. t('Existence: 10 Extension: 1'),
  817. t('Existence: 9 Extension: 1'),
  818. )),
  819. t('PAM250') => drupal_map_assoc(array(
  820. t('Existence: 15 Extension: 3'),
  821. t('Existence: 14 Extension: 3'),
  822. t('Existence: 13 Extension: 3'),
  823. t('Existence: 12 Extension: 3'),
  824. t('Existence: 11 Extension: 3'),
  825. t('Existence: 17 Extension: 2'),
  826. t('Existence: 16 Extension: 2'),
  827. t('Existence: 15 Extension: 2'),
  828. t('Existence: 14 Extension: 2'),
  829. t('Existence: 13 Extension: 2'),
  830. t('Existence: 21 Extension: 1'),
  831. t('Existence: 20 Extension: 1'),
  832. t('Existence: 19 Extension: 1'),
  833. t('Existence: 18 Extension: 1'),
  834. t('Existence: 17 Extension: 1'),
  835. )),
  836. t('BLOSUM80') => drupal_map_assoc(array(
  837. t('Existence: 8 Extension: 2'),
  838. t('Existence: 7 Extension: 2'),
  839. t('Existence: 6 Extension: 2'),
  840. t('Existence: 11 Extension: 1'),
  841. t('Existence: 10 Extension: 1'),
  842. t('Existence: 9 Extension: 1'),
  843. )),
  844. t('BLOSUM62') => drupal_map_assoc(array(
  845. t('Existence: 11 Extension: 2'),
  846. t('Existence: 10 Extension: 2'),
  847. t('Existence: 9 Extension: 2'),
  848. t('Existence: 8 Extension: 2'),
  849. t('Existence: 7 Extension: 2'),
  850. t('Existence: 6 Extension: 2'),
  851. t('Existence: 13 Extension: 1'),
  852. t('Existence: 12 Extension: 1'),
  853. t('Existence: 11 Extension: 1'),
  854. t('Existence: 10 Extension: 1'),
  855. t('Existence: 9 Extension: 1'),
  856. )),
  857. t('BLOSUM45') => drupal_map_assoc(array(
  858. t('Existence: 13 Extension: 3'),
  859. t('Existence: 12 Extension: 3'),
  860. t('Existence: 11 Extension: 3'),
  861. t('Existence: 10 Extension: 3'),
  862. t('Existence: 15 Extension: 2'),
  863. t('Existence: 14 Extension: 2'),
  864. t('Existence: 13 Extension: 2'),
  865. t('Existence: 12 Extension: 2'),
  866. t('Existence: 19 Extension: 1'),
  867. t('Existence: 18 Extension: 1'),
  868. t('Existence: 17 Extension: 1'),
  869. t('Existence: 16 Extension: 1'),
  870. )),
  871. t('BLOSUM50') => drupal_map_assoc(array(
  872. t('Existence: 13 Extension: 3'),
  873. t('Existence: 12 Extension: 3'),
  874. t('Existence: 11 Extension: 3'),
  875. t('Existence: 10 Extension: 3'),
  876. t('Existence: 9 Extension: 3'),
  877. t('Existence: 16 Extension: 2'),
  878. t('Existence: 15 Extension: 2'),
  879. t('Existence: 14 Extension: 2'),
  880. t('Existence: 13 Extension: 2'),
  881. t('Existence: 12 Extension: 2'),
  882. t('Existence: 19 Extension: 1'),
  883. t('Existence: 18 Extension: 1'),
  884. t('Existence: 17 Extension: 1'),
  885. t('Existence: 16 Extension: 1'),
  886. t('Existence: 15 Extension: 1'),
  887. )),
  888. t('BLOSUM90') => drupal_map_assoc(array(
  889. t('Existence: 9 Extension: 2'),
  890. t('Existence: 8 Extension: 2'),
  891. t('Existence: 7 Extension: 2'),
  892. t('Existence: 6 Extension: 2'),
  893. t('Existence: 11 Extension: 1'),
  894. t('Existence: 10 Extension: 1'),
  895. t('Existence: 9 Extension: 1'),
  896. )),
  897. );
  898. if (isset($options[$key])) {
  899. return $options[$key];
  900. } else {
  901. return array();
  902. }
  903. }
  904. /**
  905. * Respond to Ajax dropdown call
  906. */
  907. function ajax_example_dependent_dropdown_callback($form, $form_state) {
  908. return $form['ALG']['SParam']['gapCost'];
  909. }
  910. /**
  911. * @section
  912. * tBLASTn: Search translated nucleotide database using a protein query.
  913. * ----------------------------------------------------------------------------
  914. */
  915. /**
  916. * Adds the tBLASTn Advanced Options to the passed in form.
  917. *
  918. * This form function is meant to be called within another form definition.
  919. *
  920. * @param $form
  921. * The form the advanced options should be added to. This form already
  922. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  923. * @param $formstate
  924. * The current state fo the form passed in as $form.
  925. */
  926. function blast_ui_tblastn_advanced_options_form(&$form, $form_state) {
  927. $form['ALG']['GParam'] = array(
  928. '#type' => 'fieldset',
  929. '#title' => t('General parameters'),
  930. '#collapsible' => FALSE,
  931. );
  932. $form['ALG']['GParam']['maxTarget'] = array(
  933. '#type' => 'select',
  934. '#title' => t('Max target sequences:'),
  935. '#options' => array(
  936. 0 => t('10'),
  937. 1 => t('50'),
  938. 2 => t('100'),
  939. 3 => t('250'),
  940. 4 => t('500'),
  941. 5 => t('1000'),
  942. 6 => t('5000'),
  943. 7 => t('10000'),
  944. 8 => t('20000'),
  945. ),
  946. '#default_value' => 2,
  947. '#description' => t('Select the maximum number of aligned sequences to display'),
  948. );
  949. $form['ALG']['GParam']['eVal'] = array(
  950. '#type' => 'textfield',
  951. '#title' => t('e-Value (Expected Threshold)'),
  952. '#default_value' => 10,
  953. '#size' => 12,
  954. '#maxlength' => 20,
  955. '#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>'),
  956. );
  957. }
  958. /**
  959. * Validate the advanced options provided by the BLASTn form above.
  960. *
  961. * @see blast_ui_tblastn_advanced_options_form().
  962. */
  963. function blast_ui_tblastn_advanced_options_form_validate($form, $form_state) { }
  964. /**
  965. * Processed the advanced options provided by the yBLASTn form above.
  966. *
  967. * @see blast_ui_tblastn_advanced_options_form().
  968. */
  969. function blast_ui_tblastn_advanced_options_form_submit($form, $form_state) {
  970. $eVal = $form_state['values']['eVal'];
  971. $trgtKey = $form_state['values']['maxTarget'];
  972. $numAlign = $form['ALG']['GParam']['maxTarget']['#options'][$trgtKey];
  973. return array(
  974. 'evalue' => $eVal,
  975. );
  976. }