File: index.html

package info (click to toggle)
pymol 3.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 74,084 kB
  • sloc: cpp: 482,660; python: 89,328; ansic: 29,512; javascript: 6,792; sh: 84; makefile: 25
file content (97 lines) | stat: -rw-r--r-- 2,844 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
<html>
<head>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="-1" />
<title>Web Services - Sample 06: Using the JavaScript API</title>

<style><!--
a{text-decoration:none;
  padding: 1px;
  background-color: #dddddd}
--></style>

<script src="json2.js"></script> 
<script src="pymol.js"></script>

<script type="text/javascript">

var pymol = new PyMOL(); // create PyMOL object instance for server of this page

var cmd = pymol.cmd; // assign a global symbol for the PyMOL cmd API

function demoLoop() {
    cmd.reinitialize();
    cmd.load("$PYMOL_PATH/test/dat/1tii.pdb");
    cmd.show_as("cartoon");
    list = cmd.get_chains("polymer");
    for(var i=0;i<list.length;i++) {
        cmd.color("auto","chain "+list[i]);
    }
}
</script>

</head>
<body>

<h3>Web Services - Sample 06: Using the JavaScript API</h3>

<a href="javascript:void(0)" onclick="window.open('view-source:' + location.href)">view page source</a>

<a href="/apply/_quit">quit pymol</a>

(FireFox only: <a href="javascript:void(0)" onclick="window.open('view-source:' + location.href)">view page source</a>)

<p>The PyMOL JavaScript API re-exposes PyMOL's Python programming
interface directly to the JavaScript layer in an object-oriented way.</p>

<pre>
var pymol = new PyMOL(); // create PyMOL object instance for server of this page

var cmd = pymol.cmd; // assign a global symbol for the PyMOL cmd API
</pre>

<pre>
<a href="javascript:void(0)" onclick="cmd.load('$PYMOL_PATH/test/dat/pept.pdb')">cmd.load('$PYMOL_PATH/test/dat/pept.pdb)</a>

<a href="javascript:void(0)" onclick="cmd.zoom('pept///1/',0,0,0,1)">cmd.zoom('pept///1/',0,0,0,1)</a>

<a href="javascript:void(0)" onclick="cmd.zoom('pept',0,0,0,2)">cmd.zoom('all',0,0,0,2)</a>

</pre>

<p>This eliminates the need for encoding your PyMOL commands as URL query
strings and makes it possible to write JavaScript programs in your web page
which control PyMOL in much the same way Python programs do.</p>

<table>
<tr>
  <th align="left"><b>Python (inside PyMOL)</b></th>
  <th width="50">&nbsp;</th>
  <th align="left"><b>JavaScript (inside Browser)</b></th>
</tr>
<tr>
 <td valign="top"><pre>cmd.reinitialize()
cmd.load("$PYMOL_PATH/test/dat/1tii.pdb")
cmd.show_as("cartoon")
list = cmd.get_chains("polymer")
for chain in list:
    cmd.color("auto","chain "+chain)
</td><td>&nbsp;</td>
<td valign="top"><pre>cmd.reinitialize();
cmd.load("$PYMOL_PATH/test/dat/1tii.pdb");
cmd.show_as("cartoon");
list = cmd.get_chains("polymer");
for(var i=0;i&lt;list.length;i++) {
    cmd.color("auto","chain "+list[i]);
}
</pre>
<a href="javascript:void(0)" onClick="demoLoop()">Run this program</a>
</td>
</tr>
</table>

<a href="javascript:void(0)" onClick="pymol.cmd.show('sticks','blah')">throw exception</a>

</body>
</html>