PageRenderTime 36ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Prohits/analyst/pop_unMatched_bioGrid.php

http://prohits.googlecode.com/
PHP | 193 lines | 166 code | 10 blank | 17 comment | 17 complexity | 7e4eb7c303f382e0ce34de72d02df799 MD5 | raw file
  1. <?
  2. /***********************************************************************
  3. Copyright 2010 Gingras and Tyers labs,
  4. Samuel Lunenfeld Research Institute, Mount Sinai Hospital.
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. *************************************************************************/
  15. $orderBy = "GeneName";
  16. $show_found_hits = '';
  17. require("../common/site_permission.inc.php");
  18. require("common_functions.inc.php");
  19. include("../common/common_fun.inc.php");
  20. require_once("../msManager/is_dir_file.inc.php");
  21. $bgcolordark_header = '#808040';
  22. $bgcolorsubdark_header = '#d2d2a6';
  23. $bgcolorlight = '#f5f5f5';
  24. $bgcolordark = '#cecece';
  25. $bgHitcolor = "#e2e083";
  26. //$tmp_file = "../TMP/bioGrid/". $USER->ID .".csv";
  27. $tmp_file = $level1_matched_file;
  28. if(!_is_file($tmp_file)){
  29. echo "Cannot find file $tmp_file";
  30. }
  31. $proteinDB = new mysqlDB(PROHITS_PROTEINS_DB, HOSTNAME, USERNAME, DBPASSWORD);
  32. if(!_is_file($tmp_file)){
  33. echo "file $tmp_file is not exists";
  34. exit;
  35. }
  36. if(!$tmp_handle = fopen($tmp_file, 'r')){
  37. echo "Cannot open file ($tmp_file)";
  38. }
  39. $rootArr = array();
  40. $baitInfoArr = array();
  41. $flag = '';
  42. while(!feof($tmp_handle)){
  43. $buffer = fgets($tmp_handle, 4096);
  44. $buffer = trim($buffer);
  45. if(!$buffer) continue;
  46. if($buffer == "edge_info"){
  47. $flag = 1;
  48. continue;
  49. }elseif($buffer == "bait_info"){
  50. $flag = 2;
  51. continue;
  52. }
  53. if($flag == "1"){
  54. $tmpArr = explode(",",$buffer);
  55. if(!$show_found_hits && $tmpArr[0]) continue;
  56. $tmpArr2 = explode(" ",$tmpArr[1]);
  57. if(!array_key_exists($tmpArr2[0], $rootArr)){
  58. $rootArr[$tmpArr2[0]] = array();
  59. }
  60. array_push($rootArr[$tmpArr2[0]], $buffer);
  61. }elseif($flag == "2"){
  62. $tmpArr = explode(",",$buffer);
  63. $tmpArr2 = explode(" ",$tmpArr[0]);
  64. $baitInfoArr[$tmpArr2[0]] = $tmpArr2[0].",".$tmpArr[1].",".$tmpArr2[1];
  65. }
  66. }
  67. fclose($tmp_handle);
  68. if($show_found_hits){
  69. $title = "BioGRID interactions".str_repeat(' ', 10);
  70. }else{
  71. $title = "BioGRID interactions not found";
  72. }
  73. ?>
  74. <html>
  75. <head>
  76. <title>Prohits</title>
  77. <link rel="stylesheet" type="text/css" href="./site_style.css">
  78. <script language="Javascript" src="site_javascript.js"></script>
  79. <script language="Javascript">
  80. function sortList(order_by){
  81. var theForm = document.grid_form;
  82. theForm.orderBy.value = order_by;
  83. theForm.submit();
  84. }
  85. function show_found(){
  86. var theForm = document.grid_form;
  87. theForm.submit();
  88. }
  89. </script>
  90. </head>
  91. <body>
  92. <form name=grid_form action=<?=$PHP_SELF;?> method=post>
  93. <input type=hidden name=orderBy value=''>
  94. <input type=hidden name=level1_matched_file value='<?=$level1_matched_file?>'>
  95. <table border="0" cellpadding="1" cellspacing="1" width="100%">
  96. <tr>
  97. <td colspan=4 nowrap>
  98. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  99. <tr>
  100. <td>
  101. <font color="navy" face="helvetica,arial,futura" size="3">
  102. <b><?=$title?></b>
  103. </font>
  104. </td>
  105. <td align="right">
  106. <input type=checkbox name=show_found_hits value='y' onclick="show_found();" <?=($show_found_hits)?'checked':''?>>
  107. <font color="navy" face="helvetica,arial,futura" size="3">
  108. Show found hits
  109. </font>
  110. </td>
  111. </tr>
  112. </table>
  113. </td>
  114. </tr>
  115. <tr bgcolor="<?echo $bgcolordark_header;?>">
  116. <td width="5" height="25" align=center>
  117. <div class=tableheader>Gene ID</div>
  118. </td>
  119. <td width="70" align="center" >
  120. <div class=tableheader>Gene Name</div>
  121. </td>
  122. <td width="70" align="center">
  123. <div class=tableheader>Links</div>
  124. </td>
  125. <td width="25" align=center>
  126. <div class=tableheader>BioGRID Type</div>
  127. </td>
  128. </tr>
  129. <?
  130. foreach($baitInfoArr as $baitID => $baitInfoVal){
  131. if(!array_key_exists($baitID, $rootArr)) continue;
  132. $bait_hits_arr = $rootArr[$baitID];
  133. if(!$bait_hits_arr) continue;
  134. $tmpBaitArr = explode(",",$baitInfoVal);
  135. $baitUrlStr = get_URL_str('', $tmpBaitArr[1], '');
  136. $baitUrlStr = str_replace("<br>", "", $baitUrlStr);
  137. ?>
  138. <tr bgcolor="<?echo $bgcolorsubdark_header;?>">
  139. <td colspan=4><div class=maintext>
  140. <b>Bait ID</b>:&nbsp;<?=$tmpBaitArr[0];?>&nbsp;&nbsp;
  141. <b>Bait Gene ID</b>:&nbsp;<?=$tmpBaitArr[1];?>&nbsp;&nbsp;<br>
  142. <b>Bait Gene Name</b>:&nbsp;<?=$tmpBaitArr[2];?>&nbsp;&nbsp;&nbsp;<?=$baitUrlStr?>
  143. </div></td>
  144. </tr>
  145. <?
  146. foreach($bait_hits_arr as $hit_val){
  147. $tmpHitArr = explode(",",$hit_val);
  148. $tmpArr = explode('??',$tmpHitArr[1]);
  149. $tmpTypeArr = explode(":",$tmpHitArr[2]);
  150. $UrlStr = get_URL_str('', $tmpHitArr[3], '');
  151. $UrlStr = str_replace("<br>", "", $UrlStr);
  152. if($tmpHitArr[0]){
  153. $bgcolor = $bgcolordark;
  154. }else{
  155. $bgcolor = $bgcolorlight;
  156. }
  157. ?>
  158. <tr bgcolor='<?=$bgcolor;?>' onmousedown="highlightTR(this, 'click', '#CCFFCC', '<?=$bgcolor;?>');">
  159. <td width="" align="center"><div class=maintext>
  160. <?=$tmpHitArr[3]?>&nbsp;
  161. </div>
  162. </td>
  163. <td width="" align="center"><div class=maintext>
  164. <?=$tmpArr[1]?>&nbsp;
  165. </div>
  166. </td>
  167. <td width="" align="center"><div class=maintext>
  168. <?echo $UrlStr;?>&nbsp;
  169. </div>
  170. </td>
  171. <?echo get_bioGrid_icon($tmpTypeArr,$tmpType,'u');?>
  172. </tr>
  173. <?
  174. }
  175. }
  176. ?>
  177. </table>
  178. </form>
  179. </body>
  180. </html>