blast_ui.form_advanced_options.inc 42 KB

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