File: test.html

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 (187 lines) | stat: -rw-r--r-- 5,345 bytes parent folder | download | duplicates (8)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<html>
<head>

<script src="sorttable.js"></script>
<style type="text/css">
table.sortable a.sortheader {
    background-color:#eee;
    color:#666666;
    font-weight: bold;
    text-decoration: none;
    display: block;
}
table.sortable span.sortarrow {
    color: black;
    text-decoration: none;
}
</style>
<script src="chemdraw/chemdraw.js"></script>
<script>
  cd_includeWrapperFile("chemdraw/"); 
</script>


<title>RDKit XPCOM Demo</title>
</head>

<body>


<script>
var globalPluginSize=150;

function getRpcClient() {
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserAccess');
  return Components.classes['@mozilla.org/xml-rpc/client;1']
     .createInstance(Components.interfaces.nsIXmlRpcClient);
};

var xmlRpcClient;
var xmlRpcClientInited;
function getXmlRpc() {
  if (!xmlRpcClient) xmlRpcClient = getRpcClient();
  return xmlRpcClient;
}

var Listener = {
    onResult: function(client, ctxt, result) {
      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
      //result = result.QueryInterface(Components.interfaces.nsISupportsCString);
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

function molblockToPyMol(mb,id){
  var pymol = getXmlRpc();
  pymol.init("http://localhost:9123");
  var mbVar=pymol.createType(pymol.STRING,{});
  mbVar.data=mb;
  var idVar = pymol.createType(pymol.STRING,{});
  idVar.data=id;
  pymol.asyncCall(Listener,null,"loadMolBlock",[mbVar,idVar],2);
}



netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var cls = Components.classes["@rationaldiscovery.com/RDKit/base"].createInstance();
var baseI = cls.QueryInterface(Components.interfaces.IRDKit);

function formatNumber(number, numDecimals) { 
  var str = number.toString() 
  var point = str.indexOf(".") 
  var newstring = str.substring(0, Number(point) + Number(numDecimals) + 1);
  return(Number(newstring)) 
} 

function addMolToTable(table,mol){
  if(!mol) alert("bad molecule");

  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  var canSmi = mol.GetSmiles();
  var numDonors=mol.GetSmartsMatchCount('[$([#7,#8;!H0])]');
  var numAcceptors=mol.GetSmartsMatchCount('[$([#7,#8])]');
  var numRotatable=mol.GetSmartsMatchCount('[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]')
  var mw=mol.GetMW();
  var logp=mol.LogP();
  var mr = mol.MR();
  var url="data:chemical/smiles,"+canSmi;
  var rowIdx=GLOBAL_ROWS.length;
  var img = cd_getSpecificObjectTag("chemical/x-cdx",globalPluginSize,globalPluginSize,"cdp"+String(rowIdx+1),"",true,true,url);

  var numViolations=0;
  if(mw>500) numViolations++;
  if(logp>5) numViolations++;
  if(numDonors>5) numViolations++;
  if(numAcceptors>10) numViolations++;
  var row =new Array(img,numViolations,formatNumber(mw,3),formatNumber(logp,4),numDonors,numAcceptors,numRotatable,formatNumber(mr,4),canSmi)
  GLOBAL_ROWS[rowIdx]=row;
};

function addSmiles(smiles)
{
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserAccess");
  var mol = baseI.MolFromSmiles(smiles);
  var tbl = document.getElementById('moltable');
  if(!mol) alert("cannot construct molecule from smiles");
  addMolToTable(tbl,mol);
  var startp = 0;
  GLOBAL_START_POINT=startp;
  ts_refreshTable(tbl,startp,GLOBAL_TABLE_SIZE);
  ts_clearArrows(tbl);
    //mol.Generate3DCoords();
  //var mb = mol.GetMolBlock();
  //molblockToPyMol(mb,"Mol-"+tbl.rows.length);
  
}

function addSDFile(fileName,statusBox)
{
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  var suppl = baseI.SupplierFromSDFile(fileName);
  if(!suppl) alert("Could not open SD file");
  var tbl = document.getElementById('moltable');
  var mol;
  var startP = 0;
  while(!suppl.atEnd()){
    mol = suppl.next();
    addMolToTable(tbl,mol);
    if(statusBox){
     statusBox.value = GLOBAL_ROWS.length;
    }
  }
  GLOBAL_START_POINT=startP;
  GLOBAL_TABLE_SIZE=5
  ts_refreshTable(tbl,startP,GLOBAL_TABLE_SIZE);
  
  //var mb = mol.GetMolBlock();
  //molblockToPyMol(mb,mol.GetSmiles());
}


</script>

<form>
<table>
<tr>
  <td>
    <input name="textBox" size=80 value="c1cc(N)ccc1CC(=O)O">
    <input type=button onclick="addSmiles(form.textBox.value)" value="Grab">
  </td>
</tr>
<tr>
  <td>
    <input type=file name="sdBox" cols=80 size=80>
    <input type=button onclick="addSDFile(form.sdBox.value,form.numCompounds)" size=60 value="Grab SD">
  </td>
</tr>
</table>
Number of compounds loaded: <input name="numCompounds" value="0">
<br>
<input type=button id="prevButton" value="Previous" onClick="ts_decrementTable('moltable');">
<input type=button id="nextButton" value="Next" onClick="ts_incrementTable('moltable');">

<table class="sortable" id="moltable" border=1>
  <tr>
    <th></th>
    <th>Violations</th>
    <th>MW</th>
    <th>LogP</th>
    <th>NumDonors</th>
    <th>NumAcceptors</th>
    <th>NumRotatable</th>
    <th>MR</th>
    <th>smiles</th>
  </tr>
</table>

</form>


</body>
</html>