#!/bin/sh
#		mast.sh <pssm_file> <ac>
#	Set up the mast search, requires POST
#	NOTE: See the mast form at
#	http://meme.sdsc.edu/meme/website/mast.html
#	NOTE: Don't use blocks version because blk2pssm was already run
#		and catfile.sh location has to be blocks-bin

#
if [ $2 ]; then
  AC=$2
else
  AC="Blocks"
fi
if [ $1 ]; then

# ./blimps-bin/blk2pssm $1 $1.pssm M > /dev/null 2>&1
  echo "Content-type: text/html"
  echo
  echo "<HTML>";
  echo "<TITLE>Blocks to Mast</TITLE>";
  echo "<H1><IMG ALIGN=MIDDLE SRC=\"/blocks/icons/blocks.xbm\">";
  echo "MAST Search of Blocks Database Blocks</H1>";
  echo "<A HREF=\"http://meme.sdsc.edu/\">";
  echo "<IMG SRC=\"http://www.sdsc.edu/images/logo.gif\"></A>";
  echo "<HR>";
  echo "MAST searches blocks against a sequence database at SDSC.<BR>";
  echo "Results are returned via EMAIL.<BR>";
  echo "See the <A HREF=\"/blocks-bin/catfile.sh?$1\">MAST PSSM</A>";
  echo "made from the blocks.<HR>";

  echo "<FORM ENCTYPE = \"multipart/form-data\" METHOD = \"POST\"";
  echo "ACTION=\"http://meme.sdsc.edu/meme/website/cgi-bin/mast.cgi\">";
  echo "Enter your complete EMAIL address for MAST search results:\n";
  echo "<INPUT SIZE = 40 NAME = \"address\"> ";
# echo "<INPUT TYPE = \"HIDDEN\" NAME = \"subject\" VALUE = \"$AC\">";
#		No spaces, slashes, etc allowed in "inline_name" ...
  echo "<INPUT TYPE = \"HIDDEN\" NAME = \"inline_name\" VALUE = \"$AC\">";
  echo "<INPUT TYPE = \"HIDDEN\" NAME = \"inline_motifs\" VALUE = \"";
  cat "$1"
  echo "\">";
  echo "<P>\n";

#	mast.in is edited from the mast.html form, remove the above fields
  cat ./mast.in
fi

#\rm $1.pssm > /dev/null 2>&1
#
exit
