blast_ui.form_advanced_options.inc 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  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="https://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml#expect" target="_blank">More Information</a> | <a href="https://www.youtube.com/watch?v=nO0wJgZRZJs" target="_blank">Expect value video tutorial</a>'),
  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_options('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="https://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml#expect" target="_blank">More Information</a> | <a href="https://www.youtube.com/watch?v=nO0wJgZRZJs" target="_blank">Expect value 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. $gapKey = $form_state['values']['gapCost'];
  427. $gap = getGap($matrix, $gapKey);
  428. //eksc- need to implement query range limit
  429. // q_range
  430. return array(
  431. 'max_target_seqs' => $numAlign,
  432. 'evalue' => $eVal,
  433. 'word_size' => $wordSize,
  434. 'gapopen' => $gapOpen,
  435. 'gapextend' => $gapExtend,
  436. 'culling_limit' => $qRange,
  437. 'matrix' => $matrix,
  438. );
  439. }//blast_ui_blastp_advanced_options_form_submit
  440. /**
  441. * Fill the matrix dropdown list with appropriate options
  442. *
  443. * @return
  444. * An array consisting of matrices name for the first dropdown list
  445. */
  446. function _get_matrix_options() {
  447. return drupal_map_assoc(array(
  448. t('PAM30'),
  449. t('PAM70'),
  450. t('PAM250'),
  451. t('BLOSUM80'),
  452. t('BLOSUM62'),
  453. t('BLOSUM45'),
  454. t('BLOSUM50'),
  455. t('BLOSUM90'),
  456. ));
  457. }
  458. /**
  459. * Fill the gap penalty dropdown list with appropriate options given selected matrix
  460. *
  461. * @return
  462. * An array containing open and extension gap values for the chosen matrix (to fill the second dropdown list)
  463. */
  464. function _get_gap_for_matrix($key = '') {
  465. $options = array(
  466. t('PAM30') => drupal_map_assoc(array(
  467. t('Existence: 7 Extension: 2'),
  468. t('Existence: 6 Extension: 2'),
  469. t('Existence: 5 Extension: 2'),
  470. t('Existence: 10 Extension: 1'),
  471. t('Existence: 9 Extension: 1'),
  472. t('Existence: 8 Extension: 1'),
  473. )),
  474. t('PAM70') => drupal_map_assoc(array(
  475. t('Existence: 8 Extension: 2'),
  476. t('Existence: 7 Extension: 2'),
  477. t('Existence: 6 Extension: 2'),
  478. t('Existence: 11 Extension: 1'),
  479. t('Existence: 10 Extension: 1'),
  480. t('Existence: 9 Extension: 1'),
  481. )),
  482. t('PAM250') => drupal_map_assoc(array(
  483. t('Existence: 15 Extension: 3'),
  484. t('Existence: 14 Extension: 3'),
  485. t('Existence: 13 Extension: 3'),
  486. t('Existence: 12 Extension: 3'),
  487. t('Existence: 11 Extension: 3'),
  488. t('Existence: 17 Extension: 2'),
  489. t('Existence: 16 Extension: 2'),
  490. t('Existence: 15 Extension: 2'),
  491. t('Existence: 14 Extension: 2'),
  492. t('Existence: 13 Extension: 2'),
  493. t('Existence: 21 Extension: 1'),
  494. t('Existence: 20 Extension: 1'),
  495. t('Existence: 19 Extension: 1'),
  496. t('Existence: 18 Extension: 1'),
  497. t('Existence: 17 Extension: 1'),
  498. )),
  499. t('BLOSUM80') => drupal_map_assoc(array(
  500. t('Existence: 8 Extension: 2'),
  501. t('Existence: 7 Extension: 2'),
  502. t('Existence: 6 Extension: 2'),
  503. t('Existence: 11 Extension: 1'),
  504. t('Existence: 10 Extension: 1'),
  505. t('Existence: 9 Extension: 1'),
  506. )),
  507. t('BLOSUM62') => drupal_map_assoc(array(
  508. t('Existence: 11 Extension: 2'),
  509. t('Existence: 10 Extension: 2'),
  510. t('Existence: 9 Extension: 2'),
  511. t('Existence: 8 Extension: 2'),
  512. t('Existence: 7 Extension: 2'),
  513. t('Existence: 6 Extension: 2'),
  514. t('Existence: 13 Extension: 1'),
  515. t('Existence: 12 Extension: 1'),
  516. t('Existence: 11 Extension: 1'),
  517. t('Existence: 10 Extension: 1'),
  518. t('Existence: 9 Extension: 1'),
  519. )),
  520. t('BLOSUM45') => drupal_map_assoc(array(
  521. t('Existence: 13 Extension: 3'),
  522. t('Existence: 12 Extension: 3'),
  523. t('Existence: 11 Extension: 3'),
  524. t('Existence: 10 Extension: 3'),
  525. t('Existence: 15 Extension: 2'),
  526. t('Existence: 14 Extension: 2'),
  527. t('Existence: 13 Extension: 2'),
  528. t('Existence: 12 Extension: 2'),
  529. t('Existence: 19 Extension: 1'),
  530. t('Existence: 18 Extension: 1'),
  531. t('Existence: 17 Extension: 1'),
  532. t('Existence: 16 Extension: 1'),
  533. )),
  534. t('BLOSUM50') => drupal_map_assoc(array(
  535. t('Existence: 13 Extension: 3'),
  536. t('Existence: 12 Extension: 3'),
  537. t('Existence: 11 Extension: 3'),
  538. t('Existence: 10 Extension: 3'),
  539. t('Existence: 9 Extension: 3'),
  540. t('Existence: 16 Extension: 2'),
  541. t('Existence: 15 Extension: 2'),
  542. t('Existence: 14 Extension: 2'),
  543. t('Existence: 13 Extension: 2'),
  544. t('Existence: 12 Extension: 2'),
  545. t('Existence: 19 Extension: 1'),
  546. t('Existence: 18 Extension: 1'),
  547. t('Existence: 17 Extension: 1'),
  548. t('Existence: 16 Extension: 1'),
  549. t('Existence: 15 Extension: 1'),
  550. )),
  551. t('BLOSUM90') => drupal_map_assoc(array(
  552. t('Existence: 9 Extension: 2'),
  553. t('Existence: 8 Extension: 2'),
  554. t('Existence: 7 Extension: 2'),
  555. t('Existence: 6 Extension: 2'),
  556. t('Existence: 11 Extension: 1'),
  557. t('Existence: 10 Extension: 1'),
  558. t('Existence: 9 Extension: 1'),
  559. )),
  560. );
  561. if (isset($options[$key])) {
  562. return $options[$key];
  563. }
  564. else {
  565. return array();
  566. }
  567. }//_get_gap_for_matrix
  568. /**
  569. * Respond to Ajax dropdown call
  570. */
  571. function ajax_dependent_dropdown_callback($form, $form_state) {
  572. return $form['ALG']['SParam']['gapCost'];
  573. }
  574. /**
  575. * @section
  576. * tBLASTn: Search translated nucleotide database using a protein query.
  577. * ----------------------------------------------------------------------------
  578. */
  579. /**
  580. * Adds the tBLASTn Advanced Options to the passed in form.
  581. *
  582. * This form function is meant to be called within another form definition.
  583. *
  584. * @param $form
  585. * The form the advanced options should be added to. This form already
  586. * contains a $form['ALG'] fieldset meant to contain the advanced options.
  587. * @param $formstate
  588. * The current state fo the form passed in as $form.
  589. */
  590. function blast_ui_tblastn_advanced_options_form(&$form, $form_state) {
  591. // Edit and Resubmit functionality.
  592. // We want to pull up the details from a previous blast and fill them in as defaults
  593. // for this blast.
  594. if (isset($form_state['prev_blast'])) {
  595. $defaults = _get_default_values($form_state['prev_blast']->options, 'blastn');
  596. }
  597. else {
  598. $defaults = _get_default_values(array(), 'tblastn');
  599. }
  600. $form['ALG']['GParam'] = array(
  601. '#type' => 'fieldset',
  602. '#title' => t('General parameters'),
  603. '#collapsible' => FALSE,
  604. );
  605. $form['ALG']['GParam']['maxTarget'] = array(
  606. '#type' => 'select',
  607. '#title' => t('Max target sequences:'),
  608. '#options' => _get_max_target('tblastn'),
  609. '#default_value' => $defaults['max_target_seqs'],
  610. '#description' => t('Select the maximum number of aligned sequences to display'),
  611. );
  612. $form['ALG']['GParam']['eVal'] = array(
  613. '#type' => 'textfield',
  614. '#title' => t('e-Value (Expected Threshold)'),
  615. '#default_value' => $defaults['evalue'],
  616. '#size' => 12,
  617. '#maxlength' => 20,
  618. '#description' => t('Expected number of chance matches in a random model. This number should be give in a decimal format. <a href="https://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml#expect" target="_blank">More Information</a> | <a href="https://www.youtube.com/watch?v=nO0wJgZRZJs" target="_blank">Expect value vedio tutorial</a>'),
  619. );
  620. /*eksc- need to learn how this is implemented for tblastn
  621. $form['ALG']['GParam']['shortQueries'] = array(
  622. '#type' => 'checkbox',
  623. '#title' => t('Automatically adjust parameters for short input sequences'),
  624. '#default_value' => TRUE,
  625. );
  626. */
  627. $form['ALG']['GParam']['wordSize'] = array(
  628. '#type' => 'select',
  629. '#title' => t('Word size:'),
  630. '#options' => _get_word_size('tblastn'),
  631. '#default_value' => $defaults['word_size'],
  632. '#description' => t('The length of the seed that initiates an alignment'),
  633. );
  634. // Scoring parameters
  635. //.........................
  636. $form['ALG']['SParam'] = array(
  637. '#type' => 'fieldset',
  638. '#title' => t('Scoring parameters'),
  639. '#collapsible' => FALSE,
  640. );
  641. $matrix_options = _get_matrix_options();
  642. $form['ALG']['SParam']['Matrix'] = array(
  643. '#type' => 'select',
  644. '#title' => 'Matrix',
  645. '#options' => $matrix_options,
  646. '#default_value' => $defaults['matrix'],
  647. '#description' => t('Assigns a score for aligning pairs of residues, and determines overall alignment score..'),
  648. '#ajax' => array(
  649. 'callback' => 'ajax_dependent_dropdown_callback',
  650. 'wrapper' => 'dropdown-second-replace',
  651. ),
  652. );
  653. $form['ALG']['SParam']['gapCost'] = array(
  654. '#type' => 'select',
  655. '#title' => t('Gap Costs:'),
  656. '#prefix' => '<div id="dropdown-second-replace">',
  657. '#suffix' => '</div>',
  658. '#options' => _get_gap_for_matrix($defaults['matrix']),
  659. '#default_value' => 2,
  660. '#description' => t('Cost to create and extend a gap in an alignment.'),
  661. );
  662. $form['ALG']['GParam']['qRange'] = array(
  663. '#type' => 'textfield',
  664. '#title' => t('Max matches in a query range'),
  665. '#default_value' => $defaults['qRange'],
  666. '#size' => 12,
  667. '#maxlength' => 20,
  668. '#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.'),
  669. );
  670. }
  671. /**
  672. * Validate the advanced options provided by the tBLASTn form above.
  673. *
  674. * @see blast_ui_tblastn_advanced_options_form().
  675. */
  676. function blast_ui_tblastn_advanced_options_form_validate($form, $form_state) {
  677. // Ensure that our textfields are what we expect them to be since we will
  678. // use them to generate the BLAST command.
  679. // First up, e-value. We expect the evalue to be a very small yet still
  680. // positive number. It may be given in scientific notation which is
  681. // luckily supported by is_numeric().
  682. if (!is_numeric($form_state['values']['eVal'])) {
  683. 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>.');
  684. }
  685. // Next textfield up, "Max matches in a query range" which is also expected
  686. // to be a positive number.
  687. if (!is_numeric($form_state['values']['qRange'])) {
  688. form_set_error('qRange', 'The "Max matches in a query range" should be a positive integer.');
  689. }
  690. }
  691. /**
  692. * Processed the advanced options provided by the tBLASTn form above.
  693. *
  694. * @see blast_ui_tblastn_advanced_options_form().
  695. */
  696. function blast_ui_tblastn_advanced_options_form_submit($form, $form_state) {
  697. return blast_ui_blastp_advanced_options_form_submit($form, $form_state);
  698. }
  699. /**
  700. * Get default form values; may come from saved job data if user is re-running
  701. * a previous job.
  702. */
  703. function _get_default_values($options) {
  704. // restore previous values or set to default
  705. $max_target = (isset($options['max_target_seqs']))
  706. ? $options['max_target_seqs'] : 0;
  707. $short_queries = (isset($options['shortQueries']))
  708. ? $options['shortQueries'] : true;
  709. $evalue = (isset($options['evalue']))
  710. ? $options['evalue'] : variable_get('eVal', 0.001);
  711. $word_size = (isset($options['word_size']))
  712. ? $options['word_size'] : 11;
  713. $qRange = (isset($options['culling_limit']))
  714. ? $options['culling_limit'] : variable_get('qRange',0);
  715. $matchmiss = 0;
  716. $reward = (isset($options['reward']))
  717. ? $options['reward'] : 1;
  718. $penalty = (isset($options['penalty']))
  719. ? $options['penalty'] : -2;
  720. if ($reward == 1) {
  721. switch ($penalty) {
  722. case -1: $matchmiss = 5; break;
  723. case -2: $matchmiss = 0; break;
  724. case -3: $matchmiss = 1; break;
  725. case -4: $matchmiss = 2; break;
  726. }
  727. }
  728. else if ($reward == 2) {
  729. $matchmiss = 3;
  730. }
  731. else if ($reward == 3) {
  732. $matchmis = 4;
  733. }
  734. else if ($eward == 4) {
  735. $matchmiss = 5;
  736. }
  737. $gap = 0;
  738. $gapopen = (isset($options['gapopen']))
  739. ? $options['gapopen'] : 5;
  740. $gapextend = (isset($options['gapextend']))
  741. ? $options['gapextend'] : 2;
  742. if ($gapextend == 2) {
  743. switch ($gapopen) {
  744. case 5: $gap = 0; break;
  745. case 2: $gap = 1; break;
  746. case 1: $gap = 2; break;
  747. case 0: $gap = 3; break;
  748. }
  749. }
  750. else if ($gapextend == 1) {
  751. switch ($gapopen) {
  752. case 3: $gap = 4;
  753. case 2: $gap = 5;
  754. case 1: $gap = 6;
  755. }
  756. }
  757. // eksc- need to implement query range limit
  758. // $q_range = 0;
  759. $matrix = (isset($options['matrix']))
  760. ? $options['matrix'] : 'PAM30';
  761. return array(
  762. 'max_target_seqs' => $max_target,
  763. 'short_queries' => $short_queries,
  764. 'word_size' => $word_size,
  765. 'evalue' => $evalue,
  766. 'matchmiss' => $matchmiss,
  767. 'gap' => $gap,
  768. 'qRange' => $qRange,
  769. 'matrix' => $matrix,
  770. );
  771. }//_get_default_values
  772. /**
  773. * Get a list of options for the max_target_seq blast option.
  774. *
  775. * The options are the same for all programs
  776. * and describe the maximum number of aligned sequences to keep.
  777. */
  778. function _get_max_target($which) {
  779. switch ($which) {
  780. case 'blastn':
  781. case 'blastx':
  782. case 'blastp':
  783. case 'tblastn':
  784. return array(
  785. 0 => t(' '),
  786. 10 => t('10'),
  787. 50 => t('50'),
  788. 100 => t('100'),
  789. 250 => t('250'),
  790. 500 => t('500'),
  791. 1000 => t('1000'),
  792. 5000 => t('5000'),
  793. 10000 => t('10000'),
  794. 20000 => t('20000'),
  795. );
  796. }//switch
  797. }
  798. /**
  799. * Get a list of options for work size.
  800. */
  801. function _get_word_size($which) {
  802. switch ($which) {
  803. case 'blastn':
  804. return array(
  805. 7 => t('7'),
  806. 11 => t('11'),
  807. 15 => t('15'),
  808. 16 => t('16'),
  809. 20 => t('20'),
  810. 24 => t('24'),
  811. 28 => t('28'),
  812. 32 => t('32'),
  813. 48 => t('48'),
  814. 64 => t('64'),
  815. 128 => t('128'),
  816. 256 => t('256'),
  817. );
  818. case 'blastx':
  819. case 'blastp':
  820. case 'tblastn':
  821. return array(
  822. // 2 => t('2'),
  823. 3 => t('3'),
  824. 6 => t('6'),
  825. );
  826. }//switch
  827. }
  828. /**
  829. * Get a list of options for match/mismatch ratio.
  830. */
  831. function _get_match_mismatch($which) {
  832. switch ($which) {
  833. case 'blastn':
  834. return array(
  835. 0 => t('1,-2'),
  836. 1 => t('1,-3'),
  837. 2 => t('1,-4'),
  838. 3 => t('2,-3'),
  839. 4 => t('4,-5'),
  840. 5 => t('1,-1'),
  841. );
  842. }//switch
  843. }
  844. /**
  845. * Get gap values based on matrix and selected gap "key"
  846. */
  847. function getGap($matrix, $gapkey) {
  848. switch ($matrix) {
  849. case 'PAM30':
  850. switch ($gapKey) {
  851. case 0:
  852. $gapOpen = 7;
  853. $gapExtend = 2;
  854. break;
  855. case 1:
  856. $gapOpen = 6;
  857. $gapExtend = 2;
  858. break;
  859. case 2:
  860. $gapOpen = 5;
  861. $gapExtend = 2;
  862. break;
  863. case 3:
  864. $gapOpen = 10;
  865. $gapExtend = 1;
  866. break;
  867. case 4:
  868. $gapOpen = 9;
  869. $gapExtend = 1;
  870. break;
  871. case 5:
  872. $gapOpen = 8;
  873. $gapExtend = 1;
  874. break;
  875. }
  876. break;
  877. case 'PAM70':
  878. switch ($gapKey) {
  879. case 0:
  880. $gapOpen = 8;
  881. $gapExtend = 2;
  882. break;
  883. case 1:
  884. $gapOpen = 7;
  885. $gapExtend = 2;
  886. break;
  887. case 2:
  888. $gapOpen = 6;
  889. $gapExtend = 2;
  890. break;
  891. case 3:
  892. $gapOpen = 11;
  893. $gapExtend = 1;
  894. break;
  895. case 4:
  896. $gapOpen = 10;
  897. $gapExtend = 1;
  898. break;
  899. case 5:
  900. $gapOpen = 9;
  901. $gapExtend = 1;
  902. break;
  903. }
  904. break;
  905. case 'PAM250':
  906. switch ($gapKey) {
  907. case 0:
  908. $gapOpen = 15;
  909. $gapExtend = 3;
  910. break;
  911. case 1:
  912. $gapOpen = 14;
  913. $gapExtend = 3;
  914. break;
  915. case 2:
  916. $gapOpen = 13;
  917. $gapExtend = 3;
  918. break;
  919. case 3:
  920. $gapOpen = 12;
  921. $gapExtend = 3;
  922. break;
  923. case 4:
  924. $gapOpen = 11;
  925. $gapExtend = 3;
  926. break;
  927. case 5:
  928. $gapOpen = 17;
  929. $gapExtend = 2;
  930. break;
  931. case 6:
  932. $gapOpen = 16;
  933. $gapExtend = 2;
  934. break;
  935. case 7:
  936. $gapOpen = 15;
  937. $gapExtend = 2;
  938. break;
  939. case 8:
  940. $gapOpen = 14;
  941. $gapExtend = 2;
  942. break;
  943. case 9:
  944. $gapOpen = 13;
  945. $gapExtend = 2;
  946. break;
  947. case 10:
  948. $gapOpen = 21;
  949. $gapExtend = 1;
  950. break;
  951. case 11:
  952. $gapOpen = 20;
  953. $gapExtend = 1;
  954. break;
  955. case 12:
  956. $gapOpen = 19;
  957. $gapExtend = 1;
  958. break;
  959. case 13:
  960. $gapOpen = 18;
  961. $gapExtend = 1;
  962. break;
  963. case 14:
  964. $gapOpen = 17;
  965. $gapExtend = 1;
  966. break;
  967. }
  968. break;
  969. case 'BLOSUM80':
  970. switch ($gapKey) {
  971. case 0:
  972. $gapOpen = 8;
  973. $gapExtend = 2;
  974. break;
  975. case 1:
  976. $gapOpen = 7;
  977. $gapExtend = 2;
  978. break;
  979. case 2:
  980. $gapOpen = 6;
  981. $gapExtend = 2;
  982. break;
  983. case 3:
  984. $gapOpen = 11;
  985. $gapExtend = 1;
  986. break;
  987. case 4:
  988. $gapOpen = 10;
  989. $gapExtend = 1;
  990. break;
  991. case 5:
  992. $gapOpen = 9;
  993. $gapExtend = 1;
  994. break;
  995. }
  996. break;
  997. case 'BLOSUM62':
  998. switch ($gapKey) {
  999. case 0:
  1000. $gapOpen = 11;
  1001. $gapExtend = 2;
  1002. break;
  1003. case 1:
  1004. $gapOpen = 10;
  1005. $gapExtend = 2;
  1006. break;
  1007. case 2:
  1008. $gapOpen = 9;
  1009. $gapExtend = 2;
  1010. break;
  1011. case 3:
  1012. $gapOpen = 8;
  1013. $gapExtend = 2;
  1014. break;
  1015. case 4:
  1016. $gapOpen = 7;
  1017. $gapExtend = 2;
  1018. break;
  1019. case 5:
  1020. $gapOpen = 6;
  1021. $gapExtend = 2;
  1022. break;
  1023. case 6:
  1024. $gapOpen = 13;
  1025. $gapExtend = 1;
  1026. break;
  1027. case 7:
  1028. $gapOpen = 12;
  1029. $gapExtend = 1;
  1030. break;
  1031. case 8:
  1032. $gapOpen = 11;
  1033. $gapExtend = 1;
  1034. break;
  1035. case 9:
  1036. $gapOpen = 10;
  1037. $gapExtend = 1;
  1038. break;
  1039. case 10:
  1040. $gapOpen = 9;
  1041. $gapExtend = 1;
  1042. break;
  1043. }
  1044. break;
  1045. case 'BLOSUM45':
  1046. switch ($gapKey) {
  1047. case 0:
  1048. $gapOpen = 13;
  1049. $gapExtend = 3;
  1050. break;
  1051. case 1:
  1052. $gapOpen = 12;
  1053. $gapExtend = 3;
  1054. break;
  1055. case 2:
  1056. $gapOpen = 11;
  1057. $gapExtend = 3;
  1058. break;
  1059. case 3:
  1060. $gapOpen = 10;
  1061. $gapExtend = 3;
  1062. break;
  1063. case 4:
  1064. $gapOpen = 15;
  1065. $gapExtend = 2;
  1066. break;
  1067. case 5:
  1068. $gapOpen = 14;
  1069. $gapExtend = 2;
  1070. break;
  1071. case 6:
  1072. $gapOpen = 13;
  1073. $gapExtend = 2;
  1074. break;
  1075. case 7:
  1076. $gapOpen = 12;
  1077. $gapExtend = 2;
  1078. break;
  1079. case 8:
  1080. $gapOpen = 19;
  1081. $gapExtend = 1;
  1082. break;
  1083. case 9:
  1084. $gapOpen = 18;
  1085. $gapExtend = 1;
  1086. break;
  1087. case 10:
  1088. $gapOpen = 17;
  1089. $gapExtend = 1;
  1090. break;
  1091. case 11:
  1092. $gapOpen = 16;
  1093. $gapExtend = 1;
  1094. break;
  1095. }
  1096. break;
  1097. case 'BLOSUM50':
  1098. switch ($gapKey) {
  1099. case 0:
  1100. $gapOpen = 13;
  1101. $gapExtend = 3;
  1102. break;
  1103. case 1:
  1104. $gapOpen = 12;
  1105. $gapExtend = 3;
  1106. break;
  1107. case 2:
  1108. $gapOpen = 11;
  1109. $gapExtend = 3;
  1110. break;
  1111. case 3:
  1112. $gapOpen = 10;
  1113. $gapExtend = 3;
  1114. break;
  1115. case 4:
  1116. $gapOpen = 9;
  1117. $gapExtend = 3;
  1118. break;
  1119. case 5:
  1120. $gapOpen = 16;
  1121. $gapExtend = 2;
  1122. break;
  1123. case 6:
  1124. $gapOpen = 15;
  1125. $gapExtend = 2;
  1126. break;
  1127. case 7:
  1128. $gapOpen = 14;
  1129. $gapExtend = 2;
  1130. break;
  1131. case 8:
  1132. $gapOpen = 13;
  1133. $gapExtend = 2;
  1134. break;
  1135. case 9:
  1136. $gapOpen = 12;
  1137. $gapExtend = 2;
  1138. break;
  1139. case 10:
  1140. $gapOpen = 19;
  1141. $gapExtend = 1;
  1142. break;
  1143. case 11:
  1144. $gapOpen = 18;
  1145. $gapExtend = 1;
  1146. break;
  1147. case 12:
  1148. $gapOpen = 17;
  1149. $gapExtend = 1;
  1150. break;
  1151. case 13:
  1152. $gapOpen = 16;
  1153. $gapExtend = 1;
  1154. break;
  1155. case 14:
  1156. $gapOpen = 15;
  1157. $gapExtend = 1;
  1158. break;
  1159. }
  1160. break;
  1161. case 'BLOSUM90':
  1162. switch ($gapKey) {
  1163. case 0:
  1164. $gapOpen = 9;
  1165. $gapExtend = 2;
  1166. break;
  1167. case 1:
  1168. $gapOpen = 8;
  1169. $gapExtend = 2;
  1170. break;
  1171. case 2:
  1172. $gapOpen = 7;
  1173. $gapExtend = 2;
  1174. break;
  1175. case 3:
  1176. $gapOpen = 6;
  1177. $gapExtend = 2;
  1178. break;
  1179. case 4:
  1180. $gapOpen = 11;
  1181. $gapExtend = 1;
  1182. break;
  1183. case 5:
  1184. $gapOpen = 10;
  1185. $gapExtend = 1;
  1186. break;
  1187. case 6:
  1188. $gapOpen = 9;
  1189. $gapExtend = 1;
  1190. break;
  1191. }
  1192. break;
  1193. }
  1194. return array(
  1195. 'gapOpen' => $gapOpen,
  1196. 'gapExtend' => $gapExtend
  1197. );
  1198. }
  1199. /**
  1200. * Get a list of options for gaps.
  1201. */
  1202. function _get_gap_options($which) {
  1203. switch ($which) {
  1204. case 'blastn':
  1205. return array(
  1206. 0 => t('Existence: 5 Extension: 2'),
  1207. 1 => t('Existence: 2 Extension: 2'),
  1208. 2 => t('Existence: 1 Extension: 2'),
  1209. 3 => t('Existence: 0 Extension: 2'),
  1210. 4 => t('Existence: 3 Extension: 1'),
  1211. 5 => t('Existence: 2 Extension: 1'),
  1212. 6 => t('Existence: 1 Extension: 1'),
  1213. );
  1214. }//switch
  1215. }
  1216. /**
  1217. * Translate above gap options into blast gap open and extend costs.
  1218. */
  1219. function _set_gap($gap_key) {
  1220. switch ($gap_key) {
  1221. case 0:
  1222. $gapOpen = 5;
  1223. $gapExtend = 2;
  1224. break;
  1225. case 1:
  1226. $gapOpen = 2;
  1227. $gapExtend = 2;
  1228. break;
  1229. case 2:
  1230. $gapOpen = 1;
  1231. $gapExtend = 2;
  1232. break;
  1233. case 3:
  1234. $gapOpen = 0;
  1235. $gapExtend = 2;
  1236. break;
  1237. case 4:
  1238. $gapOpen = 3;
  1239. $gapExtend = 1;
  1240. break;
  1241. case 5:
  1242. $gapOpen = 2;
  1243. $gapExtend = 1;
  1244. break;
  1245. case 6:
  1246. $gapOpen = 1;
  1247. $gapExtend = 1;
  1248. break;
  1249. }//switch
  1250. return array('gapOpen' => $gapOpen, 'gapExtend' => $gapExtend);
  1251. }
  1252. /**
  1253. * Translate mismatch/match ratio option into blast penalty/reward options.
  1254. */
  1255. function _set_match_mismatch($m_m) {
  1256. switch ($m_m) {
  1257. case 0:
  1258. $penalty = -2;
  1259. $reward = 1;
  1260. break;
  1261. case 1:
  1262. $penalty = -3;
  1263. $reward = 1;
  1264. break;
  1265. case 2:
  1266. $penalty = -4;
  1267. $reward = 1;
  1268. break;
  1269. case 3:
  1270. $penalty = -3;
  1271. $reward = 2;
  1272. break;
  1273. case 4:
  1274. $penalty = -5;
  1275. $reward = 4;
  1276. break;
  1277. case 5:
  1278. $penalty = -1;
  1279. $reward = 1;
  1280. break;
  1281. }//switch
  1282. return array('penalty' => $penalty, 'reward' => $reward);
  1283. }