blast_ui.custom.inc 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /*
  3. * customized for PeanutBase
  4. *
  5. */
  6. function tripal_custom_generate_linkout($url_prefix, $hit, $info, $options = array()) {
  7. // uncomment to see contents of hit object
  8. //echo "hit:<pre>";var_dump($hit);echo "</pre>";
  9. // uncomment to see contents of info object
  10. //echo "info:<pre>";var_dump($info);echo "</pre>";
  11. $hit_name = $hit->{'Hit_def'};
  12. if ($info['Target'] == 'All genomes') {
  13. if (preg_match('/.*(aradu).*/i', $hit_name) == 1) {
  14. $blastdb_name = 'PeanutBase_aradu_gbrowse';
  15. }
  16. else if (preg_match('/.*(araip).*/i', $hit_name) == 1) {
  17. $blastdb_name = 'PeanutBase_araip_gbrowse';
  18. }
  19. else if (preg_match('/^Cc/', $hit_name) == 1) {
  20. $blastdb_name = 'LegumeInfo_cajca_gbrowse';
  21. }
  22. else if (preg_match('/^Ca/', $hit_name) == 1) {
  23. $blastdb_name = 'LegumeInfo_cicar_gbrowse';
  24. $hit_name = preg_replace("/(.*?)\s.*/", '$1', $hit_name);
  25. }
  26. else if (preg_match('/^Gm/', $hit_name) == 1) {
  27. $blastdb_name = 'SoyBase_glyma_gbrowse';
  28. }
  29. else if (preg_match('/^Lj/', $hit_name) == 1) {
  30. $blastdb_name = 'LegumeInfo_lotja_gbrowse';
  31. }
  32. else if (preg_match('/^Mt/', $hit_name) == 1) {
  33. $blastdb_name = 'LegumeInfo_medtr_gbrowse';
  34. }
  35. else if (preg_match('/^Pv/', $hit_name) == 1) {
  36. $blastdb_name = 'LegumeInfo_phavu_gbrowse';
  37. }
  38. else if (preg_match('/^Vr/', $hit_name) == 1) {
  39. $blastdb_name = 'LegumeInfo_vigra_gbrowse';
  40. }
  41. $hit->{'linkout_id'} = $hit_name;
  42. $url_prefix = tripal_custom_getURLprefix($blastdb_name);
  43. $url = tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $options);
  44. }//handle All genomes BLAST target
  45. else {
  46. if (preg_match('/.*(aradu).*/i', $hit_name) == 1) {
  47. preg_match("/\w+\.(\w+\.\w+)/", $hit_name, $linkout_match);
  48. $linkout_id = $linkout_match[1];
  49. $hit->{'linkout_id'} = $linkout_id;
  50. $url = "/gbrowse_aradu1.0?query=q=$linkout_id;h_feat=$linkout_id";
  51. }
  52. else if(preg_match('/.*(araip).*/i', $hit_name) == 1) {
  53. preg_match("/\w+\.(\w+\.\w+)/", $hit_name, $linkout_match);
  54. $linkout_id = $linkout_match[1];
  55. $hit->{'linkout_id'} = $linkout_id;
  56. $url = "/gbrowse_araip1.0?query=q=$linkout_id;h_feat=$linkout_id";
  57. }
  58. else if(preg_match('/.*(phytozome).*/i', $hit_name) == 1) {
  59. preg_match("/(.*?)\s.*/", $hit_name, $linkout_match);
  60. $linkout_id = $linkout_match[1];
  61. $hit->{'linkout_id'} = $linkout_id;
  62. $url = "http://legumeinfo.org/chado_phylotree/$linkout_id";
  63. }
  64. else {
  65. // Don't know what to do with this hit
  66. drupal_set_message("Don't know how to create linkout for $hit_name", 'error');
  67. $url = false;
  68. }
  69. }//handle remaining BLAST targets
  70. return "$url";
  71. }
  72. function tripal_custom_getURLprefix($blastdb_name) {
  73. $sql = "SELECT urlprefix FROM db WHERE name='$blastdb_name'";
  74. if ($res = chado_query($sql)) {
  75. if ($row=$res->fetchObject()) {
  76. return $row->urlprefix;
  77. }
  78. }
  79. return false;
  80. }//tripal_custom_getURLprefix