#!/usr/bin/perl -w

my $url = "http://www.google.com";
print "Location: $url\n\n";


#change the line above on Unix OS usually to: #!usr/bin/perl or wherever perl.exe lies
print "Content-type: text/html\n\n";
# ---------------------------------- Dependancies and Compatibilities --------------------------------------------------
# The program was written in Perl and tested on Apache HTTP server 2.0.53 on a Windows XP-pro-SP2 OS having
# ActiveState Perl 5.6 installed with Bioperl 1.4 modules. However it is expected that it works on
# Apache on Unix too. In Unix, it may be needed to open each file of the program with a text editor such as pico or nano 
# and save it again in Unix. This may be needed because the program was developed in Windows platforma and 
# some new line characters or some other characters may be meaningless to Unix system.


# Your application directory must have WRITE permissions because a temporary file upload may occur.
# It is recommended that you put the application folder in htdocs folder on Apache and permit CGI and Perl 
# script execution by for example an htaccess file or by configuring your server.
# Notice: This script uses Bio::Restriction::EnzymeCollection module of Bioperl. So this module must be installed 
# for this script to work.

# The program was tested from a Windows XP-pro-SP2 platform using Internet Explorer 6 and Netscape Navigator 4.
# Best display feature are expected on Internet Explorer 4.0 or higher.
# However, it is expected that it works well with newer versions of most other web browsers.

# Apache is available from http://www.apache.org
# A stable version of Perl can be downloaded from http://www.activestate.com
# Bioperl modules can be downloaded from http://www.bioperl.org 

# -------------------------------------------- IncisiEnz Summary ----------------------------------
# IncisiEnz is a web tool for restriction enzyme analysis of DNA sequences.
# The name IncisiEnz comes from Incisions meaning Cuts. The name was coined by me (Mohammadreza Rezailashkajani) 
# and at least a Google search returned no similar names on the web.
# The program allows the user to:
# 1) enetr sequence data in simple format or upload a sequence in FASTA format;
# 2) choose one or more restriction enzymes out of a list of enzymes produced from the default collection
#  of Bioperl  
# 3) perform a restriction enzyme analysis and get a multi-view output

# IncisiEnz was developed by Mohammadreza Rezailashkajani as a student assessment project 
# for an online module in bioinformatics in School of Biological Sciences, University of Manchester.
# Contact: 
#     docreza@yahoo.com     and          Rezailashkajani.Mohammadreza@postgrad.manchester.ac.uk


# -------------------------------- Acknowledgements -----------------------------------------------
# Bioperl modules from http://www.bioperl.org was used to:
# 1) make a reference list of restriction enzymes;
# 2) perform restriction enzyme analyses; and
# 3) make a sequence object model from file or directly from strings.

# I also wish to thank valuable comments from my classmates in Biocomputing Module
# in University of Manchester.

# For a multiple-digest, I used some examples taught by Robert Edwards [redwards@pub.open-bio.org] in 
# http://bioperl.org/pipermail/bioperl-guts-l/2003-December/015775.html in addition to documentation 
# for Bio::Restriction::Analysis.

# --------------------------------------------------------------------------------------------------


# ----------------------------------- Input Form Description --------------------------------------
# Here an input form is created with the following features:
# 	1) A text box (txtSeqName) and a text area (txtSeqContent) to accept a sequence description and content 
# 	  in simple format
# 	2) A file object (fileSeq) to allow user to upload a sequence file in FASTA format
#  	 FASTA format is a sequence as the following one in a text file saved in any name with .FASTA extention 
# 	 (any_name.FASTA). Example:

#  			>Sequence description
#  			ATCGGGGCCAGGGGGGGGATTACTGACCTAGCGATCATCGGGGCCAGGGGGGGGATTACTGACCTAGCGATCATCGGGGCC
#			ATCGGGGCCAGGGGGGGGATTACTGACCTAGCGATCATCGGGGCCAGGGGGGGGATTACTGACCTAGCGATC


# 		**Either a sequence must be pasted into the textarea OR a FASTA sequenc file should be uploaded 
# 		  If a file is uploaded the sequence pasted into the textarea will be neglected.
# 	3) A checkbox (ckCleaner) to allow user to turn on PowerCleaner which will clean all non-atcg characters
#	4) A checkbox (ckCircular) to allow user to tell the program if the sequence is circular.
# 	5) A list (cboEnzymes) which is populated from a colection of enzymes and allows user to choose more than one
# 	  enzyme by ctrl+click. At least one enzyme must be selected.
# 	6) Three checkboxes (ckViewLength, ckViewSeq and ckViewMap) to  allow user to choose different analysis result views.


# The form data will be submitted to analyzer.pl in the same directory as this form where 
# main processing and analysis will happen and an HTML ouput will be sent to the user.


# ------------------------------------ Main Script --------------------------------------------

# use print<< command for out-printing multiline strings in Perl.
print <<EOF;
<HTML>
<HEAD>
<TITLE>IncisiEnz (Restriction Enzyme Analysis)</TITLE>
</HEAD>
<body style="font-family:Arial; font-size:13px" bgcolor="#FFFFFF" link="#0033CC" vlink="#990099" alink="#CC3300" leftmargin="3" topmargin="0" marginwidth="4" marginheight="0">

<!-- ================= A simple navigation bar to browse around the web application ===================== -->
<table width="100%"  style="font-family:Tahoma, Arial; font-size:14px; font-weight:bold" border="0" cellpadding="2" cellspacing="0" bordercolor="#CC9999" bgcolor="#FFFFFF">
  <tr>
    <td valign='middle' bgcolor="#FFFFFF"><img src="../../rest_html/images/logo_incisienz.gif" width="133" height="45">  </td>
  </tr>
  <tr>
    <td bgcolor="#0066FF"> <font color="#FFFFFF"><a href="../../rest_html/home.htm"><font color="#FFFFFF" size="2">
            Home</font> </a><font size="2"> | <a href="IncisiEnz.pl"><font color="#FFFFFF">New
       Restriction Analysis </font> </a> | <a href="../../rest_html/help_IncisiEnz.htm"><font color="#FFFFFF">Help</font></a> </font> </font></td>
  </tr>
</table>
 <!--  ==================================== End navigation bar ===============================  -->
 

 <!--  ==================================== Start input form production ======================= -->

<form action="analyzer.pl" method="post" enctype="multipart/form-data" name="frmRestrict" id="frmRestrict">
  <p>
    Sequence name: <a target='_blank' href='../../rest_html/help_IncisiEnz.htm#input'>[?]</a><br> 
    <input type="text" name="txtSeqName" value="Seq 1"/> 
<br><br>
 Paste your sequence here in simple format:<a target='_blank' href='../../rest_html/help_IncisiEnz.htm#input'>[?]</a>
  <br>
    <textarea name="txtSeqContent" cols="70" rows="4"></textarea>

<p>Or alternatively browse to upload a sequence file in FASTA format <i>(the sequence pasted above will be neglected)</i>.<a target='_blank' href='../../rest_html/help_IncisiEnz.htm#input'>[?]</a>
    <br><input name="fileSeq" size="50" type="file" id="fileSeq" />
    <br><input type="checkbox"  value="isCircular" name="ckCircular">Sequence is <b>circular</b>.<a target='_blank' href='../../rest_html/help_IncisiEnz.htm#seqoptions'>[?]</a><br><input type="checkbox"  value="doClean" name="ckCleaner"><b>Turn on <i>PowerCleaner!</i> </b>(Cleans all non-atcg characters from the above-pasted/uploaded sequence.)<a target='_blank' href='../../rest_html/help_IncisiEnz.htm#seqoptions'>[?]</a>
 <br><br>Select one or more enzymes (Ctrl+click):<a target='_blank' href='../../rest_html/help_IncisiEnz.htm#enzselect'>[?]</a><br>
    <select name="cboEnzymes" size="8"  multiple="multiple">
EOF


# Define an enzyme collection using Bio::Restriction::EnzymeCollection module of Bioperl. 
# This collection usually contains around 500 type II enzymes.
# Instead, you can define your enzyme collection using Bio::Restriction::IO module of Bioperl and 
# an enzyme file from REBASE at http://rebase.neb.com/rebase
use Bio::Restriction::EnzymeCollection;
my $enzCollection=Bio::Restriction::EnzymeCollection->new();

# Populate the list with enzyme names.
foreach $enz($enzCollection->available_list){
	print "<option value=\"$enz\">$enz</option>";
}
print <<FINI;           
    </select>
<br><input type="checkbox" checked value="showLength" name="ckViewLength">Show Lengths view. <input type="checkbox"  checked value="showSeq" name="ckViewSeq">Show Sequence view <input type="checkbox" checked  value="showMap" name="ckViewMap">Show Map view <a target='_blank' href='../../rest_html/help_IncisiEnz.htm#viewoptions'>[?]</a><br>    <input type="submit"  name="Submit" value="Incise Sequence!" />
</p>
</form></BODY>
<p align='center'>This web tool is best viewed by Internet Explorer 4.0, Netscape Navigator 4.0, or higher-version browsers.</p>
</HTML>
 <!--  ==================================== End input form production ======================= -->

FINI

