diff options
Diffstat (limited to 'modules/xml/demos')
-rwxr-xr-x | modules/xml/demos/atoms_colors.xml | 113 | ||||
-rwxr-xr-x | modules/xml/demos/diazepam.dem.sce | 102 | ||||
-rwxr-xr-x | modules/xml/demos/diazepam.xml | 223 | ||||
-rwxr-xr-x | modules/xml/demos/xml.dem.gateway.sce | 18 |
4 files changed, 456 insertions, 0 deletions
diff --git a/modules/xml/demos/atoms_colors.xml b/modules/xml/demos/atoms_colors.xml new file mode 100755 index 000000000..dd57b61a3 --- /dev/null +++ b/modules/xml/demos/atoms_colors.xml @@ -0,0 +1,113 @@ +<?xml version="1.0"?> +<!-- jmol colors, see http://jmol.sourceforge.net/jscolors/ --> +<atoms> + <atom name="H" R="255" G="255" B="255"/> + <atom name="He" R="217" G="255" B="255"/> + <atom name="Li" R="204" G="128" B="255"/> + <atom name="Be" R="194" G="255" B="0"/> + <atom name="B" R="255" G="181" B="181"/> + <atom name="C" R="144" G="144" B="144"/> + <atom name="N" R="48" G="80" B="248"/> + <atom name="O" R="255" G="13" B="13"/> + <atom name="F" R="144" G="224" B="80"/> + <atom name="Ne" R="179" G="227" B="245"/> + <atom name="Na" R="171" G="92" B="242"/> + <atom name="Mg" R="138" G="255" B="0"/> + <atom name="Al" R="191" G="166" B="166"/> + <atom name="Si" R="240" G="200" B="160"/> + <atom name="P" R="255" G="128" B="0"/> + <atom name="S" R="255" G="255" B="48"/> + <atom name="Cl" R="31" G="240" B="31"/> + <atom name="Ar" R="128" G="209" B="227"/> + <atom name="K" R="143" G="64" B="212"/> + <atom name="Ca" R="61" G="255" B="0"/> + <atom name="Sc" R="230" G="230" B="230"/> + <atom name="Ti" R="191" G="194" B="199"/> + <atom name="V" R="166" G="166" B="171"/> + <atom name="Cr" R="138" G="153" B="199"/> + <atom name="Mn" R="156" G="122" B="199"/> + <atom name="Fe" R="224" G="102" B="51"/> + <atom name="Co" R="240" G="144" B="160"/> + <atom name="Ni" R="80" G="208" B="80"/> + <atom name="Cu" R="200" G="128" B="51"/> + <atom name="Zn" R="125" G="128" B="176"/> + <atom name="Ga" R="194" G="143" B="143"/> + <atom name="Ge" R="102" G="143" B="143"/> + <atom name="As" R="189" G="128" B="227"/> + <atom name="Se" R="255" G="161" B="0"/> + <atom name="Br" R="166" G="41" B="41"/> + <atom name="Kr" R="92" G="184" B="209"/> + <atom name="Rb" R="112" G="46" B="176"/> + <atom name="Sr" R="0" G="255" B="0"/> + <atom name="Y" R="148" G="255" B="255"/> + <atom name="Zr" R="148" G="224" B="224"/> + <atom name="Nb" R="115" G="194" B="201"/> + <atom name="Mo" R="84" G="181" B="181"/> + <atom name="Tc" R="59" G="158" B="158"/> + <atom name="Ru" R="36" G="143" B="143"/> + <atom name="Rh" R="10" G="125" B="140"/> + <atom name="Pd" R="0" G="105" B="133"/> + <atom name="Ag" R="192" G="192" B="192"/> + <atom name="Cd" R="255" G="217" B="143"/> + <atom name="In" R="166" G="117" B="115"/> + <atom name="Sn" R="102" G="128" B="128"/> + <atom name="Sb" R="158" G="99" B="181"/> + <atom name="Te" R="212" G="122" B="0"/> + <atom name="I" R="148" G="0" B="148"/> + <atom name="Xe" R="66" G="158" B="176"/> + <atom name="Cs" R="87" G="23" B="143"/> + <atom name="Ba" R="0" G="201" B="0"/> + <atom name="La" R="112" G="212" B="255"/> + <atom name="Ce" R="255" G="255" B="199"/> + <atom name="Pr" R="217" G="255" B="199"/> + <atom name="Nd" R="199" G="255" B="199"/> + <atom name="Pm" R="163" G="255" B="199"/> + <atom name="Sm" R="143" G="255" B="199"/> + <atom name="Eu" R="97" G="255" B="199"/> + <atom name="Gd" R="69" G="255" B="199"/> + <atom name="Tb" R="48" G="255" B="199"/> + <atom name="Dy" R="31" G="255" B="199"/> + <atom name="Ho" R="0" G="255" B="156"/> + <atom name="Er" R="0" G="230" B="117"/> + <atom name="Tm" R="0" G="212" B="82"/> + <atom name="Yb" R="0" G="191" B="56"/> + <atom name="Lu" R="0" G="171" B="36"/> + <atom name="Hf" R="77" G="194" B="255"/> + <atom name="Ta" R="77" G="166" B="255"/> + <atom name="W" R="33" G="148" B="214"/> + <atom name="Re" R="38" G="125" B="171"/> + <atom name="Os" R="38" G="102" B="150"/> + <atom name="Ir" R="23" G="84" B="135"/> + <atom name="Pt" R="208" G="208" B="224"/> + <atom name="Au" R="255" G="209" B="35"/> + <atom name="Hg" R="184" G="184" B="208"/> + <atom name="Tl" R="166" G="84" B="77"/> + <atom name="Pb" R="87" G="89" B="97"/> + <atom name="Bi" R="158" G="79" B="181"/> + <atom name="Po" R="171" G="92" B="0"/> + <atom name="At" R="117" G="79" B="69"/> + <atom name="Rn" R="66" G="130" B="150"/> + <atom name="Fr" R="66" G="0" B="102"/> + <atom name="Ra" R="0" G="125" B="0"/> + <atom name="Ac" R="112" G="171" B="250"/> + <atom name="Th" R="0" G="186" B="255"/> + <atom name="Pa" R="0" G="161" B="255"/> + <atom name="U" R="0" G="143" B="255"/> + <atom name="Np" R="0" G="128" B="255"/> + <atom name="Pu" R="0" G="107" B="255"/> + <atom name="Am" R="84" G="92" B="242"/> + <atom name="Cm" R="120" G="92" B="227"/> + <atom name="Bk" R="138" G="79" B="227"/> + <atom name="Cf" R="161" G="54" B="212"/> + <atom name="Es" R="179" G="31" B="212"/> + <atom name="Fm" R="179" G="31" B="186"/> + <atom name="Md" R="179" G="13" B="166"/> + <atom name="No" R="189" G="13" B="135"/> + <atom name="Lr" R="199" G="0" B="102"/> + <atom name="Rf" R="204" G="0" B="89"/> + <atom name="Db" R="209" G="0" B="79"/> + <atom name="Sg" R="217" G="0" B="69"/> + <atom name="Bh" R="224" G="0" B="56"/> + <atom name="Hs" R="230" G="0" B="46"/> + <atom name="Mt" R="235" G="0" B="38"/> +</atoms> diff --git a/modules/xml/demos/diazepam.dem.sce b/modules/xml/demos/diazepam.dem.sce new file mode 100755 index 000000000..5f244642d --- /dev/null +++ b/modules/xml/demos/diazepam.dem.sce @@ -0,0 +1,102 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Sylvestre Ledru +// +// This file is released under the 3-clause BSD license. See COPYING-BSD. + +function diazepam_demo() + + + + my_test_fig = figure(100001); + my_test_fig.figure_name = "Display of a molecule of diazepam from a CML file (XML)"; + + filename = "diazepam.dem.sce"; + demo_viewCode(filename); + + listDisplayed = struct(); + + prot = funcprot(); + funcprot(0); + + function displayAtom(atomName) + if ~isfield(listDisplayed,atomName) then + + listDisplayed(atomName)=%t; + [coords elementType] = getAtomInfos(atomName); + + rgbX = xmlXPath(xmlAtomsColors, "//atom[@name=''" + elementType + "'']/@*[name()=''R'' or name()=''G'' or name()=''B'']"); + rgb = xmlAsNumber(rgbX); + + xfarc(coords(1) - 0.5, coords(2) + 0.5, 1, 1, 0, 360 * 64); + cercle = get("hdl"); + cercle.background = color(rgb(1), rgb(2), rgb(3)); + xstring(coords(1), coords(2) - 1, elementType); + end + endfunction + + function [coord, elemType] = getAtomInfos(atomName) + xp = xmlXPath(xmlFile, "//cmldoc/molecule/atomArray/atom[@id=''" + atomName + "'']"); + atomX = xmlXPath(xp(1), "float"); + coord = xmlAsNumber(atomX); + elemType = xmlXPath(xp(1), "string(string[@builtin=''elementType''])"); + endfunction + + funcprot(prot); + + xmlAtomsColors = xmlRead(SCI + "/modules/xml/demos/atoms_colors.xml"); + xmlFile = xmlRead(SCI + "/modules/xml/demos/diazepam.xml"); + + bonds = xmlXPath(xmlFile, "//cmldoc/molecule/bondArray/bond"); + nbBonds = size(bonds); + coords = []; + drawlater(); + plot2d([], [], -1, "030", " ", [-6, -6, 6, 6]); + f = gcf(); + f.background = color(255, 255, 255); + f.anti_aliasing = "8x"; + + for i = 1:nbBonds(2) + bondCouple = xmlAsText(xmlXPath(bonds(i), "string[@builtin=''atomRef'']")); + order = xmlAsNumber(xmlXPath(bonds(i), "string[@builtin=''order'']")); + x1 = getAtomInfos(bondCouple(1))'; + x2 = getAtomInfos(bondCouple(2))'; + if order ~= 1 then + u = x2 - x1; + u = [0 1 ; -1 0] * u / norm(u); + end + + if order == 1 then + coords(:, $ + 1) = x1; + coords(:, $ + 1) = x2; + elseif order == 2 then + coords(:, $ + 1) = x1 - 0.1 * u; + coords(:, $ + 1) = x2 - 0.1 * u; + coords(:, $ + 1) = x1 + 0.1 * u; + coords(:, $ + 1) = x2 + 0.1 * u; + elseif order == 3 then + coords(:, $ + 1) = x1; + coords(:, $ + 1) = x2; + coords(:, $ + 1) = x1 - 0.1 * u; + coords(:, $ + 1) = x2 - 0.1 * u; + coords(:, $ + 1) = x1 + 0.1 * u; + coords(:, $ + 1) = x2 + 0.1 * u; + end + end + coords = coords(:, 2:$); + + xsegs(coords(1, :), coords(2, :)); + + for i = 1:nbBonds(2) + bondCouple = xmlAsText(xmlXPath(bonds(i), "string[@builtin=''atomRef'']")); + displayAtom(bondCouple(1)); + displayAtom(bondCouple(2)); + end + + drawnow(); + + xmlDelete(xmlAtomsColors, xmlFile); + +endfunction + +diazepam_demo(); +clear diazepam_demo;
\ No newline at end of file diff --git a/modules/xml/demos/diazepam.xml b/modules/xml/demos/diazepam.xml new file mode 100755 index 000000000..8bbb13850 --- /dev/null +++ b/modules/xml/demos/diazepam.xml @@ -0,0 +1,223 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="cml.css" type="text/css"?> +<!-- original source: http://www.xml-cml.org/ --> +<cmldoc> + <molecule convention="MDLMol" id="diazepam"> + <date day="22" month="11" year="1995"> + </date> + <atomArray> + <atom id="a1"> + <string builtin="elementType">C</string> + <float builtin="x2">1.4278</float> + <float builtin="y2">-0.202</float> + </atom> + <atom id="a2"> + <string builtin="elementType">C</string> + <float builtin="x2">0.2204</float> + <float builtin="y2">0.7483</float> + </atom> + <atom id="a3"> + <string builtin="elementType">C</string> + <float builtin="x2">1.1983</float> + <float builtin="y2">-1.7262</float> + </atom> + <atom id="a4"> + <string builtin="elementType">N</string> + <float builtin="x2">2.9383</float> + <float builtin="y2">0.1377</float> + </atom> + <atom id="a5"> + <string builtin="elementType">C</string> + <float builtin="x2">0.2204</float> + <float builtin="y2">2.3093</float> + </atom> + <atom id="a6"> + <string builtin="elementType">C</string> + <float builtin="x2">-1.111</float> + <float builtin="y2">-0.0138</float> + </atom> + <atom id="a7"> + <string builtin="elementType">C</string> + <float builtin="x2">2.4195</float> + <float builtin="y2">-2.6766</float> + </atom> + <atom id="a8"> + <string builtin="elementType">C</string> + <float builtin="x2">-0.2433</float> + <float builtin="y2">-2.3093</float> + </atom> + <atom id="a9"> + <string builtin="elementType">C</string> + <float builtin="x2">3.604</float> + <float builtin="y2">1.5472</float> + </atom> + <atom id="a10"> + <string builtin="elementType">N</string> + <float builtin="x2">1.4278</float> + <float builtin="y2">3.2597</float> + </atom> + <atom id="a11"> + <string builtin="elementType">C</string> + <float builtin="x2">-1.111</float> + <float builtin="y2">3.0714</float> + </atom> + <atom id="a12"> + <string builtin="elementType">C</string> + <float builtin="x2">-2.4562</float> + <float builtin="y2">0.7759</float> + </atom> + <atom id="a13"> + <string builtin="elementType">C</string> + <float builtin="x2">2.2037</float> + <float builtin="y2">-4.2008</float> + </atom> + <atom id="a14"> + <string builtin="elementType">C</string> + <float builtin="x2">-0.4591</float> + <float builtin="y2">-3.8336</float> + </atom> + <atom id="a15"> + <string builtin="elementType">C</string> + <float builtin="x2">2.9383</float> + <float builtin="y2">2.9199</float> + </atom> + <atom id="a16"> + <string builtin="elementType">C</string> + <float builtin="x2">1.0743</float> + <float builtin="y2">4.7839</float> + </atom> + <atom id="a17"> + <string builtin="elementType">C</string> + <float builtin="x2">-2.4562</float> + <float builtin="y2">2.3093</float> + </atom> + <atom id="a18"> + <string builtin="elementType">Cl</string> + <float builtin="x2">-3.829</float> + <float builtin="y2">0.0138</float> + </atom> + <atom id="a19"> + <string builtin="elementType">C</string> + <float builtin="x2">0.7483</float> + <float builtin="y2">-4.7839</float> + </atom> + <atom id="a20"> + <string builtin="elementType">O</string> + <float builtin="x2">3.9162</float> + <float builtin="y2">4.1457</float> + </atom> + </atomArray> + <bondArray> + <bond id="b1"> + <string builtin="atomRef">a1</string> + <string builtin="atomRef">a2</string> + <string builtin="order">1</string> + </bond> + <bond id="b2"> + <string builtin="atomRef">a1</string> + <string builtin="atomRef">a3</string> + <string builtin="order">1</string> + </bond> + <bond id="b3"> + <string builtin="atomRef">a1</string> + <string builtin="atomRef">a4</string> + <string builtin="order">2</string> + </bond> + <bond id="b4"> + <string builtin="atomRef">a2</string> + <string builtin="atomRef">a5</string> + <string builtin="order">2</string> + </bond> + <bond id="b5"> + <string builtin="atomRef">a2</string> + <string builtin="atomRef">a6</string> + <string builtin="order">1</string> + </bond> + <bond id="b6"> + <string builtin="atomRef">a3</string> + <string builtin="atomRef">a7</string> + <string builtin="order">1</string> + </bond> + <bond id="b7"> + <string builtin="atomRef">a3</string> + <string builtin="atomRef">a8</string> + <string builtin="order">2</string> + </bond> + <bond id="b8"> + <string builtin="atomRef">a4</string> + <string builtin="atomRef">a9</string> + <string builtin="order">1</string> + </bond> + <bond id="b9"> + <string builtin="atomRef">a5</string> + <string builtin="atomRef">a10</string> + <string builtin="order">1</string> + </bond> + <bond id="b10"> + <string builtin="atomRef">a5</string> + <string builtin="atomRef">a11</string> + <string builtin="order">1</string> + </bond> + <bond id="b11"> + <string builtin="atomRef">a6</string> + <string builtin="atomRef">a12</string> + <string builtin="order">2</string> + </bond> + <bond id="b12"> + <string builtin="atomRef">a7</string> + <string builtin="atomRef">a13</string> + <string builtin="order">2</string> + </bond> + <bond id="b13"> + <string builtin="atomRef">a8</string> + <string builtin="atomRef">a14</string> + <string builtin="order">1</string> + </bond> + <bond id="b14"> + <string builtin="atomRef">a9</string> + <string builtin="atomRef">a15</string> + <string builtin="order">1</string> + </bond> + <bond id="b15"> + <string builtin="atomRef">a10</string> + <string builtin="atomRef">a16</string> + <string builtin="order">1</string> + </bond> + <bond id="b16"> + <string builtin="atomRef">a11</string> + <string builtin="atomRef">a17</string> + <string builtin="order">2</string> + </bond> + <bond id="b17"> + <string builtin="atomRef">a12</string> + <string builtin="atomRef">a18</string> + <string builtin="order">1</string> + </bond> + <bond id="b18"> + <string builtin="atomRef">a13</string> + <string builtin="atomRef">a19</string> + <string builtin="order">1</string> + </bond> + <bond id="b19"> + <string builtin="atomRef">a15</string> + <string builtin="atomRef">a20</string> + <string builtin="order">2</string> + </bond> + <bond id="b20"> + <string builtin="atomRef">a10</string> + <string builtin="atomRef">a15</string> + <string builtin="order">1</string> + </bond> + <bond id="b21"> + <string builtin="atomRef">a12</string> + <string builtin="atomRef">a17</string> + <string builtin="order">1</string> + </bond> + <bond id="b22"> + <string builtin="atomRef">a14</string> + <string builtin="atomRef">a19</string> + <string builtin="order">2</string> + </bond> + </bondArray> + </molecule> +</cmldoc> diff --git a/modules/xml/demos/xml.dem.gateway.sce b/modules/xml/demos/xml.dem.gateway.sce new file mode 100755 index 000000000..aeb12cd59 --- /dev/null +++ b/modules/xml/demos/xml.dem.gateway.sce @@ -0,0 +1,18 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Sylvestre Ledru +// +// This file is released under the 3-clause BSD license. See COPYING-BSD. + + +function subdemolist = demo_gateway() + + demopath = get_absolute_file_path("xml.dem.gateway.sce"); + add_demo(gettext("XML"), demopath + "xml.dem.gateway.sce"); + + subdemolist = [_("CML read") ,"diazepam.dem.sce" ] + + subdemolist(:,2) = demopath + subdemolist(:,2); +endfunction + +subdemolist = demo_gateway(); +clear demo_gateway; |