File: MolDepict.py

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (48 lines) | stat: -rw-r--r-- 1,678 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from mod_python import apache
import sys, os, tempfile, urllib
from WebUtils import General

General._version = "1.0.0"


def page(req, smiles='', width=300, height=300, highlight='[]', numbers=0, **kwargs):
  req.content_type = 'text/html'
  page = General.ConstructHtmlHeader(title='RD Depict')

  if smiles:
    uSmiles = urllib.quote_plus(smiles)
    uHighlight = urllib.quote_plus(highlight)
    url = '/RDExtras/MolImage.py/svg?smiles=%s&height=%s&width=%s&highlight=%s&numbers=%s' % (
      uSmiles, height, width, uHighlight, numbers)
    imgUrl = '/RDExtras/MolImage.py/gif?smiles=%s&height=%s&width=%s&useCactvs=1' % (uSmiles,
                                                                                     height, width)

    page += """<center>
    <table>
    <tr>
      <td><embed src="%s" Name="SVGEmbed" width=%s height=%s type="image/svg-xml">
      <td><img src="%s" width=%s height=%s></td>
    </tr>
    </table>
    </center>""" % (url, width, height, imgUrl, width, height)
    page += '<center><b>SMILES:</b>%s</center>' % smiles
  if not smiles:
    smiles = '""'
  if not numbers or numbers == 'off':
    checked = ""
  else:
    checked = "checked"
  page += """<center>
  <form action="/RDExtras/MolDepict.py/page">
  <input type=text name="smiles" value=%s size=80>
  <input type=submit Value="Depict">
  <br><input type=checkbox name="numbers" %s> Numbers
  <input type=hidden name="width" value=%s>
  <input type=hidden name="height" value=%s>
  <input type=hidden name="highlight" value=%s>
  </center>
  """ % (smiles, checked, width, height, highlight)

  page += General.ConstructHtmlFooter(includeRestart=0, logoutText='')

  return page