Commits

Anonymous committed f0d3d21

relations are now much more redundant, have better element detecting and look prettier

Comments (0)

Files changed (4)

 		$myClass = substr($classArray[2], 0, -4);
 		echo "$(\".$myClass\").html('');";
 		unlink($file);
+		$relations = file_get_contents('temp/' . $classArray[1] . '/relations.txt');
+		$relationsArray=explode("'$myClass'", $relations);
+//		echo "<pre>" . print_r($relationsArray, true) . "</pre>";
+		$f = fopen('temp/' . $classArray[1] ."/relations.txt", 'w');
+		foreach($relationsArray as $rel) {
+			if(substr($rel, -1) !== ';'){
+				$rel = substr($rel,0, -1);
+			}
+		fwrite($f, $rel);
+		}
+	}
+	if (is_file('temp/' . $classArray[1] . '/relations.txt') == true) {
+		$relations = file_get_contents('temp/' . $classArray[1] . '/relations.txt');
+		$relationsArray=explode("~", $relations);
+		echo "var colorArray = new Array('#c2374c', '#CC9933', '#0000cc', '#336633', '#000000', '#FF9900', '#999900','#c2374c', '#CC9933', '#0000cc', '#336633', '#000000', '#FF9900', '#999900','#c2374c', '#CC9933', '#0000cc', '#336633', '#000000', '#FF9900', '#999900');
+		var c = -1;
+	var canvas = document.getElementById('relationsCanvas');
+	var context = canvas.getContext('2d');
+	context.clearRect(0,0,canvas.width,canvas.height);";
+		foreach ($relationsArray as $relation) {
+			echo $relation;
+			echo "
+				c++;
+				var figPos = $('.' + jq(relArray[0])).offset();
+				var len = relArray.length;
+				for (var i= 1; i < len; i++) {
+					var pos1 = $('#' + jq(relArray[i])).offset();
+					DrawLine(pos1.left, pos1.top + 12, figPos.left, figPos.top, colorArray[c]);
+				}
+				";
+		}
 	}
 	echo " </script>";
 ?>
 $histogramFiles = array();
 $lineScatFiles = array();
 $tileFiles = array();
-$seed = '';
-$d = 0;
-echo "<table width=\"400\" align=\"center\" cellpadding='3' cellspacing='2' style='border: 1px solid #CCCCCC;background-color:#DEEBDC; '>
-		<tr><td>&nbsp;</td><td>Filename</td><td>Date uploaded</td><td>Filesize (KB)</td></tr>";
+echo "<table id='fileManager' width=\"400\" align=\"center\" cellpadding='3' cellspacing='2' style='border: 1px solid #CCCCCC;background-color:#DEEBDC; '>
+		<tr><td>&nbsp;</td><td>Filename</td><td>Date uploaded</td><td>Filesize (KB)</td><td rowspan=20><canvas width='100' height='300' id='relationsCanvas'></canvas></td></tr>";
 foreach (glob($outDir . '*') as $allfile1) {
 	if(substr($allfile1, strlen($username) + 6) != 'hist' & substr($allfile1, strlen($username) + 6) != 'relations.txt' & substr($allfile1, strlen($username)+6, -6) != 'zzzzzzz' & substr($allfile1, strlen($username)+6, -6) != 'zzzzzz') {
 		$time = filemtime($allfile1);
 		echo "<td class='". $class ."'>" . substr($allfile1, strlen($username) + 6) . "</td>";
 		echo "<td class='". $class ."'>" .date(j, $time). "/". date(n, $time). "/". date(y,$time). "</td>";
 		echo "<td id='".$class."' class='". $class ."'>" . round(filesize($allfile1)/1024, 1) . "</td>";
-//		if (empty($images[$c]) == false) {
-//			$imgClass = substr($images[$c], 11 + strlen($username), -4);
-//			echo "<td>" . "<a id='$images[$c]' class='$imgClass' href='$images[$c]' target='_blank'><img align='center' src='". $images[$c] ."' height='40' width='40'></a>";
-//		}
+		if (empty($images[$c]) == false) {
+			$imgClass = substr($images[$c], 11 + strlen($username), -4);
+			echo "<td></td><td>" . "<a id='$images[$c]' class='$imgClass' href='$images[$c]' target='_blank'><img align='center' src='". $images[$c] ."' height='40' width='40'></a>";
+		}
 		echo "</tr>";
 		$q=FALSE;
 		if('txt' == substr($allfile1, -3)) {
 			$linkFiles[$c] = $allfile1;
 		}
 		$c++;
-	} else if (substr($allfile1, strlen($username)+6, -6) == 'zzzzzzz' | substr($allfile1, strlen($username)+6, -6) == 'zzzzzz') {
-		if (empty($images[$d]) == false) {
-			$imgClass = substr($images[$d], 11 + strlen($username), -4);
-			echo "<tr><td></td><td></td><td></td><td></td><td>" . "<a id='$images[$d]' class='$imgClass' href='$images[$d]' target='_blank'><img align='center' src='". $images[$d] ."' height='40' width='40'></a></tr>";
-			$d++;
+	} else if (substr($allfile1, strlen($username)+6, -6) == 'zzzzzzz' | substr($allfile1, strlen($username)+6, -6) == 'zzzzzz' | $allfile1 == 'hist') {
+		if (empty($images[$c]) == false) {
+			echo $seed2;
+			$imgClass = substr($images[$c], 11 + strlen($username), -4);
+			echo "<tr><td></td><td></td><td></td><td></td><td></td><td>" . "<a id='$images[$c]' class='$imgClass' href='$images[$c]' target='_blank'><img align='center' src='". $images[$c] ."' height='40' width='40'></a></tr>";
 		}
+	$c++;
 	}
 }
 $histScript = '';
 		$linkScript .= "<option value='$file' selected='selected'>$filename</option>";
 	}
 }
-$script ="<script>	delLines();";
+$script ="<script>var colorArray = new Array('#c2374c', '#CC9933', '#0000cc', '#336633', '#000000', '#FF9900', '#999900','#c2374c', '#CC9933', '#0000cc', '#336633', '#000000', '#FF9900', '#999900','#c2374c', '#CC9933', '#0000cc', '#336633', '#000000', '#FF9900', '#999900');
+		var c = -1;";
 if (is_file('temp/' . $username . '/relations.txt') == true) {
 	$relations = file_get_contents('temp/' . $username . '/relations.txt');
 	$relationsArray=explode("~", $relations);
 	foreach ($relationsArray as $relation) {
 		$script .= $relation;
 		$script .= "
+				c++;
 				var figPos = $('.' + jq(relArray[0])).offset();
-
 				var len = relArray.length;
 				for (var i= 1; i < len; i++) {
-					var pos1 = $('#' + jq(relArray[i])).offset();
-					DrawLine(pos1.left + 12, pos1.top + 12, figPos.left, figPos.top);
+					var filei = $('#' + jq(relArray[i]));
+					var pos1 = filei.offset();
+					DrawLine(pos1.left + filei.width(), pos1.top + filei.height()/2, figPos.left, figPos.top, colorArray[c]);
 				}
-				window.alert('hi');
 				";
 	}
 }
 $script .="	var scripts = new Array(\"$heatmapScript\", \"$histogramScript\", \"$lineScatScript\", \"$tileScript\");
 	function start() {
-		delLines();
 		var username = document.getElementById('userID').value;
 		var dis = document.getElementById('circosForm');
 		dis.style.display = 'block';
 
 </script>
 <script type="text/javascript">
+Array.prototype.remove = function() {
+    var what, a = arguments, L = a.length, ax;
+    while (L && this.length) {
+        what = a[--L];
+        while ((ax = this.indexOf(what)) !== -1) {
+            this.splice(ax, 1);
+        }
+    }
+    return this;
+};
+
 function cookieAjax() {
 	return 		$.ajax({
 		type: "POST",
  * displays the id in the textbox and gives the option to save the id as a cookie
  */
 function startNewSession() { 
+	$('#fileManager').css('display', 'none');
 	var chars = "1234567890abcdefghijklmnopqrstuvwxyz";
 	var token = "";
 	var c = 0;
 /*
  * Draws a line given start and stop coordinates
  */
- function DrawLine(x1, y1, x2, y2) {
-	    c = $(document.body);
-	    var dx = Math.abs(x2-x1);
-	    var dy = Math.abs(y2-y1);
-	    var d = Math.max(dx, dy);
-	    var i=0;
-	    for(i=0; i < d; i++) {
-	        var img = $(document.createElement('img')).attr('src', 'blank.gif');
-	        var div = $(document.createElement('div')).width(1).height(1).css({'background-color': '#008080', position: 'absolute', left: Math.min(x1,x2)+(i*dx/d), top: Math.min(y1,y2)+(i*dy/d) });
-	        div.append(img);
-	        c.append(div);
-	    }
-	}
-/*
- * Deletes all the lines
- */
-function delLines() {
-	while($('body > div:last-child').html() != '<a style="display:none">huehuehue</a>') {
-		$('body > div:last-child').remove();
+function DrawLine(x1, y1, x2, y2, color) {
+	var canvas = document.getElementById('relationsCanvas');
+	var context = canvas.getContext('2d');
+	var posAdjust = $('#relationsCanvas').offset();
+	x1 = x1-posAdjust.left;
+	y1 = y1-posAdjust.top;
+	x2 = x2-posAdjust.left;
+	y2 = y2-posAdjust.top;
+	context.beginPath();
+	context.moveTo(x1, y1);
+	context.lineTo(x2, y2);
+    context.strokeStyle = color;
+	context.stroke(); 
 	}
-}
 /*
  * Espaces characters that need to be escaped in a jquery ID selector
  */
 </script>
 </head>
 <body>
+<!--[IF IE]>
+    <script type="text/javascript">
+           <script>window.alert('WARNING Internet explorer does not support many of the features on this website, please consider upgrading your browser');</script>
+    </script>
+<![endif]-->
 <div id='delete_div'></div>
 <div align="center">
 <h1> Circos Plot Generator</h1> <a href="http://cran.r-project.org/web/packages/RCircos/index.html" target="_blank">A web interface for the RCircos r package</a><br>
 				<td>&nbsp;</td>
 			</tr>
 			<tr>
-		<td colspan=6 align=center><INPUT type="Submit" Name=Submit VALUE="Upload data" id="mySubmit"> <input id="showRelations" type="checkbox" value="showRelations"
-										name="showRelations">Show file relations. (this could take a while)</input></td>
+		<td colspan=6 align=center><INPUT type="Submit" Name=Submit VALUE="Upload data" id="mySubmit"></td>
 		<tr> <td colspan=6 align=center>
 		<button type='button' id='start' style="display: none">Start</button>
   </td>

rcircos_action.php

 	if('$geneFile' =='') {
 		c <- c-3
 		probe <- T;
+		linkNumber <- c;
 	}
 	for( i in 1:5) {
 		TrackType <- TrackTypes[i];
 dev.off();
 THERSCRIPT;
 $circosPlot ="temp/" . $username . "/hist/" . $fileName."." .$fileType;
-$relations = fopen('temp/' . $username ."/relations.txt", 'a');
-$file1 = substr($Track1File, 6 + strlen($username), -4);
-$file2 = substr($Track2File, 6 + strlen($username), -4);
-$file3 = substr($Track3File, 6 + strlen($username), -4);
-$file4 = substr($Track4File, 6 + strlen($username), -4);
-$file5 = substr($Track5File, 6 + strlen($username), -4);
-$file6 = substr($geneFile, 6 + strlen($username), -4);
-$file7 = substr($linkFile, 6 + strlen($username), -4);
-$relationstext = "var relArray = new Array(); relArray[0]='".$fileName."';";
-$c = 1;
-if($file1 != '') {
-	$relationstext .= "
-relArray[$c]='$file1';";
-	$c++;
-}
-if($file2 !='') {
-	$relationstext .= "
-relArray[$c]='$file2';";
-	$c++;
-}
-if($file3 != '') {
-	$relationstext .= "
-relArray[$c]='$file3';";
-	$c++;
-}
-if($file4 != '') {
-	$relationstext .= "
-relArray[$c]='$file4';";
-	$c++;
-}
-if($file5 != '') {
-	$relationstext .= "
-relArray[$c]='$file5';";
-	$c++;
-}
-if($file6 != '') {
-	$relationstext .= "
-relArray[$c]='$file6';";
-	$c++;
-}
-if($file7 != '') {
-	$relationstext .= "
-relArray[$c]='$file7';";
-} $relationstext .= "~";
-fwrite($relations, $relationstext);
-fclose($relations);
-$contents = file_get_contents('temp/' . $username . '/relations.txt');
-$relationsArray = explode("~", $contents);
 //echo "<pre>" . print_r($relationsArray, true) . "</pre>";
 foreach (glob("temp/" . '*') as $allfile1) {
 	if ( (time() - filemtime($allfile1)) > 60*60*24*7) unlink($allfile1);
 }
 $isDone = false;
 $c = 0;
-while($isDone = false); {
+while($isDone == false) {
 	if(is_file('temp/' . $username . '/zzzzzzz' . $c . ".txt")) {
 		$c++;
 	} else {
 		fopen('temp/' . $username . '/zzzzzzz' . $c . ".txt", 'w');
+		$isDone = true;
 	}
 }
 $cmd_file = "temp/" . $fileName. '_R.cmd';
 $('#historySelect').val('$circosPlot');
 	</script><img align='center' src='". $circosPlot ."' height='800' width='800' >";
 }
+$relations = fopen('temp/' . $username ."/relations.txt", 'a');
+$file1 = substr($Track1File, 6 + strlen($username), -4);
+$file2 = substr($Track2File, 6 + strlen($username), -4);
+$file3 = substr($Track3File, 6 + strlen($username), -4);
+$file4 = substr($Track4File, 6 + strlen($username), -4);
+$file5 = substr($Track5File, 6 + strlen($username), -4);
+$file6 = substr($geneFile, 6 + strlen($username), -4);
+$file7 = substr($linkFile, 6 + strlen($username), -4);
+$relationstext = "var relArray = new Array('".$fileName."'";
+$c = 1;
+if($file1 != '') {
+	$relationstext .= " ,'$file1'";
+	$c++;
+}
+if($file2 !='') {
+	$relationstext .= ",'$file2'";
+	$c++;
+}
+if($file3 != '') {
+	$relationstext .= ",'$file3'";
+	$c++;
+}
+if($file4 != '') {
+	$relationstext .= ",'$file4'";
+	$c++;
+}
+if($file5 != '') {
+	$relationstext .= ",'$file5'";
+	$c++;
+}
+if($file6 != '') {
+	$relationstext .= ",'$file6'";
+	$c++;
+}
+if($file7 != '') {
+	$relationstext .= ",'$file7'";
+} $relationstext .= ");~";
+fwrite($relations, $relationstext);
+fclose($relations);
 
 ?>