<html>
<head>
   <title>PepSurf Job Information</title>
<script language='javascript'>
function spaceover(n)
{
	with (document)
	{
		if (n < 1000)
			write("&nbsp;");
		if (n < 100)
			write("&nbsp;");
		if (n < 10)
			write("&nbsp;");
	}
}
function timediff(t2, t1)
{
	var sec2 = parseInt(t2.substring(t2.lastIndexOf(":") + 1));
	t2 = t2.substring(0, t2.lastIndexOf(":"));

	var sec1 = parseInt(t1.substring(t1.lastIndexOf(":") + 1));
	t1 = t1.substring(0, t1.lastIndexOf(":"));

	var min2 = parseInt(t2.substring(t2.lastIndexOf(":") + 1));
	t2 = t2.substring(0, t2.lastIndexOf(":"));

	var min1 = parseInt(t1.substring(t1.lastIndexOf(":") + 1));
	t1 = t1.substring(0, t1.lastIndexOf(":"));

	var hr2 = parseInt(t2);
	var hr1 = parseInt(t1);

	var secdiff = sec2 - sec1;
	var mindiff = min2 - min1;
	var hrdiff = hr2 - hr1;

	if (secdiff < 0)
	{
		secdiff += 60;
		mindiff -= 1;
	}

	if (mindiff < 0)
	{
		mindiff += 60;
		hrdiff -= 1;
	}

	return(hrdiff + ":" + mindiff + ":" + secdiff);
}

function highlightMismatches(alist)
{
	var aalist = new Array();
	aalist = alist.split(",");

	var icom2, idash, aalen, ispace;

	var icom = 0;

	// No aligned AA for first AA?
	// Assume there is at least one comma, and that there is at least one
	// aligned AA, so at least one dash.
	icom2 = alist.indexOf(",", icom + 1);
	idash = alist.indexOf("-");
	if (idash > icom2)
	{
		alist = alist.substring(0, icom + 2) + "<font color='red'><b>" +
			alist.substring(icom + 2);
		alist = alist.substring(0, icom + 5 + 21) + "</b></font>" +
			alist.substring(icom + 26);
//		alert(alist);
	}
	else
	{
		// mismatched first pair?
		// don't assume peptide length is <9, can be double digits!
		var ispace = alist.indexOf(" ");
		// we already have idash
		var aa1 = alist.substring(ispace + 1,	idash);
		var aa2 = alist.substring(idash + 1, idash + 4);
//		alert("|" + aa1 + "| |" + aa2 + "|");
		if (aa1 != aa2)
		{
			alist = alist.substring(0, 2) + "<font color='red'><b>" + alist.substring(2);
			alist = alist.substring(0, 30) + "</b></font>" + alist.substring(30);
//		alert(alist);
		}
	}

	while ((icom = alist.indexOf(",", icom + 1)) != -1)
	{
		// No matched AA?
		icom2 = alist.indexOf(",", icom + 1);
		if (icom2 == -1)
			aalen = alist.substring(icom + 1).length;
		else
			aalen = icom2 - icom;
		if (aalen < 8)
		{
			alist = alist.substring(0, icom + 3) + "<font color='red'><b>" +
				alist.substring(icom + 3);
			alist = alist.substring(0, icom + 6 + 21) + "</b></font>" +
				alist.substring(icom + 27);
//			alert(alist);
			continue;
		}

		// mismatched pair of AA's?
		var aa1 = alist.substring(icom + 3, icom + 6);
		var aa2 = alist.substring(icom + 7, icom + 10);
//		alert("|" + aa1 + "| |" + aa2 + "|");
		if (aa1 != aa2)
		{
			alist = alist.substring(0, icom + 3) + "<font color='red'><b>" + alist.substring(icom + 3);
			alist = alist.substring(0, icom + 31) + "</b></font>" + alist.substring(icom + 31);
//			alert(alist);
		}
	}
	return alist;
}
</script>
</head>

<body bgcolor='#d0d0d0'>

<div align=center>
<big><big><b>

<script language='javascript'>
	document.writeln(opener.serverName);
</script>

Job Information
</b></big><p>
<script language='javascript'>
	with (document)
	{
		write("Go to <a href=\"http://pepsurf.tau.ac.il/results/");
		write(opener.top.pepsurf_run_number);
		writeln("/index.htm\" target=\"resultswin\">Results of Job");
		writeln(opener.top.pepsurf_run_number + "<\/a>");
	}
</script>
(until they are deleted from the server).
</b></big>

<p>
The information below is obtained from the header of PDB file
<br><b>
<script language='javascript'>
	document.write(opener.top.pdbFilename); // FGiJ specific variable
</script>
</b>
<br>
<script language='javascript'>
	with (document)
	{
		if (true) //opener.top.pdbToLoad.substring(0,5) == "http:")
		{
			writeln("This PDB file can be");
			writeln("<a href=\"javascript: opener.show_download_info()\">");
			writeln("saved to your computer</a>.");
		}
	}
</script>


<br>

<p><table border="1" cellpadding="10" bgcolor="#c0e0c0"><!-- was e0ffe0 -->

<tr><td colspan="2">
<center><big><b>Job Parameters</b></big>
<br>

<script language='javascript'>
		with (document)
		{
			writeln("Job ");
			writeln(opener.top.pepsurf_run_number);
			writeln("by PepSurf version  " + opener.top.pepsurf_version);
			writeln("on " + opener.top.pepsurf_run_date + ".");
		}
</script>

</center></td></tr><tr><td>

<!-- BEGIN COLUMN ONE JOB PARAMETERS -->

<ul>

<li>PDB ID:<b>
<script language='javascript'>
	with (document)
	{
		// If the PDB ID is legal, link it to RCSB. Otherwise just show it unlinked.

		if (opener.top.consurf_pdb_id.length == 4)
		{
			write("<a href=\"http://www.rcsb.org/pdb/cgi/explore.cgi?pdbId=");
			writeln(opener.top.consurf_pdb_id + "\"");
			writeln("target = \"rcsbwin\">");
		}

		write(opener.top.consurf_pdb_id.toUpperCase());

		if (opener.top.consurf_pdb_id.length == 4)
		{
			writeln("<\/a>");
		}
	}
</script>

</b><li>

Chain(s) processed:<b>

<script language='javascript'>
	document.writeln(opener.top.consurf_chain);
</script>

<script language='javascript'>
	if (opener.consurf_identical_chains != "")
	{
		document.writeln("</b><li>Chains identical in sequence to chain processed:<b>");
		document.writeln(opener.top.consurf_identical_chains);
	}
</script>

	</ul>
</td><td>

<li>Substitution matrix:<b>

<script language='javascript'>
	document.writeln(opener.pepsurf_substitution_matrix);
</script>

</b><li>Gap penalty:<b>

<script language='javascript'>
	document.writeln(opener.pepsurf_gap_penalty);
</script>

</b><li>Probability for best path:<b>

<script language='javascript'>
	document.writeln(opener.pepsurf_probability_for_best_path);
</script>


</b></td></tr></table>

<p>For an explanation of the Job Parameters and Results, please see the
on-line documentation for the
<a href="http://pepsurf.tau.ac.il">PepSurf Server</a>.


<!-- BEGIN RESULTS -->

<p><table border="1" cellpadding="10" bgcolor="white"><!-- was c0a0e0 -->

<tr><td colspan="2">
<center><big><b>Job Results</b></big>
<br>

<script language='javascript'>
	var start = opener.top.pepsurf_run_submission_time;
	var finish = opener.top.pepsurf_run_completion_time;
	var jobtime = timediff(finish, start);

	var tmsg = "Job time was <b>" + jobtime + "</b> (started at " + start +
		", ended at " + finish + ").";

	document.writeln(tmsg);

</script>

</center></td></tr><tr><td>


<script language='javascript'>
	with (document)
	{
		var iclu;
		for (iclu = 1; iclu <= opener.pepsurf_cluster_count; iclu++)
		{
//			if (iclu > 1)
//				writeln("<br><br>");

			var clist = opener.get_cluster_list(iclu);
			var clen = clist.split("|").length;
			clist = clist.replace(/\|/g, ", ");

			writeln("<big>Cluster " + iclu + ":</big>");
			writeln("&nbsp; &nbsp; <big>(" + clen + "</big> amino acids)<br>");

			writeln(clist);


			writeln("<ul>");

			var ial, pepn, pepaa, alist;
			// for each peptide aligned to iclu
			for (ial = 1; ial <= opener.pepsurf_alignment_count; ial++)
			{
				if (opener.pepsurf_alignment_cluster[ial] == iclu)
				{
					writeln("<li>");

					pepn = opener.pepsurf_alignment_peptide[ial];
					pepaa = opener.pepsurf_peptide[pepn];
					writeln("<b><big><tt>" + pepaa + "</tt></big></b> " +
						"(" + pepaa.length + " amino acids) aligns to:");

					alist = opener.pepsurf_alignment_list[ial];
					alist = highlightMismatches(alist);
					alist = alist.replace(/\,/g, "<br>");
					writeln("<ul>" + alist + "</ul>");
				}
			}

			writeln("</ul>");

		}
	}
</script>

</td></tr></table>

<form><input type="button" value="Close" onClick="window.close()">
</form>

</div>
</body>
</html>
