#!/usr/bin/python
#
#
######################################################
#  This script for IL prediction                      #
#                                                     #
#  Version 1.0                    date c: 15/12/09    #
#                                 date m: 15/12/09    #
#  LUU Tien Dao            (c) 2009-2012  IGBMC       #
#######################################################



print "Content-Type: text/html\n\n"


from libtools import files,dbpsycopg, system, images
import html

global cs, csystem
csystem = system.system()
cs = system.server()

db = dbpsycopg.postgres(system.db.MS2PH_DB,"user")
db.connect()


def select_amino_acids(id):
    htmlcode = """<select name="%s" id="%s">
        <option value="amino_acid" selected></option>
        <option value="Ala">Ala</option>
        <option value="Arg">Arg</option>
        <option value="Asn">Asn</option>
        <option value="Asp">Asp</option>
        <option value="Cys">Cys</option>
        <option value="Glu">Glu</option>
        <option value="Gln">Gln</option>
        <option value="Gly">Gly</option>
        <option value="His">His</option>
        <option value="Ile">Ile</option>
        <option value="Leu">Leu</option>
        <option value="Lys">Lys</option>
        <option value="Met">Met</option>
        <option value="Phe">Phe</option>
        <option value="Pro">Pro</option>
        <option value="Ser">Ser</option>
        <option value="Thr">Thr</option>
        <option value="Trp">Trp</option>
        <option value="Tyr">Tyr</option>
        <option value="Val">Val</option>
        </select>""" % (id,id)
    return htmlcode    

print """<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<HTML><HEAD><META http-equiv='content-type' content='text/html; charset=ISO-8859-1'>
<title>ILP prediction</title>"""
print """<link rel="stylesheet" type="text/css" href="%sresult.css">\n
         <script language="JavaScript" src="%sform_func.js" type="text/javascript"></script>""" % (cs.PATH_CSS,cs.PATH_HTML)

print """<script language="javascript" type="text/javascript">
        <!--
        if (navigator.appVersion.substring(0,1)>=3)
        {
        i1=new Image;
        i1.src='%sminus.gif';
        i2=new Image;
        i2.src='%splus.gif';
        }
        //-->
        </script>\n</head><body>""" % (cs.PATH_IMG,cs.PATH_IMG)

html.menu()

print """
    <div align='center' id='page'><h3 class='none'>Inductive Logic Programming Prediction<br></h3></div>
    <form name="custom_mutants" action="" onSubmit="Javascript:FormAction();">
            <input type="hidden" name="db" value="%s">
            <div  class="usermut" align="center">
            <table>
                <tr>
                    <td>Uniprot Accession number</td>
                    <td><input size="5" name="protid"> (e.g Q13496)</td>
                </tr>
                <tr>    
                    <td>Wild type residue</td>
                    <td>%s</td>
                </tr>
                <tr>
                    <td>Position</td>
                    <td><input size="5" name="pos"></td>
                </tr>
                <tr>    
                    <td>Mutant residue</td>
                    <td>%s</td>
                </tr>
                <tr>
                <td colspan="2" align="center"><p align="center">
                 <input type="button" onclick="javascript:prediction(this.form.wt.value, this.form.pos.value, this.form.mut.value, this.form.db.value, this.form.protid.value);" class="button" value="Predict">
                 <input type="reset" value="Reset" class="button">
                 </p>
                 </td></tr>
            </table>
            </div>
            </form>""" % (system.db.MS2PH_DB, select_amino_acids('wt'), select_amino_acids('mut'), cs.serv)

print """<br /><br />
<img src="../images/web/list.jpg" /><a href="%scgi-bin/rules" target="_blank">List of ILP rules</a>
<br /><br />
<b>References:</b><br />
<br />
T.D. Luu, N.H. Nguyen, A. Friedrich, J. Muller, L. Moulinier, O. Poch (2010)
Discovering knowledge hidden in mutation data using Inductive Logic Programming. Manuscript in submission.<br />
[<a href='../download/SM2PHdb_ILP_Supplementary_Material.zip'>Supplementary material</a>]<br />
<br />
A. Friedrich, N. Garnier, N. Gagniere, N.H. Nguyen, L.P. Albou, V. Biancalana, E. Bettler,
G. Deleage, O. Lecompte, J. Muller, D. Moras, J.L. Mandel, T. Toursel,
L. Moulinier, O. Poch (2010), SM2PH-db: an interactive system for the integrated analysis of
phenotypic consequences of missense mutations in proteins involved in human genetic diseases.
Human Mutation, 31: 127-135. doi: 10.1002/humu.21155<br />
<br />
N. Bard, R. Bolze, E. Caron, F. Desprez, M. Heymann, A. Friedrich, L. Moulinier,
N.H. Nguyen, O. Poch, T. Toursel (2010)
Decrypthon grid - grid resources dedicated to neuromuscular disorders, Stud Health Technol Inform, 159, 124-133.<br />
<br />
"""

html.footbar()
db.disconnect()
print "</body>"
print "</html>"

