about summary refs log tree commit diff
path: root/sourcecodes/graphviz_structure.php
diff options
context:
space:
mode:
Diffstat (limited to 'sourcecodes/graphviz_structure.php')
-rw-r--r--sourcecodes/graphviz_structure.php36
1 files changed, 23 insertions, 13 deletions
diff --git a/sourcecodes/graphviz_structure.php b/sourcecodes/graphviz_structure.php
index 1e866bc4..641a4854 100644
--- a/sourcecodes/graphviz_structure.php
+++ b/sourcecodes/graphviz_structure.php
@@ -40,7 +40,9 @@ $n=count($dataname);
 
 $initialstring="digraph G {\n"."size=\"6,8\";\n"."node [shape=square,width=1.5];\n";
 $endstring="}";
-fwrite($fout,"$initialstring");
+if ($fout !== false) {
+  fwrite($fout,"$initialstring");
+}
 //fwrite($fouttemp,"$initialstring_temp");
 
 
@@ -48,10 +50,12 @@ fwrite($fout,"$initialstring");
 $g_file_name="/tmp/bnw/".$keyval."grviz_name_file.txt";
 $grviz_name_file=fopen($g_file_name,"w");
 
-for($i=0;$i<$n;$i++)
-{
-      $row_name=trim($dataname[$i]);  
-      fwrite($grviz_name_file,"$row_name\n");
+if ($grviz_name_file !== false) {
+  for($i=0;$i<$n;$i++)
+  {
+        $row_name=trim($dataname[$i]);
+        fwrite($grviz_name_file,"$row_name\n");
+  }
 }
 
 for($i=1;$i<=$n;$i++)
@@ -67,17 +71,21 @@ for($i=1;$i<=$n;$i++)
 	   {
                $col_val=trim($col_arr[$j]);
                if($col_val==1)
-               { 
+               {
                   $col_name=trim($dataname[$j]);
-                  fprintf($fout,"%s -> %s;\n",$ii,$j);  
+                  if ($fout !== false) {
+                    fprintf($fout,"%s -> %s;\n",$ii,$j);
+                  }
                   //fprintf($fouttemp,"%s -> %s;\n",$row_name,$col_name);
-                 
+
 	        }
           }
           
      
-} 
-fwrite($fout,"$endstring");   
+}
+if ($fout !== false) {
+  fwrite($fout,"$endstring");
+}
 //fwrite($fouttemp,"$endstring");
  
 //shell_exec('/usr/bin/dot -Tpng -o /var/www/html/compbio/BNW/graphviz.jpg /var/www/html/compbio/BNW/graphviztemp.txt');
@@ -87,9 +95,11 @@ fwrite($fout,"$endstring");
 $file1="/tmp/bnw/".$keyval."run_initialstructure.sh";
 $initiallines=file_get_contents("/tmp/bnw/temp_shell_file_initial_structure");
 $all_lines="$initiallines"."$keyval\nfi\nexit";
-$fp = fopen($file1,"w"); 
-fwrite($fp, "$all_lines\n");
-fclose($fp);
+$fp = fopen($file1,"w");
+if ($fp !== false) {
+  fwrite($fp, "$all_lines\n");
+  fclose($fp);
+}
 //prepare and execute shell script for matlab with a write lock
 //$cmd="./runmat.sh $keyval";
 //system($cmd);