blast_ui.form_advanced_options.inc 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  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. /**
  227. * Validate the advanced options provided by the BLASTn form above.
  228. *
  229. * @see blast_ui_blastx_advanced_options_form().
  230. */
  231. function blast_ui_blastx_advanced_options_form_validate($form, $form_state) { }
  232. /**
  233. * Processed the advanced options provided by the BLASTx form above.
  234. *
  235. * @see blast_ui_blastx_advanced_options_form().
  236. */
  237. function blast_ui_blastx_advanced_options_form_submit($form, $form_state) { }
  238. /**
  239. * @section
  240. * BLASTp: Search protein database using a protein query.
  241. * ----------------------------------------------------------------------------
  242. */
  243. /**
  244. * Adds the BLASTp Advanced Options to the passed in form.
  245. *
  246. * This form function is meant to be called within another form definition.
  247. *
  248. * @param $form
  249. * The form the advanced options should be added to. This form already
  250. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  251. * @param $formstate
  252. * The current state fo the form passed in as $form.
  253. */
  254. function blast_ui_blastp_advanced_options_form(&$form, $form_state) {
  255. //General parameters
  256. $form['ALG']['GParam'] = array(
  257. '#type' => 'fieldset',
  258. '#title' => t('General parameters'),
  259. '#collapsible' => FALSE,
  260. );
  261. $form['ALG']['GParam']['maxTarget'] = array(
  262. '#type' => 'select',
  263. '#title' => t('Max target sequences:'),
  264. '#options' => array(
  265. 0 => t('10'),
  266. 1 => t('50'),
  267. 2 => t('100'),
  268. 3 => t('250'),
  269. 4 => t('500'),
  270. 5 => t('1000'),
  271. 6 => t('5000'),
  272. 7 => t('10000'),
  273. 8 => t('20000'),
  274. ),
  275. '#default_value' => 2,
  276. '#description' => t('Select the maximum number of aligned sequences to display'),
  277. );
  278. $form['ALG']['GParam']['shortQueries'] = array(
  279. '#type' => 'checkbox',
  280. '#title' => t('Automatically adjust parameters for short input sequences'),
  281. '#default_value' => TRUE,
  282. );
  283. $form['ALG']['GParam']['eVal'] = array(
  284. '#type' => 'textfield',
  285. '#title' => t('e-value(Expect threshold)'),
  286. '#default_value' => 10,
  287. '#size' => 12,
  288. '#maxlength' => 20,
  289. '#description' => t('Expected number of chance matches in a random model.'),
  290. );
  291. $form['ALG']['GParam']['wordSize'] = array(
  292. '#type' => 'select',
  293. '#title' => t('Word size:'),
  294. '#options' => array(
  295. 0 => t('2'),
  296. 1 => t('3'),
  297. ),
  298. '#default_value' => 1,
  299. '#description' => t('The length of the seed that initiates an alignment'),
  300. );
  301. $form['ALG']['GParam']['qRange'] = array(
  302. '#type' => 'textfield',
  303. '#title' => t('Max matches in a query range'),
  304. '#default_value' => 0,
  305. '#size' => 12,
  306. '#maxlength' => 20,
  307. '#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.'),
  308. );
  309. // Scoring parameters
  310. $form['ALG']['SParam'] = array(
  311. '#type' => 'fieldset',
  312. '#title' => t('Scoring parameters'),
  313. '#collapsible' => FALSE,
  314. );
  315. $options_first = _ajax_example_get_first_dropdown_options();
  316. $selected = isset($form_state['values']['MATRIX'] ) ? $form_state['values']['MATRIX'] : key($options_first);
  317. $form['ALG']['SParam']['MATRIX'] = array(
  318. '#type' => 'select',
  319. '#title' => 'Matrix',
  320. '#options' => $options_first,
  321. '#default_value' => $selected,
  322. '#description' => t('Assigns a score for aligning pairs of residues, and determines overall alignment score..'),
  323. '#ajax' => array(
  324. 'callback' => 'ajax_example_dependent_dropdown_callback',
  325. 'wrapper' => 'dropdown-second-replace',
  326. ),
  327. );
  328. $form['ALG']['SParam']['gapCost'] = array(
  329. '#type' => 'select',
  330. '#title' => t('Gap Costs:'),
  331. '#prefix' => '<div id="dropdown-second-replace">',
  332. '#suffix' => '</div>',
  333. '#options' => _ajax_example_get_second_dropdown_options($selected),
  334. '#default_value' => 2,
  335. '#description' => t('Cost to create and extend a gap in an alignment.'),
  336. );
  337. $form['ALG']['SParam']['M&MScores'] = array(
  338. '#type' => 'select',
  339. '#title' => t('Match/Mismatch Scores:'),
  340. '#options' => array(
  341. 0 => t('No adjustment'),
  342. 1 => t('Composition-based statistics'),
  343. 2 => t('Conditional compositional score matrix adjustment'),
  344. 3 => t('Universal composition score matrix adjustment '),
  345. ),
  346. '#default_value' => 2,
  347. '#description' => t('Matrix adjustment method to compensate for amino acid composition of sequences'),
  348. );
  349. }
  350. /**
  351. * Validate the advanced options provided by the BLASTn form above.
  352. *
  353. * @see blast_ui_blastp_advanced_options_form().
  354. */
  355. function blast_ui_blastp_advanced_options_form_validate($form, $form_state) { }
  356. /**
  357. * Processed the advanced options provided by the BLASTp form above.
  358. *
  359. * @see blast_ui_blastp_advanced_options_form().
  360. */
  361. function blast_ui_blastp_advanced_options_form_submit($form, $form_state) {
  362. $eVal = $form_state['values']['eVal'];
  363. $trgtKey = $form_state['values']['maxTarget'];
  364. $numAlign = $form['ALG']['GParam']['maxTarget']['#options'][$trgtKey];
  365. $wsKey = $form_state['values']['wordSize'];
  366. $wordSize = $form['ALG']['GParam']['wordSize']['#options'][$wsKey];
  367. // Expand Gap Cost key into open and extend penalties
  368. $gapKey = $form_state['values']['MATRIX'];
  369. switch ($gapKey) {
  370. case 0:
  371. $matrix ="PAM30";
  372. $gapKey = $form_state['values']['gapCost'];
  373. switch ($gapKey) {
  374. case 0:
  375. $gapOpen = 7;
  376. $gapExtend = 2;
  377. break;
  378. case 1:
  379. $gapOpen = 6;
  380. $gapExtend = 2;
  381. break;
  382. case 2:
  383. $gapOpen = 5;
  384. $gapExtend = 2;
  385. break;
  386. case 3:
  387. $gapOpen = 10;
  388. $gapExtend = 1;
  389. break;
  390. case 4:
  391. $gapOpen = 9;
  392. $gapExtend = 1;
  393. break;
  394. case 5:
  395. $gapOpen = 8;
  396. $gapExtend = 1;
  397. break;
  398. }
  399. break;
  400. case 1:
  401. $matrix ="PAM70";
  402. $gapKey = $form_state['values']['gapCost'];
  403. switch ($gapKey) {
  404. case 0:
  405. $gapOpen = 8;
  406. $gapExtend = 2;
  407. break;
  408. case 1:
  409. $gapOpen = 7;
  410. $gapExtend = 2;
  411. break;
  412. case 2:
  413. $gapOpen = 6;
  414. $gapExtend = 2;
  415. break;
  416. case 3:
  417. $gapOpen = 11;
  418. $gapExtend = 1;
  419. break;
  420. case 4:
  421. $gapOpen = 10;
  422. $gapExtend = 1;
  423. break;
  424. case 5:
  425. $gapOpen = 9;
  426. $gapExtend = 1;
  427. break;
  428. }
  429. break;
  430. case 2:
  431. $matrix ="PAM250";
  432. $gapKey = $form_state['values']['gapCost'];
  433. switch ($gapKey) {
  434. case 0:
  435. $gapOpen = 15;
  436. $gapExtend = 3;
  437. break;
  438. case 1:
  439. $gapOpen = 14;
  440. $gapExtend = 3;
  441. break;
  442. case 2:
  443. $gapOpen = 13;
  444. $gapExtend = 3;
  445. break;
  446. case 3:
  447. $gapOpen = 12;
  448. $gapExtend = 3;
  449. break;
  450. case 4:
  451. $gapOpen = 11;
  452. $gapExtend = 3;
  453. break;
  454. case 5:
  455. $gapOpen = 17;
  456. $gapExtend = 2;
  457. break;
  458. case 6:
  459. $gapOpen = 16;
  460. $gapExtend = 2;
  461. break;
  462. case 7:
  463. $gapOpen = 15;
  464. $gapExtend = 2;
  465. break;
  466. case 8:
  467. $gapOpen = 14;
  468. $gapExtend = 2;
  469. break;
  470. case 9:
  471. $gapOpen = 13;
  472. $gapExtend = 2;
  473. break;
  474. case 10:
  475. $gapOpen = 21;
  476. $gapExtend = 1;
  477. break;
  478. case 11:
  479. $gapOpen = 20;
  480. $gapExtend = 1;
  481. break;
  482. case 12:
  483. $gapOpen = 19;
  484. $gapExtend = 1;
  485. break;
  486. case 13:
  487. $gapOpen = 18;
  488. $gapExtend = 1;
  489. break;
  490. case 14:
  491. $gapOpen = 17;
  492. $gapExtend = 1;
  493. break;
  494. }
  495. break;
  496. case 3:
  497. $matrix ="BLOSUM80";
  498. $gapKey = $form_state['values']['gapCost'];
  499. switch ($gapKey) {
  500. case 0:
  501. $gapOpen = 8;
  502. $gapExtend = 2;
  503. break;
  504. case 1:
  505. $gapOpen = 7;
  506. $gapExtend = 2;
  507. break;
  508. case 2:
  509. $gapOpen = 6;
  510. $gapExtend = 2;
  511. break;
  512. case 3:
  513. $gapOpen = 11;
  514. $gapExtend = 1;
  515. break;
  516. case 4:
  517. $gapOpen = 10;
  518. $gapExtend = 1;
  519. break;
  520. case 5:
  521. $gapOpen = 9;
  522. $gapExtend = 1;
  523. break;
  524. }
  525. break;
  526. case 4:
  527. $matrix ="BLOSUM62";
  528. $gapKey = $form_state['values']['gapCost'];
  529. switch ($gapKey) {
  530. case 0:
  531. $gapOpen = 11;
  532. $gapExtend = 2;
  533. break;
  534. case 1:
  535. $gapOpen = 10;
  536. $gapExtend = 2;
  537. break;
  538. case 2:
  539. $gapOpen = 9;
  540. $gapExtend = 2;
  541. break;
  542. case 3:
  543. $gapOpen = 8;
  544. $gapExtend = 2;
  545. break;
  546. case 4:
  547. $gapOpen = 7;
  548. $gapExtend = 2;
  549. break;
  550. case 5:
  551. $gapOpen = 6;
  552. $gapExtend = 2;
  553. break;
  554. case 6:
  555. $gapOpen = 13;
  556. $gapExtend = 1;
  557. break;
  558. case 7:
  559. $gapOpen = 12;
  560. $gapExtend = 1;
  561. break;
  562. case 8:
  563. $gapOpen = 11;
  564. $gapExtend = 1;
  565. break;
  566. case 9:
  567. $gapOpen = 10;
  568. $gapExtend = 1;
  569. break;
  570. case 10:
  571. $gapOpen = 9;
  572. $gapExtend = 1;
  573. break;
  574. }
  575. break;
  576. case 5:
  577. $matrix ="BLOSUM45";
  578. $gapKey = $form_state['values']['gapCost'];
  579. switch ($gapKey) {
  580. case 0:
  581. $gapOpen = 13;
  582. $gapExtend = 3;
  583. break;
  584. case 1:
  585. $gapOpen = 12;
  586. $gapExtend = 3;
  587. break;
  588. case 2:
  589. $gapOpen = 11;
  590. $gapExtend = 3;
  591. break;
  592. case 3:
  593. $gapOpen = 10;
  594. $gapExtend = 3;
  595. break;
  596. case 4:
  597. $gapOpen = 15;
  598. $gapExtend = 2;
  599. break;
  600. case 5:
  601. $gapOpen = 14;
  602. $gapExtend = 2;
  603. break;
  604. case 6:
  605. $gapOpen = 13;
  606. $gapExtend = 2;
  607. break;
  608. case 7:
  609. $gapOpen = 12;
  610. $gapExtend = 2;
  611. break;
  612. case 8:
  613. $gapOpen = 19;
  614. $gapExtend = 1;
  615. break;
  616. case 9:
  617. $gapOpen = 18;
  618. $gapExtend = 1;
  619. break;
  620. case 10:
  621. $gapOpen = 17;
  622. $gapExtend = 1;
  623. break;
  624. case 11:
  625. $gapOpen = 16;
  626. $gapExtend = 1;
  627. break;
  628. }
  629. break;
  630. case 6:
  631. $matrix ="BLOSUM50";
  632. $gapKey = $form_state['values']['gapCost'];
  633. switch ($gapKey) {
  634. case 0:
  635. $gapOpen = 13;
  636. $gapExtend = 3;
  637. break;
  638. case 1:
  639. $gapOpen = 12;
  640. $gapExtend = 3;
  641. break;
  642. case 2:
  643. $gapOpen = 11;
  644. $gapExtend = 3;
  645. break;
  646. case 3:
  647. $gapOpen = 10;
  648. $gapExtend = 3;
  649. break;
  650. case 4:
  651. $gapOpen = 9;
  652. $gapExtend = 3;
  653. break;
  654. case 5:
  655. $gapOpen = 16;
  656. $gapExtend = 2;
  657. break;
  658. case 6:
  659. $gapOpen = 15;
  660. $gapExtend = 2;
  661. break;
  662. case 7:
  663. $gapOpen = 14;
  664. $gapExtend = 2;
  665. break;
  666. case 8:
  667. $gapOpen = 13;
  668. $gapExtend = 2;
  669. break;
  670. case 9:
  671. $gapOpen = 12;
  672. $gapExtend = 2;
  673. break;
  674. case 10:
  675. $gapOpen = 19;
  676. $gapExtend = 1;
  677. break;
  678. case 11:
  679. $gapOpen = 18;
  680. $gapExtend = 1;
  681. break;
  682. case 12:
  683. $gapOpen = 17;
  684. $gapExtend = 1;
  685. break;
  686. case 13:
  687. $gapOpen = 16;
  688. $gapExtend = 1;
  689. break;
  690. case 14:
  691. $gapOpen = 15;
  692. $gapExtend = 1;
  693. break;
  694. }
  695. break;
  696. case 7:
  697. $matrix ="BLOSUM90";
  698. $gapKey = $form_state['values']['gapCost'];
  699. switch ($gapKey) {
  700. case 0:
  701. $gapOpen = 9;
  702. $gapExtend = 2;
  703. break;
  704. case 1:
  705. $gapOpen = 8;
  706. $gapExtend = 2;
  707. break;
  708. case 2:
  709. $gapOpen = 7;
  710. $gapExtend = 2;
  711. break;
  712. case 3:
  713. $gapOpen = 6;
  714. $gapExtend = 2;
  715. break;
  716. case 4:
  717. $gapOpen = 11;
  718. $gapExtend = 1;
  719. break;
  720. case 5:
  721. $gapOpen = 10;
  722. $gapExtend = 1;
  723. break;
  724. case 6:
  725. $gapOpen = 9;
  726. $gapExtend = 1;
  727. break;
  728. }
  729. break;
  730. }
  731. return array(
  732. 'evalue' => $eVal,
  733. 'word_size' => $wordSize,
  734. 'gapopen' => $gapOpen,
  735. 'gapextend' => $gapExtend,
  736. 'matrix' => $matrix
  737. );
  738. }
  739. /**
  740. * Fill the first dropdown list with appropriate options
  741. *
  742. * @return
  743. * An array consisting of matrices name for the first dropdown list
  744. */
  745. function _ajax_example_get_first_dropdown_options() {
  746. return drupal_map_assoc(array(
  747. t('PAM30'),
  748. t('PAM70'),
  749. t('PAM250'),
  750. t('BLOSUM80'),
  751. t('BLOSUM62'),
  752. t('BLOSUM45'),
  753. t('BLOSUM50'),
  754. t('BLOSUM90'),
  755. ));
  756. }
  757. /**
  758. * Fill the second dropdown list with appropriate options
  759. *
  760. * @return
  761. * An array containing open and extension gap values for the chosen matrix (to fill the second dropdown list)
  762. */
  763. function _ajax_example_get_second_dropdown_options($key = '') {
  764. $options = array(
  765. t('PAM30') => drupal_map_assoc(array(
  766. t('Existence: 7 Extension: 2'),
  767. t('Existence: 6 Extension: 2'),
  768. t('Existence: 5 Extension: 2'),
  769. t('Existence: 10 Extension: 1'),
  770. t('Existence: 9 Extension: 1'),
  771. t('Existence: 8 Extension: 1'),
  772. )),
  773. t('PAM70') => drupal_map_assoc(array(
  774. t('Existence: 8 Extension: 2'),
  775. t('Existence: 7 Extension: 2'),
  776. t('Existence: 6 Extension: 2'),
  777. t('Existence: 11 Extension: 1'),
  778. t('Existence: 10 Extension: 1'),
  779. t('Existence: 9 Extension: 1'),
  780. )),
  781. t('PAM250') => drupal_map_assoc(array(
  782. t('Existence: 15 Extension: 3'),
  783. t('Existence: 14 Extension: 3'),
  784. t('Existence: 13 Extension: 3'),
  785. t('Existence: 12 Extension: 3'),
  786. t('Existence: 11 Extension: 3'),
  787. t('Existence: 17 Extension: 2'),
  788. t('Existence: 16 Extension: 2'),
  789. t('Existence: 15 Extension: 2'),
  790. t('Existence: 14 Extension: 2'),
  791. t('Existence: 13 Extension: 2'),
  792. t('Existence: 21 Extension: 1'),
  793. t('Existence: 20 Extension: 1'),
  794. t('Existence: 19 Extension: 1'),
  795. t('Existence: 18 Extension: 1'),
  796. t('Existence: 17 Extension: 1'),
  797. )),
  798. t('BLOSUM80') => drupal_map_assoc(array(
  799. t('Existence: 8 Extension: 2'),
  800. t('Existence: 7 Extension: 2'),
  801. t('Existence: 6 Extension: 2'),
  802. t('Existence: 11 Extension: 1'),
  803. t('Existence: 10 Extension: 1'),
  804. t('Existence: 9 Extension: 1'),
  805. )),
  806. t('BLOSUM62') => drupal_map_assoc(array(
  807. t('Existence: 11 Extension: 2'),
  808. t('Existence: 10 Extension: 2'),
  809. t('Existence: 9 Extension: 2'),
  810. t('Existence: 8 Extension: 2'),
  811. t('Existence: 7 Extension: 2'),
  812. t('Existence: 6 Extension: 2'),
  813. t('Existence: 13 Extension: 1'),
  814. t('Existence: 12 Extension: 1'),
  815. t('Existence: 11 Extension: 1'),
  816. t('Existence: 10 Extension: 1'),
  817. t('Existence: 9 Extension: 1'),
  818. )),
  819. t('BLOSUM45') => drupal_map_assoc(array(
  820. t('Existence: 13 Extension: 3'),
  821. t('Existence: 12 Extension: 3'),
  822. t('Existence: 11 Extension: 3'),
  823. t('Existence: 10 Extension: 3'),
  824. t('Existence: 15 Extension: 2'),
  825. t('Existence: 14 Extension: 2'),
  826. t('Existence: 13 Extension: 2'),
  827. t('Existence: 12 Extension: 2'),
  828. t('Existence: 19 Extension: 1'),
  829. t('Existence: 18 Extension: 1'),
  830. t('Existence: 17 Extension: 1'),
  831. t('Existence: 16 Extension: 1'),
  832. )),
  833. t('BLOSUM50') => drupal_map_assoc(array(
  834. t('Existence: 13 Extension: 3'),
  835. t('Existence: 12 Extension: 3'),
  836. t('Existence: 11 Extension: 3'),
  837. t('Existence: 10 Extension: 3'),
  838. t('Existence: 9 Extension: 3'),
  839. t('Existence: 16 Extension: 2'),
  840. t('Existence: 15 Extension: 2'),
  841. t('Existence: 14 Extension: 2'),
  842. t('Existence: 13 Extension: 2'),
  843. t('Existence: 12 Extension: 2'),
  844. t('Existence: 19 Extension: 1'),
  845. t('Existence: 18 Extension: 1'),
  846. t('Existence: 17 Extension: 1'),
  847. t('Existence: 16 Extension: 1'),
  848. t('Existence: 15 Extension: 1'),
  849. )),
  850. t('BLOSUM90') => drupal_map_assoc(array(
  851. t('Existence: 9 Extension: 2'),
  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. );
  860. if (isset($options[$key])) {
  861. return $options[$key];
  862. } else {
  863. return array();
  864. }
  865. }
  866. /**
  867. * Respond to Ajax dropdown call
  868. */
  869. function ajax_example_dependent_dropdown_callback($form, $form_state) {
  870. return $form['ALG']['SParam']['gapCost'];
  871. }
  872. /**
  873. * @section
  874. * tBLASTn: Search translated nucleotide database using a protein query.
  875. * ----------------------------------------------------------------------------
  876. */
  877. /**
  878. * Adds the tBLASTn Advanced Options to the passed in form.
  879. *
  880. * This form function is meant to be called within another form definition.
  881. *
  882. * @param $form
  883. * The form the advanced options should be added to. This form already
  884. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  885. * @param $formstate
  886. * The current state fo the form passed in as $form.
  887. */
  888. function blast_ui_tblastn_advanced_options_form(&$form, $form_state) { }
  889. /**
  890. * Validate the advanced options provided by the BLASTn form above.
  891. *
  892. * @see blast_ui_tblastn_advanced_options_form().
  893. */
  894. function blast_ui_tblastn_advanced_options_form_validate($form, $form_state) { }
  895. /**
  896. * Processed the advanced options provided by the yBLASTn form above.
  897. *
  898. * @see blast_ui_tblastn_advanced_options_form().
  899. */
  900. function blast_ui_tblastn_advanced_options_form_submit($form, $form_state) { }