#!/bin/csh -f

# Make the example web pages for AstexViewer

# check to see if $CCP4 has been setup.
if (${?CCP4} == 0) then
  echo ' The CCP4 setup script has not been sourced or has a problem' 1>&2
  exit 1
endif 

################
# Example 1
################

cat  > example1.html <<EOF
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <title>AstexViewer Applet Example</title>
  </head>
  <body BGCOLOR="#FFFFFF" TEXT="#000000"
    LINK="#0000FF" VLINK="#000080" ALINK="#FF0000">

<center>
    <h1>AstexViewer Applet Example</h1>

<center><b><font size=+2>Protein/Ligand Complex</font></b></center>

<p><i>This page was generated by the CCP4 configure, to set system-specific
"archive" and "codebase" attributes in the applet. If you are viewing this
page on a system other than the one it was generated on then you may
experience problems.</i></p>

<table border=0>
<tr><td>
<applet archive="src/AstexViewer.jar"
        code="MoleculeViewerApplet"
        codebase="${CCP4}/"
        width="600" height="400">
<param name="molecule1" value="protein.pdb">
<!-- There is a problem with the ligand file: <param name="molecule2" value="ligand.pdb"> -->
<param name="map" value="fofc.map">
<param name="center" value="X:1">
<param name="wide" value="X:1"></applet></td></tr>
</table>
<img src=astex_logo.gif>
</center>

<p>
    <hr>
    <address><a href="mailto:m.hartshorn@astex-technology.com">Mike Hartshorn</a></address>
  </body>
</html>
EOF

################
# Example 2
################

cd trypsin
cat  > index.html <<EOF
<html>
<head>
<title>Trypsin/Benzamidine</title>
<SCRIPT LANGUAGE="JavaScript">

<!-- Hide script
function sendCommand(){
	var s = document.dummy.command.value;
        document.av.execute(s);
}

function execute(s){
	document.av.execute(s);
	//window.status = s;
}

function changecontour(obj, map, contour){
  window.status = 'bob ' + obj[0].value + ' ' +obj.length;
	for(var i = 0; i < obj.length; i++){
		if(obj[i].selected){
			var s = 'map ' + map + ' contour ' + contour + ' ' + obj[i].value + ';';
			window.status = s;
			execute(s);
		}
	}
}

function togglecontour(map, contour){
  var s = 'map ' + map + ' contour ' + contour + ' toggle;';
  window.status = s;
  execute(s);
}

function togglestructure(name){
  execute('molecule display ' + name + ' toggle;');
}

function proteinsurface(name, colour, obj){
  execute('object display ' + name + '_surf toggle;');

  if(obj.checked){
	if(!obj.generated){
		execute('select aminoacid and sphere 8 around molecule ligand*; surface ' + name + '_surf ' + colour + ' aminoacid and sphere 12 around molecule ligand*; select none;');
		obj.generated = 1;
	}
  }
}

function ligandsurface(name, colour, obj){
  execute('object display ' + name + '_surf toggle;');

  if(obj.checked){
	if(!obj.generated){
		execute('surface ' + name + '_surf ' + colour + ' molecule ' +  name + '; select none;');
		obj.generated = 1;
	}
  }
}
// End script hiding -->

</SCRIPT>
</head>
<body>

<h1>
<table cellpadding=8>
<tr>
<td valign=top><img src="../astex_logo.gif"></td>
<td>
<b><font size=+2>AstexViewer Example Web Page
</td>
</tr>
</table>
</h1>

<p><i>This page was generated by the CCP4 configure, to set system-specific
"archive" and "codebase" attributes in the applet. If you are viewing this
page on a system other than the one it was generated on then you may
experience problems.</i></p>

<form name=form>
<table width=95% height=90%>
<tr>
<td valign=top>
<h2>Trypsin/Benzamidine</h2>
<b>Proteins</b><br>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td>
<input checked type=checkbox name=protein0
onclick="togglestructure('protein0')">
<input type=checkbox name=protein0_surf
onclick="proteinsurface('protein0', 'green', document.form.protein0_surf)">
</td><td>1p3_final</td>
</table>
<p>
<b>Ligands</b><br>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td><font size=-1>
<input checked type=checkbox name=ligand0
onclick="togglestructure('ligand0')">
<input type=checkbox name=ligand0_surf
onclick="ligandsurface('ligand0', 'yellow', document.form.ligand0_surf)">
</font>
</td>
<td>
<font size=-1>AT000045_001_01</font>
</td>
</tr>
<tr>
<td><font size=-1>
<input  type=checkbox name=ligand1
onclick="togglestructure('ligand1')">
<input type=checkbox name=ligand1_surf
onclick="ligandsurface('ligand1', 'orange', document.form.ligand1_surf)">
</font>
</td>
<td>
<font size=-1>AT000045_001_02</font>
</td>
</tr>
<tr>
<td><font size=-1>
<input  type=checkbox name=ligand2
onclick="togglestructure('ligand2')">
<input type=checkbox name=ligand2_surf
onclick="ligandsurface('ligand2', 'cyan', document.form.ligand2_surf)">
</font>
</td>
<td>
<font size=-1>AT000045_001_03</font>
</td>
</tr>
<tr>
<td><font size=-1>
<input  type=checkbox name=ligand3
onclick="togglestructure('ligand3')">
<input type=checkbox name=ligand3_surf
onclick="ligandsurface('ligand3', 'purple', document.form.ligand3_surf)">
</font>
</td>
<td>
<font size=-1>AT000045_001_04</font>
</td>
</tr>
</table><p>
<p><b>Maps</b><br><table border=0 cellpadding=2 cellspacing=0 name=contours>
<tr>
<td colspan=100>1p3_final</td>
</tr>
<tr>
<td bgcolor=red>
<select name=cmap00 onchange='changecontour(document.form.cmap00, "map0", 0)'>
<option  value='5.0'>+5.0
<option  value='4.9'>+4.9
<option  value='4.8'>+4.8
<option  value='4.7'>+4.7
<option  value='4.6'>+4.6
<option  value='4.5'>+4.5
<option  value='4.4'>+4.4
<option  value='4.3'>+4.3
<option  value='4.2'>+4.2
<option  value='4.1'>+4.1
<option  value='4.0'>+4.0
<option  value='3.9'>+3.9
<option  value='3.8'>+3.8
<option  value='3.7'>+3.7
<option  value='3.6'>+3.6
<option  value='3.5'>+3.5
<option  value='3.4'>+3.4
<option  value='3.3'>+3.3
<option  value='3.2'>+3.2
<option  value='3.1'>+3.1
<option selected value='3.0'>+3.0
<option  value='2.9'>+2.9
<option  value='2.8'>+2.8
<option  value='2.7'>+2.7
<option  value='2.6'>+2.6
<option  value='2.5'>+2.5
<option  value='2.4'>+2.4
<option  value='2.3'>+2.3
<option  value='2.2'>+2.2
<option  value='2.1'>+2.1
<option  value='2.0'>+2.0
<option  value='1.9'>+1.9
<option  value='1.8'>+1.8
<option  value='1.7'>+1.7
<option  value='1.6'>+1.6
<option  value='1.5'>+1.5
<option  value='1.4'>+1.4
<option  value='1.3'>+1.3
<option  value='1.2'>+1.2
<option  value='1.1'>+1.1
<option  value='1.0'>+1.0
<option  value='0.9'>+0.9
<option  value='0.8'>+0.8
<option  value='0.7'>+0.7
<option  value='0.6'>+0.6
<option  value='0.5'>+0.5
<option  value='0.4'>+0.4
<option  value='0.3'>+0.3
<option  value='0.2'>+0.2
<option  value='0.1'>+0.1
<option  value='0.0'>+0.0
<option  value='-0.1'>-0.1
<option  value='-0.2'>-0.2
<option  value='-0.3'>-0.3
<option  value='-0.4'>-0.4
<option  value='-0.5'>-0.5
<option  value='-0.6'>-0.6
<option  value='-0.7'>-0.7
<option  value='-0.8'>-0.8
<option  value='-0.9'>-0.9
<option  value='-1.0'>-1.0
<option  value='-1.1'>-1.1
<option  value='-1.2'>-1.2
<option  value='-1.3'>-1.3
<option  value='-1.4'>-1.4
<option  value='-1.5'>-1.5
<option  value='-1.6'>-1.6
<option  value='-1.7'>-1.7
<option  value='-1.8'>-1.8
<option  value='-1.9'>-1.9
<option  value='-2.0'>-2.0
<option  value='-2.1'>-2.1
<option  value='-2.2'>-2.2
<option  value='-2.3'>-2.3
<option  value='-2.4'>-2.4
<option  value='-2.5'>-2.5
<option  value='-2.6'>-2.6
<option  value='-2.7'>-2.7
<option  value='-2.8'>-2.8
<option  value='-2.9'>-2.9
<option  value='-3.0'>-3.0
<option  value='-3.1'>-3.1
<option  value='-3.2'>-3.2
<option  value='-3.3'>-3.3
<option  value='-3.4'>-3.4
<option  value='-3.5'>-3.5
<option  value='-3.6'>-3.6
<option  value='-3.7'>-3.7
<option  value='-3.8'>-3.8
<option  value='-3.9'>-3.9
<option  value='-4.0'>-4.0
<option  value='-4.1'>-4.1
<option  value='-4.2'>-4.2
<option  value='-4.3'>-4.3
<option  value='-4.4'>-4.4
<option  value='-4.5'>-4.5
<option  value='-4.6'>-4.6
<option  value='-4.7'>-4.7
<option  value='-4.8'>-4.8
<option  value='-4.9'>-4.9
<option  value='-5.0'>-5.0
</select>
</td>
<td>
<input type=checkbox checked name=map00 onclick='togglecontour("map0", 0)'>
</td>
<td bgcolor=orange>
<select name=cmap01 onchange='changecontour(document.form.cmap01, "map0", 1)'>
<option  value='5.0'>+5.0
<option  value='4.9'>+4.9
<option  value='4.8'>+4.8
<option  value='4.7'>+4.7
<option  value='4.6'>+4.6
<option  value='4.5'>+4.5
<option  value='4.4'>+4.4
<option  value='4.3'>+4.3
<option  value='4.2'>+4.2
<option  value='4.1'>+4.1
<option  value='4.0'>+4.0
<option  value='3.9'>+3.9
<option  value='3.8'>+3.8
<option  value='3.7'>+3.7
<option  value='3.6'>+3.6
<option  value='3.5'>+3.5
<option  value='3.4'>+3.4
<option  value='3.3'>+3.3
<option  value='3.2'>+3.2
<option  value='3.1'>+3.1
<option  value='3.0'>+3.0
<option  value='2.9'>+2.9
<option  value='2.8'>+2.8
<option  value='2.7'>+2.7
<option  value='2.6'>+2.6
<option  value='2.5'>+2.5
<option  value='2.4'>+2.4
<option  value='2.3'>+2.3
<option  value='2.2'>+2.2
<option  value='2.1'>+2.1
<option selected value='2.0'>+2.0
<option  value='1.9'>+1.9
<option  value='1.8'>+1.8
<option  value='1.7'>+1.7
<option  value='1.6'>+1.6
<option  value='1.5'>+1.5
<option  value='1.4'>+1.4
<option  value='1.3'>+1.3
<option  value='1.2'>+1.2
<option  value='1.1'>+1.1
<option  value='1.0'>+1.0
<option  value='0.9'>+0.9
<option  value='0.8'>+0.8
<option  value='0.7'>+0.7
<option  value='0.6'>+0.6
<option  value='0.5'>+0.5
<option  value='0.4'>+0.4
<option  value='0.3'>+0.3
<option  value='0.2'>+0.2
<option  value='0.1'>+0.1
<option  value='0.0'>+0.0
<option  value='-0.1'>-0.1
<option  value='-0.2'>-0.2
<option  value='-0.3'>-0.3
<option  value='-0.4'>-0.4
<option  value='-0.5'>-0.5
<option  value='-0.6'>-0.6
<option  value='-0.7'>-0.7
<option  value='-0.8'>-0.8
<option  value='-0.9'>-0.9
<option  value='-1.0'>-1.0
<option  value='-1.1'>-1.1
<option  value='-1.2'>-1.2
<option  value='-1.3'>-1.3
<option  value='-1.4'>-1.4
<option  value='-1.5'>-1.5
<option  value='-1.6'>-1.6
<option  value='-1.7'>-1.7
<option  value='-1.8'>-1.8
<option  value='-1.9'>-1.9
<option  value='-2.0'>-2.0
<option  value='-2.1'>-2.1
<option  value='-2.2'>-2.2
<option  value='-2.3'>-2.3
<option  value='-2.4'>-2.4
<option  value='-2.5'>-2.5
<option  value='-2.6'>-2.6
<option  value='-2.7'>-2.7
<option  value='-2.8'>-2.8
<option  value='-2.9'>-2.9
<option  value='-3.0'>-3.0
<option  value='-3.1'>-3.1
<option  value='-3.2'>-3.2
<option  value='-3.3'>-3.3
<option  value='-3.4'>-3.4
<option  value='-3.5'>-3.5
<option  value='-3.6'>-3.6
<option  value='-3.7'>-3.7
<option  value='-3.8'>-3.8
<option  value='-3.9'>-3.9
<option  value='-4.0'>-4.0
<option  value='-4.1'>-4.1
<option  value='-4.2'>-4.2
<option  value='-4.3'>-4.3
<option  value='-4.4'>-4.4
<option  value='-4.5'>-4.5
<option  value='-4.6'>-4.6
<option  value='-4.7'>-4.7
<option  value='-4.8'>-4.8
<option  value='-4.9'>-4.9
<option  value='-5.0'>-5.0
</select>
</td>
<td>
<input type=checkbox  name=map01 onclick='togglecontour("map0", 1)'>
</td>
<td bgcolor=blue>
<select name=cmap02 onchange='changecontour(document.form.cmap02, "map0", 2)'>
<option  value='5.0'>+5.0
<option  value='4.9'>+4.9
<option  value='4.8'>+4.8
<option  value='4.7'>+4.7
<option  value='4.6'>+4.6
<option  value='4.5'>+4.5
<option  value='4.4'>+4.4
<option  value='4.3'>+4.3
<option  value='4.2'>+4.2
<option  value='4.1'>+4.1
<option  value='4.0'>+4.0
<option  value='3.9'>+3.9
<option  value='3.8'>+3.8
<option  value='3.7'>+3.7
<option  value='3.6'>+3.6
<option  value='3.5'>+3.5
<option  value='3.4'>+3.4
<option  value='3.3'>+3.3
<option  value='3.2'>+3.2
<option  value='3.1'>+3.1
<option  value='3.0'>+3.0
<option  value='2.9'>+2.9
<option  value='2.8'>+2.8
<option  value='2.7'>+2.7
<option  value='2.6'>+2.6
<option  value='2.5'>+2.5
<option  value='2.4'>+2.4
<option  value='2.3'>+2.3
<option  value='2.2'>+2.2
<option  value='2.1'>+2.1
<option  value='2.0'>+2.0
<option  value='1.9'>+1.9
<option  value='1.8'>+1.8
<option  value='1.7'>+1.7
<option  value='1.6'>+1.6
<option  value='1.5'>+1.5
<option  value='1.4'>+1.4
<option  value='1.3'>+1.3
<option  value='1.2'>+1.2
<option  value='1.1'>+1.1
<option  value='1.0'>+1.0
<option  value='0.9'>+0.9
<option  value='0.8'>+0.8
<option  value='0.7'>+0.7
<option  value='0.6'>+0.6
<option  value='0.5'>+0.5
<option  value='0.4'>+0.4
<option  value='0.3'>+0.3
<option  value='0.2'>+0.2
<option  value='0.1'>+0.1
<option  value='0.0'>+0.0
<option  value='-0.1'>-0.1
<option  value='-0.2'>-0.2
<option  value='-0.3'>-0.3
<option  value='-0.4'>-0.4
<option  value='-0.5'>-0.5
<option  value='-0.6'>-0.6
<option  value='-0.7'>-0.7
<option  value='-0.8'>-0.8
<option  value='-0.9'>-0.9
<option  value='-1.0'>-1.0
<option  value='-1.1'>-1.1
<option  value='-1.2'>-1.2
<option  value='-1.3'>-1.3
<option  value='-1.4'>-1.4
<option  value='-1.5'>-1.5
<option  value='-1.6'>-1.6
<option  value='-1.7'>-1.7
<option  value='-1.8'>-1.8
<option  value='-1.9'>-1.9
<option selected value='-2.0'>-2.0
<option  value='-2.1'>-2.1
<option  value='-2.2'>-2.2
<option  value='-2.3'>-2.3
<option  value='-2.4'>-2.4
<option  value='-2.5'>-2.5
<option  value='-2.6'>-2.6
<option  value='-2.7'>-2.7
<option  value='-2.8'>-2.8
<option  value='-2.9'>-2.9
<option  value='-3.0'>-3.0
<option  value='-3.1'>-3.1
<option  value='-3.2'>-3.2
<option  value='-3.3'>-3.3
<option  value='-3.4'>-3.4
<option  value='-3.5'>-3.5
<option  value='-3.6'>-3.6
<option  value='-3.7'>-3.7
<option  value='-3.8'>-3.8
<option  value='-3.9'>-3.9
<option  value='-4.0'>-4.0
<option  value='-4.1'>-4.1
<option  value='-4.2'>-4.2
<option  value='-4.3'>-4.3
<option  value='-4.4'>-4.4
<option  value='-4.5'>-4.5
<option  value='-4.6'>-4.6
<option  value='-4.7'>-4.7
<option  value='-4.8'>-4.8
<option  value='-4.9'>-4.9
<option  value='-5.0'>-5.0
</select>
</td>
<td>
<input type=checkbox  name=map02 onclick='togglecontour("map0", 2)'>
</td>
</tr>
</table>
</td>
<td valign=top>
<applet width="700" height="700"
archive="src/AstexViewer.jar"
code="MoleculeViewerApplet"
codebase="${CCP4}/"
name="av">
<param name="script" value="
molecule load protein0 '1p3_final.pdb';
molecule load ligand0 'AT000045_001_01.pdb';
molecule load ligand1 'AT000045_001_02.pdb';
molecule load ligand2 'AT000045_001_03.pdb';
molecule load ligand3 'AT000045_001_04.pdb';
map load map0 'fofc.map';
map map0 contour 0 off;
map map0 contour 1 off;
map map0 contour 2 off;
map map0 contour 0 3;
map map0 contour 1 2;
map map0 contour 2 -2;
map map0 contour 0 on;
molecule display * off;
molecule display protein0 on;
molecule display ligand0 on;
center molecule ligand*;
display wide molecule ligand*;
colour purple (atom C* and molecule protein*) and not sphere 12 around molecule ligand*;
#colour grey (molecule protein* and (atom C or atom CA));
">
</applet></td>
</tr>

</table>
</form>
EOF


exit 0
