Download the Presentation As

Download the Presentation As

AJAX and the OpenEye Tools Andrew Dalke / Dalke Scientific Göteborg, Sweden <html> ... <img src="/depict.cgi?smiles=CC(=O)Oc1ccccc1C(=O)O" /> ... </html> http server CGI wrapper depictor <html> ... <img src="/depict.cgi?smiles=CC(=O)Oc1ccccc1C(=O)O" /> ... </html> “Web Application http server Stack” CGI wrapper Ruby on Rails Django { depictor TurboGears <html> ... <img src="/depict?smiles=CC(=O)Oc1ccccc1C(=O)O" /> ... </html> TurboGears “depict” handler OEChem/ogham Google “OE8BitImage to PNG” for pointers of how to use Ogham’s Python interface <form action="/depict"> Enter SMILES: <input type="text" name="smiles"> </form> submit form, server responds with an image: <form action="/show_depict"> Enter SMILES: <input type="text" name="smiles"> </form> server could respond with HTML <form action="show_depict"> Enter SMILES: <input type="text" name="smiles"> </form> <img src="/depict?smiles=CCC12CCC3C%28C1CCC2%28C%23C% 29O%29CCC4%3DCC%28%3DO%29CCC34" client requests the image from the server Improved interactivity Use Javascript to change the image src URL instead of doing two round-trips to the server. demo1 <form action="http://localhost:8080/depict" onsubmit="..Javascript code to update the image.."> Enter SMILES: <input type="text" size="40" name="smiles" id="smiles"> </form> <img src="http://localhost:8080/depict?smiles=" id="depiction"> <html> <head> <script type="text/javascript"> var update_image = function (x) { var smiles = document.getElementById("smiles").value; var depiction_ele = document.getElementById("depiction"); depiction_ele.src = "http://localhost:8080/depict?smiles=" + escape(smiles); return false; } </script> </head> <body> <form action="http://localhost:8080/depict" onsubmit="return update_image()"> Enter SMILES: <input type="text" size="40" name="smiles" id="smiles"> </form> <img src="http://localhost:8080/depict?smiles=" id="depiction"> </body> </html> <html> <head> <script type="text/javascript"> var update_image = function (x) { var smiles = document.getElementById("smiles").value; var depiction_ele = document.getElementById("depiction"); depiction_ele.src = "http://localhost:8080/depict?smiles=" + escape(smiles); return false; } </script> </head> <body> <form action="http://localhost:8080/depict" onsubmit="return update_image()"> Enter SMILES: <input type="text" size="40" name="smiles" id="smiles"> </form> <img src="http://localhost:8080/depict?smiles=" id="depiction"> </body> </html> This is out-dated! New things in the last 10 years: - better support for HTML components (MVC) - separation of content (HTML) from actions (Javascript) - mostly standardized cross-browser support for events - Javascript libraries to simplify development (and work around browser bugs) jQuery, MochiKit, YUI, Dojo, Prototype, Script.aculo.us ... <html> <head> <script type="text/javascript" src="jquery-1.2.3.js"></script> <script type="text/javascript"> $(document).ready(function() { $("form").submit(function() { jQuery $("#depiction").attr("src", "http://localhost:8080/depict?smiles=" + escape($("#smiles").val())); return false; }); }); </script> </head> <body> <form action="http://localhost:8080/depict"> Enter SMILES: <input type="text" size="40" name="smiles" id="smiles"> </form> <img src="http://localhost:8080/depict?smiles=" id="depiction"> </body> </html> More Interactive Update after every key event demo2 <html> <head> <script type="text/javascript" src="static/javascript/Mochikit.js"></script> <script type="text/javascript" src="static/javascript/jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { Called for each $("#smiles").keydown(function() { callLater(0, update_image); “key down” event }); }); “callLater” from MochiKit var update_image = function () { $("#depiction").attr("src", "http://localhost:8080/depict?smiles=" + escape($("#smiles").val())); } </script> </head> <body> <form action="http://localhost:8080/depict"> Enter SMILES: <input type="text" size="40" name="smiles" id="smiles"> </form> <img src="http://localhost:8080/depict?smiles=" id="depiction"> </body> </html> JSON requests Also show the IUPAC name as the SMILES is being typed Javascript can request a new document from the server http://localhost:8080/smi2name?smiles=c1ccccc1O Content-Type: text/javascript {"status": "valid", "name": "phenol"} demo3 <body> <form action="http://localhost:8080/depict"> Enter SMILES: <input type="text" size="40" name="smiles" id="smiles"> </form> <img src="http://localhost:8080/depict?smiles=" id="depiction"><br> Name: <span id="compound_name"></span> </body> $(document).ready(function() { $("#smiles").keydown(function() { callLater(0, update_display); }); }); var update_display = function () { var smiles = $("#smiles").val(); $("#depiction").attr("src", "http://localhost:8080/depict?smiles=" + escape(smiles)); var d = loadJSONDoc("http://localhost:8080/smi2name", {smiles: smiles}); d.addCallback(show_compound_name); } var show_compound_name = function(smi2name_result) { var color = "black"; if (smi2name_result.status == "invalid") { color = "red"; } $("#compound_name").text(smi2name_result.name).css( "color", color); } smi2name in TurboGears @expose(format="json") def smi2name(self, smiles): mol = OEGraphMol() if OEParseSmiles(mol, smiles): status = "valid" else: status = "invalid" name = oeiupac.OECreateIUPACName(mol) return dict(status=status, name=name) Demo application Layout / CSS Transparent image map (updated via AJAX) Atom region mouseover moves the highlight image Atom selections drawn with a translucent image Ogham depiction.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    20 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us