about summary refs log tree commit diff
path: root/sourcecodes/bn_file_load_gom.php
diff options
context:
space:
mode:
authorziejd22018-03-14 23:23:33 -0500
committerGitHub2018-03-14 23:23:33 -0500
commit1ff6baa44e22b91eefb48aea6f3befa078c0489b (patch)
treee0fd79d2e32fd2aedda2eadaed0f19af3514c520 /sourcecodes/bn_file_load_gom.php
parent6882395afdadf4e982b25b5215071a0932730950 (diff)
parentc80226899f5cdd9f11c163817d59445213f5bef0 (diff)
downloadBNW-1ff6baa44e22b91eefb48aea6f3befa078c0489b.tar.gz
Merge pull request #1 from ziejd2/octave_php_separate
Octave php separate
Diffstat (limited to 'sourcecodes/bn_file_load_gom.php')
-rw-r--r--sourcecodes/bn_file_load_gom.php270
1 files changed, 31 insertions, 239 deletions
diff --git a/sourcecodes/bn_file_load_gom.php b/sourcecodes/bn_file_load_gom.php
index 342afe02..8f14aa7a 100644
--- a/sourcecodes/bn_file_load_gom.php
+++ b/sourcecodes/bn_file_load_gom.php
@@ -1,5 +1,7 @@
 <?php
-////////////////This code load a data file and creates input file for continuous global optimal search (our modification). execute_bn_gom.php link is for execution of structure learning and create_tiers_gom.php is for adding restrictions///////////////////////////////////
+  //Going to modify this so it just writes the uploaded data to a file.
+  //Standardization and determining other factors will be performed in
+  //  a Matlab/Octave script.
 
 include("header_new.inc");
 include("header_batchsearch.inc");
@@ -8,6 +10,7 @@ $searchID="";
 $UploadValue="NO";
 $TextFile=$HTTP_POST_FILES["MyFile"]["name"];
 
+
 /////////////Generate a random key/////////////////////
 $alphas=array();
 $alphas = array_merge(range('A', 'Z'), range('a', 'z'));
@@ -24,39 +27,11 @@ if($_POST["My_key"]!="")
   $keyval=$_POST["My_key"];
 
 
-////////////////////max parent/////////////////////////
-
-
-$type_n=array();
-
-//Get number of parent data and key value for changes in number of parent
-$type_n=explode("|",$_POST["nm_parent"]);
-if($keyval=="")
-   $keyval=$type_n[0];
-
 $sid=$keyval."continuous_input";
 $dir="./data/";
 
-$TextinFileFinal=$dir.$sid.".txt";
-$TextinFile=$dir.$sid."_temp.txt";
-$TextinFilenamelist=$dir.$keyval."name.txt";
-
-//print default number of parents
-$parent_number=4;
-$pfile=$dir.$keyval."parent.txt";
-$parentf=fopen($pfile,"w");
-fwrite($parentf,"$parent_number\n");
+$TextinFile=$dir.$sid."_orig.txt";
 
-//print default number of k for model averaging
-$k_number=1;
-$kfile=$dir.$keyval."k.txt";
-$kf=fopen($kfile,"w");
-fwrite($kf,"$k_number\n");
-
-//print default threshold for model averaging
-$thrfile=$dir.$keyval."thr.txt";
-$kf=fopen($thrfile,"w");
-fwrite($kf,"0.5\n");
 
 if(isset($HTTP_POST_VARS["searchkey"]))
 {
@@ -69,10 +44,6 @@ if($searchID!="")
 ?>
 
 <!-- Site navigation menu -->
-<ul class="navbar2">
-  <li><a href="executionprogress.php?My_key=<?php print($keyval);?>">Perform Bayesian network modeling using default settings</a>
-  <li><a href="create_tiers_gom.php?My_key=<?php print($keyval);?>">Go to structure learning settings and the BNW structural constraint interface</a>  
-</ul>
 <ul class="navbar">
   <li><a href="help.php#file_format" target="_blank">Data formatting guidelines</a> 
   <li><a href="help.php" target="_blank">Help</a>
@@ -111,7 +82,7 @@ if(isset($HTTP_POST_VARS["MyUpload"]))
             else
             {
                 $searchID=file_get_contents("$TextinFile");
-		  unlink($TextinFile);
+		//unlink($TextinFile);
 
             }
 
@@ -140,7 +111,7 @@ if(isset($HTTP_POST_VARS["MyUpload"]))
 </tr>
 <tr>
 <td align="left"><font color=#33339f><br>Content of uploaded data file:</font><br>
-          <textarea name="searchkey" rows="10" cols="100"><?PHP print($searchID)?> </textarea>
+          <textarea name="searchkey" rows="8" cols="100"><?PHP print($searchID)?> </textarea>
 </td>
 </tr>
 <tr>
@@ -176,220 +147,41 @@ if(isset($HTTP_POST_VARS["MyUpload"]))
 </table>
 </FORM>
 </div>
-<?php
-//////////////////Format data for Structure learning "C" code////////
-
-  $str_arr=array();
-  $searchID=trim($searchID);
-  $str_arr=explode("\n",$searchID);
-  $data=array();
-
-   
-  $fph = fopen($TextinFilenamelist,"w");
-  $fpmain = fopen($TextinFileFinal,"w");
-
-  $cont_arr=array();
-  $cont_arr_tmp=array();
-
-
-  $data_type=array();
-  $level_arr=array();
-
-//Who is discrete? Who is continuous?
-  $i=0;
-  $lc=0;
-  foreach($str_arr as $line)
-  {
-    $line=trim($line); 
-    if($lc==0)
-      {
-       fwrite($fph, "$line\n");
-	fprintf($fpmain, "$line\n");
-       $name_t=$line;
-
-	fclose($fph); 
-       $data=explode("\t",$line);
-	$j=0;
-       foreach($data as $d_c)
-	  {
-           $d_c=trim($d_c);
-           $level_arr[$j][0]=$d_c;  //variable name y for 
-            
-	    $data_type[$j]=0;
-            $j++;
-          }
-          $lcc=$j;  //$lcc=number of column in the input file 
-      }        
-    else
-      { 
-        
-        $strline=""; 
-        $data=explode("\t",$line);
-	 $j=0;
-        foreach($data as $d_c) 
-        {
-            $d_c=trim($d_c);
-	     $cont_arr[$i][$j]=$d_c; 
-            $cont_arr_tmp[$i][$j]=$d_c; 
-
-            $mystring = $d_c;
-	     $findme   = '.';
-	     $pos = strpos($mystring, $findme);
-            $strline.="1\t";
-  
-            if ($pos != false)
-            {
-                $data_type[$j]=1;
-            }
-            $j++;
-         }
-	 $i++; 
-    
-      }
-     $lc++;
-     
-  }
-$lc--; //$lc=number of rows in the input file
-//Now count number of labels for discrete variables and populate the $data_type[$j] 
-$data_count=0;
-$l_type="";
-for($j=0;$j<$lcc;$j++)
-{
-
-       if($data_type[$j]!=1)
-	{
-	  $data_count=0;
-	  for($i=0;$i<$lc;$i++)
-	  {
-              $vi=$i+1;
-	       for($ii=$vi;$ii<$lc;$ii++)
-	       {
-                 if($cont_arr[$i][$j]==$cont_arr[$ii][$j] && $cont_arr[$i][$j]!=-9999)
-		   {
-		       $cont_arr[$ii][$j]=-9999; 
-               
-		   } 
-	       }
-               
-              
-         }
-	  for($i=0;$i<$lc;$i++)
-	     {
-	       if($cont_arr[$i][$j]!=-9999 && $cont_arr[$i][$j]!="")
-		{
-                  // $data_count_l=$data_count+2;
-                  $data_count++;
-                  $level_arr[$j][$data_count]=$cont_arr[$i][$j];
-              }
-	     }
-	  $data_type[$j]=$data_count;
-	    
-	   
-	}
-       if($j==0)
-         $l_type.=$data_type[$j];
-       else
-	 $l_type.="\t".$data_type[$j];  
-      
-    }
-
-///////////////////Write data to files/////////////////
-$fptype = fopen($dir.$keyval."type.txt","w");
-$fpnode= fopen($dir.$keyval."nnode.txt","w");
-fwrite($fpnode,"$lcc\n");
-$fprows = fopen($dir.$keyval."nrows.txt","w");
-fwrite($fprows,"$lc\n");
-$flevel = fopen($dir.$keyval."nlevels.txt","w");
-
-//print in level mapping file for discrete variables
-for($j=0;$j<$lcc;$j++)
-{
-  if($data_type[$j]>1)
-  {  
-      fprintf($flevel,"%s",$level_arr[$j][0]);
-      $m=$data_type[$j];
-      for($jj=1;$jj<=$m;$jj++)
-      {
-         fprintf($flevel,"\t%s",$level_arr[$j][$jj]);
-      }
-
-      fprintf($flevel,"\n");  
-  }   
-}
-
-
-fwrite($fptype,"$name_t\n");
-for($j=0;$j<$lcc;$j++)
-{
-  fprintf($fptype,"$data_type[$j]\t");
-}
-fwrite($fptype,"\n");
-
-  
-fwrite($fpmain, "$l_type\n");
-$l_c=0;
-
-//perform discrete level replacement 
-for($m=0;$m<$lcc;$m++)  //column
-{
-  if($data_type[$m]>1)
-  {
-     $r=$data_type[$m];
-     for($j=1;$j<=$r;$j++)
-     {  
-         $search=$level_arr[$m][$j];
-         $replace=$j."#";
-         for($n=0;$n<$lc;$n++)  //row
-         { 
-           $val=$cont_arr_tmp[$n][$m];
-           if($val==$search)
-               $cont_arr_tmp[$n][$m]=$replace;  //alter levels 
-         }
-     }
-     for($n=0;$n<$lc;$n++)  //row
-          $cont_arr_tmp[$n][$m]=str_replace('#','',$cont_arr_tmp[$n][$m]);
-  }
-}
-
-//write data to output file
-for($j=0;$j<$lc;$j++)
-{
-  fprintf($fpmain,"%s",$cont_arr_tmp[$j][0]);
-  for($jj=1;$jj<$lcc;$jj++)
-    fprintf($fpmain,"\t%s",$cont_arr_tmp[$j][$jj]);
-  fprintf($fpmain, "\n");
-}
-
-fclose($fpmain);
-
-////////////////empty ban and white list/////////////////////////////
-
-$sid1=$keyval."ban";
-$sid2=$keyval."white";
-$wdir="./data/"; 
 
-$Textban=$wdir.$sid1.".txt";
-$Textwhite=$wdir.$sid2.".txt";
-
-$fpb = fopen($Textban,"w");
-$fpw = fopen($Textwhite,"w");
-
-$datpost="From\tTo\n";
+<?php
 
-fwrite($fpb,"$datpost");
-fwrite($fpw,"$datpost");
 if($searchID!="")
 {
-
-$runtime=exe_time($keyval,$parent_number,$k_number);
+  if ($UploadValue=="NO")
+  {
+      $fpdata = fopen($dir.$keyval."continuous_input_orig.txt","w");
+      fwrite($fpdata,$searchID);
+  }  
+  shell_exec('./run_prep_input '.$keyval);
+  $parent_number=4;
+  $k_number=1;
+  $runtime=exe_time($keyval,$parent_number,$k_number);
 ?>
+<ul class="navbar2">
+  <li><a href="javascript:void(0);"
+NAME="InputCheck" title="InputCheck"
+    onClick=window.open("input_check.php?My_key=<?php print($keyval);?>","Rat//ting","width=950,height=270,0,status=0,");>View uploaded variables and data</a>
+  <li><a href="executionprogress.php?My_key=<?php print($keyval);?>">Perform Bayesian network modeling using default settings</a>
+  <li><a href="create_tiers_gom.php?My_key=<?php print($keyval);?>">Go to structure learning settings and the BNW structural constraint interface</a>  
+</ul>
 <div id="outernew">
 <p><h3><?php 
 print("Estimated run time for current dataset using default settings: $runtime seconds");
 ?>
-<br><br></h3>
+<br><br><br><br></h3>
 </p>
 <br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
 </div>
 <?php
 }