<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="https://chem-bla-ics.linkedchemistry.info/feed/by_tag/html.xml" rel="self" type="application/atom+xml" /><link href="https://chem-bla-ics.linkedchemistry.info/" rel="alternate" type="text/html" /><updated>2026-04-19T09:50:36+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/feed/by_tag/html.xml</id><title type="html">chem-bla-ics</title><subtitle>Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.</subtitle><author><name>Egon Willighagen</name></author><entry><title type="html">Programming in the Life Sciences #11: HTML</title><link href="https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-11-html.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #11: HTML" /><published>2013-10-30T00:20:00+00:00</published><updated>2013-10-30T00:20:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-11-html</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-11-html.html"><![CDATA[<p><a href="https://en.wikipedia.org/wiki/HTML">HTML</a> (HyperText Markup Language), the language of the web,
is no longer the only language of the web. But it still is the primary language in which source
code of webpages is shared. Originally, HTML pages were always static: the only HTML source of a
web page was that was downloaded from a website. Nowadays, much HTML the is visualized in your
web browser, is generated on the fly with JavaScript. In fact, that is exactly what you will
learn to do in this course.</p>

<p>HTML has many dialects, and HTML5 is the upcoming next version. The features have become so
extensive that we will not have capture half of them; instead, we will stick to the bare
minimum needed. But even at an minimum, writing a web page with HTML code is basically writing
source code. The compiled version is the view of the webpage your web browser shows you. One
important difference is that HTML is much more like a data model representation than it is like
computational instructions. That is, rather than saying things like <code class="language-plaintext highlighter-rouge">put("String", xCoord, yCoord)</code>,
we define what is to be shown in in what order with general instructions. Well, in pure HTML
that is. <a href="https://en.wikipedia.org/wiki/CSS">Cascading Style Sheets</a> (CSS) is quite outside the
scope of this course.</p>

<p>A minimal HTML page looks like:</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;html&gt;</span>
  <span class="nt">&lt;head&gt;</span>
  <span class="nt">&lt;/head&gt;</span>
  <span class="nt">&lt;body&gt;</span>
  Hello world!
  <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</code></pre></div></div>

<p>When we think about this structure, we notice that it is not unlike the key-value maps we
covered earlier. For example, compare it to this
<a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-10.html">JSON</a>:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"html"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"head"</span><span class="p">:{},</span><span class="w">
    </span><span class="nl">"body"</span><span class="p">:{</span><span class="err">value:</span><span class="s2">"Hello world!"</span><span class="p">}</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>Even if we introduce HTML attributes:</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;html&gt;</span>
  <span class="nt">&lt;head&gt;</span>
  <span class="nt">&lt;/head&gt;</span>
  <span class="nt">&lt;body&gt;</span>
  <span class="nt">&lt;h1&gt;&lt;a</span> <span class="na">name=</span><span class="s">"hello"</span><span class="nt">&gt;</span>Hello world!<span class="nt">&lt;/a&gt;&lt;/h1&gt;</span>
  <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</code></pre></div></div>

<p>The JSON equivalent would be:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"html"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"head"</span><span class="p">:{},</span><span class="w">
    </span><span class="nl">"body"</span><span class="p">:{</span><span class="w">
      </span><span class="nl">"h1"</span><span class="p">:{</span><span class="w">
        </span><span class="nl">"a"</span><span class="p">:{</span><span class="w">
          </span><span class="err">attributes:</span><span class="p">{</span><span class="nl">"name"</span><span class="p">:</span><span class="s2">"hello"</span><span class="p">},</span><span class="w">
          </span><span class="err">value:</span><span class="s2">"Hello world!"</span><span class="w">
        </span><span class="p">}</span><span class="w">
      </span><span class="p">}</span><span class="w">
    </span><span class="p">}</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>So, while these are quite different languages than programming languages, we can clearly
see they have been made up by the same (computer science) people. But in my opinion, this
is an advantage: because we only need to learn the underlying patterns and can then much
more easily switch between different language.</p>

<p>Now, returning to the HTML example, we introduce a bit of terminology. Let’s start with
the last example:</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;h1&gt;&lt;a</span> <span class="na">name=</span><span class="s">"hello"</span><span class="nt">&gt;</span>Hello world!<span class="nt">&lt;/a&gt;&lt;/h1&gt;</span>
</code></pre></div></div>

<p>This HTML code example shows the <code class="language-plaintext highlighter-rouge">&lt;h1&gt;</code> <strong>element</strong> which has one <strong>child element</strong>
<code class="language-plaintext highlighter-rouge">&lt;a&gt;</code>. This child element has an <strong>attribute</strong> <code class="language-plaintext highlighter-rouge">@name</code>. Elements can contain string content,
such as the <code class="language-plaintext highlighter-rouge">&lt;a&gt;</code> element has, and one or more child elements (and any combination of that).
Attributes can only have string content. The HTML specification defines in detail which
elements can be child elements of other elements. For example, the <code class="language-plaintext highlighter-rouge">&lt;head&gt;</code> element can
only be a child element of <code class="language-plaintext highlighter-rouge">&lt;html&gt;</code>. Similarly, each HTML element can only have specific
attributes, though some attributes can be attached to any element.</p>

<p>There is plenty of documentation on the web, but there are also tools that can help us write
HTML. For example, the <a href="http://validator.w3.org/">http://validator.w3.org/</a>. This website
detects errors in your HTML code, and is quite helpful if you are new to editing HTML, as
well as useful if you have a lot of HTML experience.</p>

<p>HTML elements you may find useful include the following:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">&lt;h1&gt;</code>, <code class="language-plaintext highlighter-rouge">&lt;h2&gt;</code>, …, <code class="language-plaintext highlighter-rouge">&lt;h5&gt;</code>: these are header and can be used to make sections</li>
  <li><code class="language-plaintext highlighter-rouge">&lt;p&gt;</code>: indicates a paragraph</li>
  <li><code class="language-plaintext highlighter-rouge">&lt;div id="someID"&gt;</code>: indicates a section of text. The content of any element with an id attribute can be replaced by any appropriate HTML content with JavaScript</li>
  <li><code class="language-plaintext highlighter-rouge">&lt;a href="http://..."&gt;some link&lt;/a&gt;</code>: this is used to make hyperlinks, href means hyperlink reference</li>
  <li><code class="language-plaintext highlighter-rouge">&lt;a name="mark1"&gt;some text&lt;/a&gt;</code>: this is used to create bookmarks. with <code class="language-plaintext highlighter-rouge">&lt;a href="#mark1"&gt;jump to section Mark 1&lt;/a&gt;</code></li>
  <li><code class="language-plaintext highlighter-rouge">&lt;script&gt;</code>: used to include JavaScript code in your HTML page</li>
  <li><code class="language-plaintext highlighter-rouge">&lt;head&gt;</code>: this HTML blob contains metadata, a list of libraries to be loaded, but also JavaScript which is executed before the HTML <code class="language-plaintext highlighter-rouge">&lt;body&gt;</code> is processed</li>
  <li><code class="language-plaintext highlighter-rouge">&lt;body&gt;</code>: this contains the HTML that is depicted in your browser window</li>
</ul>

<p>Keep the HTML simple; the programming is more important.</p>

<p><strong>Exercise</strong>: below is part of the HTML/JavaScript <a href="https://github.com/egonw/mscpils/blob/master/example1.html">source code</a>
behind <a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-5.html">this app</a>.
Please indicate which lines are HTML source code, and what is JavaScript.</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;!DOCTYPE HTML PUBLIC
  "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd"&gt;</span>
<span class="nt">&lt;html&gt;</span>
<span class="c">&lt;!--

Copyright (c) 2013  Egon Willighagen &lt;egon.willighagen@maastrichtuniversity.nl&gt;

 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the "Software"), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:

 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.

--&gt;</span>
<span class="nt">&lt;head&gt;</span>
  <span class="nt">&lt;title&gt;</span>OpenPHACTS Jasmine Spec Runner<span class="nt">&lt;/title&gt;</span>
  <span class="nt">&lt;script </span><span class="na">src=</span><span class="s">"lib/jquery-1.9.1.min.js"</span><span class="nt">&gt;&lt;/script&gt;</span>
  <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"lib/purl.js"</span><span class="nt">&gt;&lt;/script&gt;</span>

  <span class="c">&lt;!-- include source files here... --&gt;</span>
  <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"src/OPS.js"</span><span class="nt">&gt;&lt;/script&gt;</span>
  <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"src/ConceptWikiSearch.js"</span><span class="nt">&gt;&lt;/script&gt;</span>

  <span class="c">&lt;!-- setup --&gt;</span>
  <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span><span class="nt">&gt;</span>
  <span class="c1">// get the app_key and app_id from the webpage call --&gt;</span>
<span class="kd">var</span> <span class="nx">prmstr</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">search</span><span class="p">.</span><span class="nf">substr</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">prmarr</span> <span class="o">=</span> <span class="nx">prmstr</span><span class="p">.</span><span class="nf">split </span><span class="p">(</span><span class="dl">"</span><span class="s2">&amp;</span><span class="dl">"</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">params</span> <span class="o">=</span> <span class="p">{};</span>
<span class="k">for</span> <span class="p">(</span> <span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">prmarr</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">tmparr</span> <span class="o">=</span> <span class="nx">prmarr</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nf">split</span><span class="p">(</span><span class="dl">"</span><span class="s2">=</span><span class="dl">"</span><span class="p">);</span>
    <span class="nx">params</span><span class="p">[</span><span class="nx">tmparr</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="nx">tmparr</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="p">}</span>
  <span class="nt">&lt;/script&gt;</span>
<span class="nt">&lt;/head&gt;</span>

<span class="nt">&lt;body&gt;</span>
  <span class="nt">&lt;h3&gt;</span>Output<span class="nt">&lt;/h3&gt;</span>
  <span class="nt">&lt;h3&gt;</span>Search Results<span class="nt">&lt;/h3&gt;</span>
  <span class="nt">&lt;p&gt;&lt;div</span> <span class="na">id=</span><span class="s">"table"</span><span class="nt">&gt;&lt;/div&gt;&lt;/p&gt;</span>
  <span class="nt">&lt;h3&gt;</span>Compound Details<span class="nt">&lt;/h3&gt;</span>
  <span class="nt">&lt;p&gt;&lt;div</span> <span class="na">id=</span><span class="s">"details"</span><span class="nt">&gt;&lt;/div&gt;&lt;/p&gt;</span>
  <span class="nt">&lt;h3&gt;</span>JSON reply<span class="nt">&lt;/h3&gt;</span>
  <span class="nt">&lt;p&gt;&lt;div</span> <span class="na">id=</span><span class="s">"json"</span><span class="nt">&gt;</span>Nothing yet<span class="nt">&lt;/div&gt;&lt;/p&gt;</span>
  <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span><span class="nt">&gt;</span>
<span class="kd">var</span> <span class="nx">searcher</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Openphacts</span><span class="p">.</span><span class="nc">ConceptWikiSearch</span><span class="p">(</span>
  <span class="dl">"</span><span class="s2">https://beta.openphacts.org</span><span class="dl">"</span><span class="p">,</span>
  <span class="nx">params</span><span class="p">[</span><span class="dl">"</span><span class="s2">app_id</span><span class="dl">"</span><span class="p">],</span> <span class="nx">params</span><span class="p">[</span><span class="dl">"</span><span class="s2">app_key</span><span class="dl">"</span><span class="p">]</span>
<span class="p">);</span>
<span class="kd">var</span> <span class="nx">callback</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">success</span><span class="p">,</span> <span class="nx">status</span><span class="p">,</span> <span class="nx">response</span><span class="p">){</span>
  <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">"</span><span class="s2">json</span><span class="dl">"</span><span class="p">).</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nf">stringify</span><span class="p">(</span><span class="nx">response</span><span class="p">);</span>
  <span class="nx">html</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">&lt;table&gt;</span><span class="dl">"</span><span class="p">;</span>
  <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">response</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
    <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;tr&gt;</span><span class="dl">"</span><span class="p">;</span>
    <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;td&gt;</span><span class="dl">"</span><span class="p">;</span>
    <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">Name: &lt;span&gt;</span><span class="dl">"</span> <span class="o">+</span>
      <span class="nx">response</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">prefLabel</span> <span class="o">+</span>
      <span class="dl">"</span><span class="s2">&lt;/span&gt;</span><span class="dl">"</span><span class="p">;</span>
    <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;/td&gt;</span><span class="dl">"</span><span class="p">;</span>
    <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;/tr&gt;</span><span class="dl">"</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;/table&gt;</span><span class="dl">"</span><span class="p">;</span>
  <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">"</span><span class="s2">table</span><span class="dl">"</span><span class="p">).</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">html</span><span class="p">;</span>
<span class="p">};</span>
<span class="nx">searcher</span><span class="p">.</span><span class="nf">byTag</span><span class="p">(</span>
  <span class="dl">'</span><span class="s1">Aspirin</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">5</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">4</span><span class="dl">'</span><span class="p">,</span>
  <span class="dl">'</span><span class="s1">07a84994-e464-4bbf-812a-a4b96fa3d197</span><span class="dl">'</span><span class="p">,</span>
  <span class="nx">callback</span>
<span class="p">);</span>
  <span class="nt">&lt;/script&gt;</span>
<span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</code></pre></div></div>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="html" /><summary type="html"><![CDATA[HTML (HyperText Markup Language), the language of the web, is no longer the only language of the web. But it still is the primary language in which source code of webpages is shared. Originally, HTML pages were always static: the only HTML source of a web page was that was downloaded from a website. Nowadays, much HTML the is visualized in your web browser, is generated on the fly with JavaScript. In fact, that is exactly what you will learn to do in this course.]]></summary></entry><entry><title type="html">Programming in the Life Sciences #6: functions</title><link href="https://chem-bla-ics.linkedchemistry.info/2013/10/12/programming-in-life-sciences-6-functions.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #6: functions" /><published>2013-10-12T00:00:00+00:00</published><updated>2013-10-12T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2013/10/12/programming-in-life-sciences-6-functions</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2013/10/12/programming-in-life-sciences-6-functions.html"><![CDATA[<p>One key feature of programming languages is the following: first, there is linearity. This is an important point
that is not always clear to students who just start to program. In fact, ask yourself what the algorithm is for
counting the chairs in the room where you are now sitting. Could a computer do that in the same way? How should
your algorithm change? A key point is, is that the program is run step by step, in a linear way.</p>

<p>However, we very easily jump to functions. In fact, we use so many libraries nowadays, this linearity is not so
clear anymore. Things just happen with magic library calls. But at the same time, the library calls make our life
a lot easier: by using functions, we group functionality in easy to read and easier to understand blobs.</p>

<p>OK, the previous example showed that we could use the HTML <code class="language-plaintext highlighter-rouge">@onClick</code> attribute to provide further detail.
But I did not show how. This is how:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">Name: &lt;span onClick=</span><span class="se">\"</span><span class="s2">showDetails('</span><span class="dl">"</span> <span class="o">+</span>
  <span class="nf">escape</span><span class="p">(</span><span class="nx">dataJSON</span><span class="p">)</span> <span class="o">+</span> <span class="dl">"</span><span class="se">\</span><span class="s2">')</span><span class="se">\"</span><span class="s2">&gt;</span><span class="dl">"</span> <span class="o">+</span> 
  <span class="nx">response</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">prefLabel</span> <span class="o">+</span> <span class="dl">"</span><span class="s2">&lt;/span&gt;</span><span class="dl">"</span><span class="p">;</span>
</code></pre></div></div>

<p>This code adds the <code class="language-plaintext highlighter-rouge">@onClick</code> attribute and a function call to the <code class="language-plaintext highlighter-rouge">showDetails()</code> method which takes one parameter,
where we pass escaped JSON. That is non-trivial, I understand, and may be due to my limited knowledge of JavaScript.
The escaping of the JSON is needed to make quotes match in the generated HTML. In the function later, we can unescape
it and get the original JSON again. Importantly, the dataJSON data contains all the details I like to show.</p>

<p>Now, this functions needs to be defined. Yes, plural, because two functions are used in this code snippet: <code class="language-plaintext highlighter-rouge">showDetails()</code>
and <code class="language-plaintext highlighter-rouge">escape()</code>. The last is defined by one of the used libraries. The <code class="language-plaintext highlighter-rouge">showDetails()</code> function, however, I made up.
So, I had to define it elsewhere in the HTML document, and it looks like:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">showDetails</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">dataJSON</span><span class="p">){</span>
  <span class="nx">data</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nf">parse</span><span class="p">(</span><span class="nf">unescape</span><span class="p">(</span><span class="nx">dataJSON</span><span class="p">));</span>
  <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">"</span><span class="s2">details</span><span class="dl">"</span><span class="p">).</span><span class="nx">innerHTML</span> <span class="o">=</span>
    <span class="nx">data</span><span class="p">.</span><span class="nx">_about</span><span class="p">;</span>
<span class="p">};</span>
</code></pre></div></div>

<p>This example actually gives the exact same output as the code in the previous post, but with one major difference.
We now can extend the function as much as we like, but the code to output the list of found compounds does not have
to get more complex than it already is.</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="javascript" /><category term="html" /><summary type="html"><![CDATA[One key feature of programming languages is the following: first, there is linearity. This is an important point that is not always clear to students who just start to program. In fact, ask yourself what the algorithm is for counting the chairs in the room where you are now sitting. Could a computer do that in the same way? How should your algorithm change? A key point is, is that the program is run step by step, in a linear way.]]></summary></entry><entry><title type="html">Programming in the Life Sciences #4: communication from within HTML</title><link href="https://chem-bla-ics.linkedchemistry.info/2013/10/09/programming-in-life-sciences-4.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #4: communication from within HTML" /><published>2013-10-09T00:00:00+00:00</published><updated>2013-10-09T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2013/10/09/programming-in-life-sciences-4</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2013/10/09/programming-in-life-sciences-4.html"><![CDATA[<p>The purpose of a web service is that you give it a question or task, and that it returns an answer. For example, we can ask the
<a href="http://www.openphacts.org/">Open PHACTS</a> platform what compounds it knows with aspirin in the name. We pass the question (with the
<a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-2-accounts.html">API key</a>) and get a list of matching compounds.
Now, this communication is complex: it happens at many levels, which are spelled out in the
<a href="https://en.wikipedia.org/wiki/Internet_model">Internet Model</a>. There are various variants of the stack of communication layers,
but we are interested mostly in the top layers, at the <em>application layer</em>. In fact, for this course this model only serves as
supporting information for those who want to learn more.</p>

<p>Practically, what matters here is how to ask the question and how to understand the answer.</p>

<p>We are supported in these practicalities with JavaScript libraries, in particular the <a href="https://github.com/openphacts/ops.js">ops.js</a>
library and general <a href="https://en.wikipedia.org/wiki/JSON">JSON</a> functionality provided by most browsers (unless the student decided to use
a <em>different</em> programming language, in which there are different libraries). Personally, I have only very limited JavaScript experience,
and this mostly goes back to the good old <a href="http://www.biomedcentral.com/1471-2105/8/487">Userscript and Greasemonkey days</a> (wow! the
paper is actually the <a href="http://www.altmetric.com/details.php?citation_id=103983">4th highest scoring BMC Bioinformatics article!</a>).
But because my JavaScript knowledge is limited and rusty, I spent a good part of today, to get a basic example running. Very basic,
and barely exceeding the communication details. That is, this is the output in the browser:</p>

<p><img src="/assets/images/mcspils_jsonOutput.png" alt="" /></p>

<p>So, what does the question look like? The question is actually hardcoded in the HTML source, but the page does take two parameters:
the <code class="language-plaintext highlighter-rouge">app_key</code> and <code class="language-plaintext highlighter-rouge">app_id</code> that come <a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-2-accounts.html">with your Open PHACTS account</a>.</p>

<p>The ops.js library helps us, and wraps the Open PHACTS LDA methods in JavaScript methods. Thus, rather can crafting special HTTP calls,
we use two JavaScript calls:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">searcher</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Openphacts</span><span class="p">.</span><span class="nc">ConceptWikiSearch</span><span class="p">(</span>
  <span class="dl">"</span><span class="s2">https://beta.openphacts.org</span><span class="dl">"</span><span class="p">,</span>
  <span class="nx">params</span><span class="p">[</span><span class="dl">"</span><span class="s2">app_id</span><span class="dl">"</span><span class="p">],</span> <span class="nx">params</span><span class="p">[</span><span class="dl">"</span><span class="s2">app_key</span><span class="dl">"</span><span class="p">]</span>
<span class="p">);</span>
<span class="nx">searcher</span><span class="p">.</span><span class="nf">byTag</span><span class="p">(</span>
  <span class="dl">'</span><span class="s1">Aspirin</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">20</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">4</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">07a84994-e464-4bbf-812a-a4b96fa3d197</span><span class="dl">'</span><span class="p">,</span>
  <span class="nx">callback</span>
<span class="p">);</span>
</code></pre></div></div>

<p>The first statement creates an LDA method object, while the second makes an actual question. I have not defined the callback variable,
which actually is a JavaScript function that looks like:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">callback</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">success</span><span class="p">,</span> <span class="nx">status</span><span class="p">,</span> <span class="nx">response</span><span class="p">){</span>
  <span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">searcher</span><span class="p">.</span><span class="nf">parseResponse</span><span class="p">(</span><span class="nx">response</span><span class="p">);</span>
  <span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">"</span><span class="s2">output</span><span class="dl">"</span><span class="p">).</span><span class="nx">innerHTML</span> <span class="o">=</span>
    <span class="dl">"</span><span class="s2">Results: </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">JSON</span><span class="p">.</span><span class="nf">stringify</span><span class="p">(</span><span class="nx">result</span><span class="p">);</span>
<span class="p">};</span>
</code></pre></div></div>

<p>When the LDA web service returns data, this method gets called, providing asynchronous functionality to keep the web page responsive.
But when called, it first parses the returned data, and then puts the JSON output as text in the HTML. The output that is given in
the earlier screenshot.</p>

<p>So, hurdle taken. From here on it’s easier. Regular looping over the results, creating some HTML output, etc. The
<a href="https://gist.github.com/egonw/6902776">full source code</a> if this example is available as Gist.</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="javascript" /><category term="html" /><category term="openphacts" /><category term="doi:10.1186/1471-2105-8-487" /><summary type="html"><![CDATA[The purpose of a web service is that you give it a question or task, and that it returns an answer. For example, we can ask the Open PHACTS platform what compounds it knows with aspirin in the name. We pass the question (with the API key) and get a list of matching compounds. Now, this communication is complex: it happens at many levels, which are spelled out in the Internet Model. There are various variants of the stack of communication layers, but we are interested mostly in the top layers, at the application layer. In fact, for this course this model only serves as supporting information for those who want to learn more.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/mcspils_jsonOutput.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/mcspils_jsonOutput.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Programming in the Life Sciences #5: converting the results into HTML</title><link href="https://chem-bla-ics.linkedchemistry.info/2013/10/09/programming-in-life-sciences-5.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #5: converting the results into HTML" /><published>2013-10-09T00:00:00+00:00</published><updated>2013-10-09T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2013/10/09/programming-in-life-sciences-5</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2013/10/09/programming-in-life-sciences-5.html"><![CDATA[<p>Now that we have <a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-4.html">the communication working</a>
with the Open PHACTS LDA, it is time to make a nice GUI. I will not go into details, but we can use basic JavaScript to
iterate over the JSON results, and, for example, create a HTML table:</p>

<p><img src="/assets/images/mscpils1_output.png" alt="" /></p>

<p>In fact, I hooked in some HTML <code class="language-plaintext highlighter-rouge">onClick()</code> functionality so that when you click one of the compound names, you get further
details (under <em>Compound Details</em>), though that only outputs the ConceptWiki URI at this moment. A simple for-loop does
the heavy work:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">html</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">&lt;table&gt;</span><span class="dl">"</span><span class="p">;</span>
<span class="k">for </span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">response</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
  <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;tr&gt;</span><span class="dl">"</span><span class="p">;</span>
  <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;td&gt;</span><span class="dl">"</span><span class="p">;</span>
  <span class="nx">dataJSON</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nf">stringify</span><span class="p">(</span><span class="nx">response</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
  <span class="c1">//   dataJSON.replace(/"/g, "'");</span>
  <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">Name: &lt;span&gt;</span><span class="dl">"</span> <span class="o">+</span> <span class="nx">response</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">prefLabel</span> <span class="o">+</span> <span class="dl">"</span><span class="s2">&lt;/span&gt;</span><span class="dl">"</span><span class="p">;</span>
  <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;/td&gt;</span><span class="dl">"</span><span class="p">;</span>
  <span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;/tr&gt;</span><span class="dl">"</span><span class="p">;</span>
<span class="p">}</span>
<span class="nx">html</span> <span class="o">+=</span> <span class="dl">"</span><span class="s2">&lt;/table&gt;</span><span class="dl">"</span><span class="p">;</span>
<span class="nb">document</span><span class="p">.</span><span class="nf">getElementById</span><span class="p">(</span><span class="dl">"</span><span class="s2">table</span><span class="dl">"</span><span class="p">).</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">html</span><span class="p">;</span>
</code></pre></div></div>

<p>So, we’re set to teach the students all the basics of programming: loops, variables, functions, etc.</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="html" /><category term="javascript" /><summary type="html"><![CDATA[Now that we have the communication working with the Open PHACTS LDA, it is time to make a nice GUI. I will not go into details, but we can use basic JavaScript to iterate over the JSON results, and, for example, create a HTML table:]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/mscpils1_output.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/mscpils1_output.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">My HTML+RDFa homepage</title><link href="https://chem-bla-ics.linkedchemistry.info/2009/09/18/my-htmlrdfa-homepage.html" rel="alternate" type="text/html" title="My HTML+RDFa homepage" /><published>2009-09-18T00:00:00+00:00</published><updated>2009-09-18T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2009/09/18/my-htmlrdfa-homepage</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2009/09/18/my-htmlrdfa-homepage.html"><![CDATA[<p>Finally got around to adding a few more bits to my new science homepage: <a href="http://egonw.github.com/">egonw.github.com</a>. Cool thing about this new page is that it is
<a href="http://www.w3.org/TR/rdfa-syntax/">HTML+RDFa</a>, so, my new <a href="http://en.wikipedia.org/wiki/FOAF_%28software%29">FOAF</a> profile is embedded in the HTML:</p>

<p><img src="/assets/images/egonwGithub.png" alt="" /></p>

<p>Down the bottom is link to extract the RDF triples:</p>

<p><img src="/assets/images/egonwGithub1.png" alt="" /></p>

<p>Next, is to write a piece of code that creates HTML+RDFa+BIBO from a BibTeX file, and to write a plugin for Bioclipse to extract triples from HTML+RDFA.</p>]]></content><author><name>Egon Willighagen</name></author><category term="html" /><category term="rdf" /><category term="foaf" /><summary type="html"><![CDATA[Finally got around to adding a few more bits to my new science homepage: egonw.github.com. Cool thing about this new page is that it is HTML+RDFa, so, my new FOAF profile is embedded in the HTML:]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/egonwGithub1.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/egonwGithub1.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Invisible InChI’s</title><link href="https://chem-bla-ics.linkedchemistry.info/2007/02/20/invisible-inchis.html" rel="alternate" type="text/html" title="Invisible InChI’s" /><published>2007-02-20T00:00:00+00:00</published><updated>2007-02-20T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2007/02/20/invisible-inchis</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2007/02/20/invisible-inchis.html"><![CDATA[<p>Some <a href="http://www.iupac.org/inchi/">InChI</a>’s are short, such as that for methane: <span class="chem:inchi">InChI=1/CH4/h1H4</span>.
Others are long (think <a href="http://chem-bla-ics.linkedchemistry.info/2006/03/31/inchis-in-latex-and-cdk-news.html">crambin <i class="fa-solid fa-recycle fa-xs"></i></a>), and you don’t
want to show them inline. Or you just want to show them anyway, but still want the chemistry to be understood. Here come the
invisible InChI’s.</p>

<h2 id="alt-text-for-images">Alt text for images</h2>

<p>One solution is to put the InChI as content of the @alt attribute of the HTML <code class="language-plaintext highlighter-rouge">&lt;img&gt;</code> element. This has the downside that it
has no explicit semantic meaning. For example, the <a href="http://scienceblogs.com/moleculeoftheday/">Molecule Of The Day</a> blog is using
this approach. It’s an excellent start, but not the solution.</p>

<h2 id="as-keyword">As Keyword</h2>

<p>Another option is to put it in as keyword, in the HTML <code class="language-plaintext highlighter-rouge">&lt;head&gt;</code> element: <code class="language-plaintext highlighter-rouge">&lt;meta name="keywords" content="InChI=1/CH4/h1H4"&gt;</code>.
But Google does not index this, so the use is restricted.</p>

<h2 id="invisible-text">Invisible text</h2>

<p>The most promosing alternative, however, is to put it in using the <code class="language-plaintext highlighter-rouge">&lt;span&gt;</code> element, in combination with microformats or RDFa,
Like this: <span class="chem:inchi" style="font-size: 0%; visibility: hidden;">InChI=1/CH4/h1H4</span>.
It does not show up, does it? But it is really there, as you would see, if you have
<a href="http://chem-bla-ics.linkedchemistry.info/2006/12/19/chemistry-in-html-greasemonkey-again.html">the special Greasemonkey <i class="fa-solid fa-recycle fa-xs"></i>
</a> installed.</p>

<p>This is the HTML code for this example:</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">"chem:inchi"</span> <span class="na">style=</span><span class="s">"font-size: 0%; visibility: hidden;"</span><span class="nt">&gt;</span>InChI=1/CH4/h1H4<span class="nt">&lt;/span&gt;</span>
</code></pre></div></div>

<p>The <code class="language-plaintext highlighter-rouge">@style</code> attribute marks the text’s visibility as hidden, and the font-size is set to 0%. It is important not to set it
to zero itself, because many web browsers do not interpret zero font size correctly, and take the default font size instead.</p>

<p>This should solve the standing problem that we would like to include the InChI’s in our blogs, if it would just not be so
long and unreadable. Just hide it.</p>

<p><strong>Update</strong>: Daniel <a href="https://web.archive.org/web/20070514085137/https://chem-bla-ics.blogspot.com/2007/02/invisible-inchis.html#comment-6321491648638004528">informed <i class="fa-solid fa-box-archive fa-xs"></i></a> <!-- keep link -->
me that Google won’t index text marked ‘visibility: hidden’ and may even mark your webpage as spam :( Not the solution either.
Read the comments for more thoughts.</p>]]></content><author><name>Egon Willighagen</name></author><category term="inchi" /><category term="html" /><summary type="html"><![CDATA[Some InChI’s are short, such as that for methane: InChI=1/CH4/h1H4. Others are long (think crambin ), and you don’t want to show them inline. Or you just want to show them anyway, but still want the chemistry to be understood. Here come the invisible InChI’s.]]></summary></entry><entry><title type="html">Chemistry in HTML: JavaScript from the server</title><link href="https://chem-bla-ics.linkedchemistry.info/2007/01/02/chemistry-in-html-javascript-from.html" rel="alternate" type="text/html" title="Chemistry in HTML: JavaScript from the server" /><published>2007-01-02T00:00:00+00:00</published><updated>2007-01-02T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2007/01/02/chemistry-in-html-javascript-from</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2007/01/02/chemistry-in-html-javascript-from.html"><![CDATA[<p>Recently I blogged about <a href="https://chem-bla-ics.linkedchemistry.info/2006/12/17/smiles-cas-and-inchi-in-blogs.html">a Greasemonkey script <i class="fa-solid fa-recycle fa-xs"></i></a>
to take advantage of <a href="https://chem-bla-ics.linkedchemistry.info/2006/12/10/including-smiles-cml-and-inchi-in.html">semantic markup of chemistry in blogs <i class="fa-solid fa-recycle fa-xs"></i></a>
(and HTML in general), and later made <a href="https://chem-bla-ics.linkedchemistry.info/2006/12/19/chemistry-in-html-greasemonkey-again.html">some plans how this can be
extended <i class="fa-solid fa-recycle fa-xs"></i></a>.
One of the ideas was to make this userscript available from the server, instead
of having people need to install <a href="http://greasemonkey.mozdev.org/">Greasemonkey</a>
and the script separately. So, here it is.</p>

<h2 id="sechemticjs">sechemtic.js</h2>

<p>Consider this (X)HTML:</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;html</span> <span class="na">xmlns=</span><span class="s">"http://www.w3.org/1999/xhtml"</span>
      <span class="na">xmlns:chem=</span><span class="s">"http://www.blueobelisk.org/chemistryblogs/"</span><span class="nt">&gt;</span>

<span class="nt">&lt;head&gt;</span>
 <span class="nt">&lt;title&gt;</span>m1<span class="nt">&lt;/title&gt;</span>
 <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"sechemtic.js"</span> <span class="nt">/&gt;</span>
<span class="o">&lt;</span><span class="sr">/head</span><span class="err">&gt;
</span>
<span class="o">&lt;</span><span class="nx">body</span> <span class="nx">onload</span><span class="o">=</span><span class="dl">"</span><span class="s2">addGoogleAndPubChemLinks(1,1)</span><span class="dl">"</span><span class="o">&gt;</span>
  <span class="o">&lt;</span><span class="nx">h1</span><span class="o">&gt;</span><span class="nx">The</span> <span class="nx">Output</span><span class="o">&lt;</span><span class="sr">/h1</span><span class="err">&gt;
</span>  <span class="o">&lt;</span><span class="nx">p</span><span class="o">&gt;</span><span class="nx">This</span> <span class="nx">article</span> <span class="nx">is</span> <span class="nx">about</span> <span class="o">&lt;</span><span class="nx">span</span> <span class="kd">class</span><span class="o">=</span><span class="dl">"</span><span class="s2">chem:compound</span><span class="dl">"</span><span class="o">&gt;</span><span class="nx">m1</span><span class="o">&lt;</span><span class="sr">/span&gt;</span><span class="err"> 
</span>  <span class="p">(</span><span class="nx">SMILES</span><span class="p">:</span><span class="o">&lt;</span><span class="nx">span</span> <span class="kd">class</span><span class="o">=</span><span class="dl">"</span><span class="s2">chem:smiles</span><span class="dl">"</span><span class="o">&gt;</span><span class="nx">CCCOC</span><span class="o">&lt;</span><span class="sr">/span&gt;</span><span class="se">)</span><span class="sr">.&lt;/</span><span class="nx">p</span><span class="o">&gt;</span>

<span class="o">&lt;</span><span class="sr">/body</span><span class="err">&gt;
</span>
<span class="o">&lt;</span><span class="sr">/html</span><span class="err">&gt;
</span></code></pre></div></div>

<p><img src="/assets/images/sechemticJSOutput.png" alt="" /></p>

<p>I think the above example shows the simple setup of the Sechemtic Web script (please
forgive me my habit to use bad linguistic mashups ;). Just load the script in the
HTML <code class="language-plaintext highlighter-rouge">&lt;head&gt;</code>, and add in the <code class="language-plaintext highlighter-rouge">onload="addGoogleAndPubChemLinks(1,1)"</code> attribute to
the <code class="language-plaintext highlighter-rouge">&lt;body&gt;</code> element. With blogs these bits would be part of the template, and,
therefore, need to be installed once. From then on, just use the <a href="https://chem-bla-ics.linkedchemistry.info/2006/12/10/including-smiles-cml-and-inchi-in.html">semantic markup as
explained earlier <i class="fa-solid fa-recycle fa-xs"></i></a>.
Both the microformat and the RDFa method are supported. In
case of the latter, I recommend to define the chem namespace in the template of
webpages too, instead of in the <code class="language-plaintext highlighter-rouge">&lt;span&gt;</code> elements.</p>

<p>Currently, the Sechemtic Web script only has one functionality: to add links to
<a href="http://pubchem.ncbi.nlm.nih.gov/">PubChem</a> and <a href="http://www.google.com/">Google</a>,
with the <code class="language-plaintext highlighter-rouge">addGoogleAndPubChemLinks(int, int)</code> method. The
first parameter determines (0 or 1) if links to Google should be made, and the
second parameter does the same for links to PubChem.</p>

<h2 id="download">Download</h2>

<p>For now, the script can be downloaded <a href="http://wiki.cubic.uni-koeln.de/cb/sechemtic.js">here</a>.
It is licensed with the GPL version 2.0.</p>

<h2 id="microformats">Microformats</h2>

<p>Here’s the same example using <a href="http://microformats.org/">microformats</a>
instead of RDFa:</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;html&gt;</span>

<span class="nt">&lt;head&gt;</span>
 <span class="nt">&lt;title&gt;</span>m1<span class="nt">&lt;/title&gt;</span>
 <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span> <span class="na">src=</span><span class="s">"sechemtic.js"</span> <span class="nt">/&gt;</span>
<span class="o">&lt;</span><span class="sr">/head</span><span class="err">&gt;
</span>
<span class="o">&lt;</span><span class="nx">body</span> <span class="nx">onload</span><span class="o">=</span><span class="dl">"</span><span class="s2">addGoogleAndPubChemLinks(1,1)</span><span class="dl">"</span><span class="o">&gt;</span>
  <span class="o">&lt;</span><span class="nx">h1</span><span class="o">&gt;</span><span class="nx">The</span> <span class="nx">Output</span><span class="o">&lt;</span><span class="sr">/h1</span><span class="err">&gt;
</span>  <span class="o">&lt;</span><span class="nx">p</span><span class="o">&gt;</span><span class="nx">This</span> <span class="nx">article</span> <span class="nx">is</span> <span class="nx">about</span> <span class="o">&lt;</span><span class="nx">span</span> <span class="kd">class</span><span class="o">=</span><span class="dl">"</span><span class="s2">compound</span><span class="dl">"</span><span class="o">&gt;</span><span class="nx">m1</span><span class="o">&lt;</span><span class="sr">/span&gt;</span><span class="err"> 
</span>  <span class="p">(</span><span class="nx">SMILES</span><span class="p">:</span><span class="o">&lt;</span><span class="nx">span</span> <span class="kd">class</span><span class="o">=</span><span class="dl">"</span><span class="s2">smiles</span><span class="dl">"</span><span class="o">&gt;</span><span class="nx">CCCOC</span><span class="o">&lt;</span><span class="sr">/span&gt;</span><span class="se">)</span><span class="sr">.&lt;/</span><span class="nx">p</span><span class="o">&gt;</span>

<span class="o">&lt;</span><span class="sr">/body</span><span class="err">&gt;
</span>
<span class="o">&lt;</span><span class="sr">/html</span><span class="err">&gt;
</span></code></pre></div></div>]]></content><author><name>Egon Willighagen</name></author><category term="html" /><category term="javascript" /><category term="userscript" /><summary type="html"><![CDATA[Recently I blogged about a Greasemonkey script to take advantage of semantic markup of chemistry in blogs (and HTML in general), and later made some plans how this can be extended . One of the ideas was to make this userscript available from the server, instead of having people need to install Greasemonkey and the script separately. So, here it is.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/sechemticJSOutput.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/sechemticJSOutput.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Chemistry in HTML: Greasemonkey again</title><link href="https://chem-bla-ics.linkedchemistry.info/2006/12/19/chemistry-in-html-greasemonkey-again.html" rel="alternate" type="text/html" title="Chemistry in HTML: Greasemonkey again" /><published>2006-12-19T00:00:00+00:00</published><updated>2006-12-19T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2006/12/19/chemistry-in-html-greasemonkey-again</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2006/12/19/chemistry-in-html-greasemonkey-again.html"><![CDATA[<p>Here’s a quick update on my blog about <a href="https://chem-bla-ics.linkedchemistry.info/2006/12/17/smiles-cas-and-inchi-in-blogs.html">SMILES, CAS and InChI in blogs: Greasemonkey <i class="fa-solid fa-recycle fa-xs"></i></a>
last sunday. The original download was messed up :( You can download a new version at <a href="http://userscripts.org/scripts/show/6807">userscripts.org</a>.</p>

<p>This new version also supports <code class="language-plaintext highlighter-rouge">chem:compound</code>, for any chemical. For example:</p>

<ul>
  <li><span class="chem:compound">isopropyl alcohol</span></li>
</ul>

<p>Remember that it only works for properly marked up content, as described in <a href="https://chem-bla-ics.linkedchemistry.info/2006/12/10/including-smiles-cml-and-inchi-in.html">Including SMILES, CML and InChI in blogs <i class="fa-solid fa-recycle fa-xs"></i></a>.
The HTML source code of the above example looks like (in RDFa):</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;ul&gt;&lt;li&gt;</span>
<span class="nt">&lt;span</span> <span class="na">xmlns:chem=</span><span class="s">"http://www.blueobelisk.org/chemistryblogs/"</span>
      <span class="na">class=</span><span class="s">"chem:compound"</span><span class="nt">&gt;</span>isopropyl alcohol<span class="nt">&lt;/span&gt;</span>
<span class="nt">&lt;/li&gt;&lt;/ul&gt;</span>
</code></pre></div></div>

<p>The current script only adds search links to <a href="http://pubchem.ncbi.nlm.nih.gov/">PubChem</a> and
<a href="http://google.com/">Google</a>, but the possibilities are endless, and potentially very powerfull.
Here are some future ideas.</p>

<h2 id="a-link-to-predict-nmr-spectra-using-nmrshiftdborg">A link to predict NMR spectra using NMRShiftDB.org:</h2>

<p>Making a link to the <a href="http://www.nmrshiftdb.org/">NMRShiftDB.org</a> website to predict <sup>13</sup>C or
<sup>1</sup>H NMR from a SMILES, and InChI likely too, is easy, if the website provides a URL to do this.
(I will discuss this with Stefan.)</p>

<h2 id="a-popup-window-with-the-3d-structure-in-jmol">A popup window with the 3D structure in Jmol:</h2>

<p>This would involve some more work, but this most certainly possible too, given that we actually have
a website around which allows downloading 3D coordinates given a SMILES or InChI. While a simple approach
would be to make a popup with <a href="http://www.jmol.org/">Jmol</a> that takes the URL to that 3D coordinate website,
it could be extended using Ajax to query the 3D structure first, and depending on success, show
Jmol or a message “Could not find 3D coordinates”.</p>

<h2 id="summarize-molecular-details-hidden-in-cml">Summarize molecular details hidden in CML:</h2>

<p>This is likely the most exiting possibility. I blogged about CMLRSS <a href="http://search.blogger.com/?as_q=CMLRSS&amp;ie=UTF-8&amp;ui=blg&amp;bl_url=chem-bla-ics.blogspot.com&amp;x=0&amp;y=0">many times</a> <!-- keep link -->
now (check the AVI, the <a href="https://doi.org/10.1021/ci034244p">article</a>, etc), and combining these two
technologies will take the semantic, chemistry internet to the next level. CMLRSS describes how CML
can be embedded in blog items (e.g. <a href="https://chem-bla-ics.linkedchemistry.info/2006/02/18/blogging-chemistry-on-blogspotcom.html">Blogging chemistry on blogspot.com <i class="fa-solid fa-recycle fa-xs"></i></a>),
but really works for any <a href="http://www.w3.org/TR/xhtml1/">XHTML</a>.</p>

<p>Consider this mockup: add CML content to your blog item, containing molecular properties, such as its
NMR peaks, elemental analysis, etc. This will not show up in your blog item, so that the user is not
bothered with implementation details. Now, a userscript will now about the CML content, as it has access
to the whole content of the page. The visible text will mention the molecule for which CML contains
experimental or other details. Using the <code class="language-plaintext highlighter-rouge">&lt;span class="chem:compound"/&gt;</code> technology shown above, it is
possible to link that compound to this CML bit (details to follow in this blog in January 2007). The
userscript will then on the fly create a popup for the compound name in the visible text to show those
experimental details.</p>

<p>How about that? Comments and other ideas are more than welcome!</p>

<h2 id="server-side-scripts">Server side scripts:</h2>

<p>Greasemonkey allows users to decide which scripts to run on a website, and which not. If you, as blogger
or XHTML editor, want to force a script like the above to be run, that should be possible too.
Greasemonkey scripts are written in JavaScript, so including them on the server side should be
possible too. I might explore this option soon too.</p>]]></content><author><name>Egon Willighagen</name></author><category term="userscript" /><category term="html" /><category term="rdf" /><category term="doi:10.1021/CI034244P" /><category term="nmrshiftdb" /><summary type="html"><![CDATA[Here’s a quick update on my blog about SMILES, CAS and InChI in blogs: Greasemonkey last sunday. The original download was messed up :( You can download a new version at userscripts.org.]]></summary></entry><entry><title type="html">Including SMILES, CML and InChI in blogs</title><link href="https://chem-bla-ics.linkedchemistry.info/2006/12/10/including-smiles-cml-and-inchi-in.html" rel="alternate" type="text/html" title="Including SMILES, CML and InChI in blogs" /><published>2006-12-10T00:00:00+00:00</published><updated>2006-12-10T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2006/12/10/including-smiles-cml-and-inchi-in</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2006/12/10/including-smiles-cml-and-inchi-in.html"><![CDATA[<p>The blogs <a href="http://blog.chembark.com/">ChemBark</a> and <a href="http://kinasepro.wordpress.com/">KinasePro</a> have been discussing
the use of SMILES, CML and InChI in <a href="http://wiki.cubic.uni-koeln.de/pg/">Chemical Blogspace</a> (with 70 chemistry blogs now!).
Chemists seem to <a href="http://kinasepro.wordpress.com/2006/12/05/monday-night-ot-2/">prefer SMILES over InChI</a>, while there is
<a href="http://blog.chembark.com/2006/11/25/help-needed-how-do-we-use-cml-properly/">interest in moving towards CML too</a>.
<a href="http://wwmm.ch.cam.ac.uk/blogs/murrayrust/">Peter commented</a>.</p>

<p>Any incorporation of content other than images and free text requires some HTML knowledge, but this can be rather limited.
It is up to us chemoinformaticians to write good documentation on how to do things; so here is a first go.</p>

<h2 id="including-cml-in-blogs-and-other-rss-feeds">Including CML in blogs and other RSS feeds</h2>

<p>I blogged about including <a href="https://chem-bla-ics.linkedchemistry.info/2006/02/18/blogging-chemistry-on-blogspotcom.html">CML in blogs <i class="fa-solid fa-recycle fa-xs"></i></a>
last February, and can generally refer to this article published last year: <em>Chemical markup, XML, and the World Wide Web. 5.
Applications of chemical metadata in RSS aggregators</em> (PMID:<a href="https://pubmed.ncbi.nlm.nih.gov/15032525">15032525</a>,
DOI:<a href="https://doi.org/10.1021/ci034244p">10.1021/ci034244p</a>). Basically, it just comes down to putting the CML code into
the HTML version of your blog content, though I appreciate the need for plugins.</p>

<h2 id="including-smiles-cas-and-inchi-in-blogs">Including SMILES, CAS and InChI in blogs</h2>

<p>Including SMILES is much easier as it is plain text, and has the advantage over InChI that it is much more readable.
<a href="http://www.cambridgemedchemconsulting.com/">Chris</a> wondered in the KinasePro blog on how to tag SMILES, while Paul
did the same on ChemBark about CAS numbers.</p>

<p>Now, users of <a href="http://postgenomic.com/">PostGenomic.com</a> know how to <a href="http://postgenomic.com/wiki/doku.php?id=markup">add markup to their blogs</a>
to get PostGenomic index discussed literature, website and conferences. Something similar is easily done for chemistry
things too, as I showed in <a href="https://chem-bla-ics.linkedchemistry.info/2006/02/25/hacking-inchi-support-into.html">Hacking InChI support into postgenomic.com <i class="fa-solid fa-recycle fa-xs"></i></a>
(which was put on lower priority because of finishing my PhD). PostGenomic.com basically uses microformats, which I
blogged about just a few days ago in <a href="https://chem-bla-ics.linkedchemistry.info/2006/12/06/chemoblogs-2.html">Chemo::Blogs #2 <i class="fa-solid fa-recycle fa-xs"></i></a>,
where I suggested the use of <code class="language-plaintext highlighter-rouge">&lt;span class="chemicalcompound"&gt;asperin&lt;/span&gt;</code>.</p>

<p>And this is the way SMILES, CAS and InChI’s can be tagged on blogs. The <code class="language-plaintext highlighter-rouge">&lt;span&gt;</code> element is HTML code to indicate
a bit of similar content in HTML, and can, among many other things, be formatted differently than other text. However,
this can also be used to add semantics in a relatively cheap, but accepted, way. [Microformats](http://microformats.org/
 are formalized just by use, so whatever we, as chemistry bloggers, use will become the de facto standard. Here are my suggestions:</p>

<ul>
  <li>for SMILES: <code class="language-plaintext highlighter-rouge">&lt;span class="smiles"&gt;CCO&lt;/span&gt;</code></li>
  <li>for CAS registry numbers: <code class="language-plaintext highlighter-rouge">&lt;span class="casnumber"&gt;50-00-0&lt;/span&gt;</code></li>
  <li>for InChI: <code class="language-plaintext highlighter-rouge">&lt;span class="inchi"&gt;InChI=1/CH4/h1H4&lt;/span&gt;</code></li>
</ul>

<h2 id="the-rdfa-alternative">The RDFa alternative</h2>

<p>The future, however, might use RDFa over microformats, so here are the RDFa equivalents:</p>

<ul>
  <li>for SMILES: <code class="language-plaintext highlighter-rouge">&lt;span class="chem:smiles"&gt;CCO&lt;/span&gt;</code></li>
  <li>for CAS registry numbers: <code class="language-plaintext highlighter-rouge">&lt;span class="chem:casnumber"&gt;50-00-0&lt;/span&gt;</code></li>
  <li>for InChI: <code class="language-plaintext highlighter-rouge">&lt;span class="chem:inchi"&gt;InChI=1/CH4/h1H4&lt;/span&gt;</code></li>
</ul>

<p>which requires you to register the namespace <code class="language-plaintext highlighter-rouge">xmlns:chem="http://www.blueobelisk.org/chemistryblogs/"</code> somewhere though.
Formally, the URN for this namespace needs to be formalized; Peter, would the <a href="http://www.blueobelisk.org/">Blue Obelisk</a>
be the platform to do this? BTW, this is more advanced, and currently does not have practical advantages over the use of
microformats.</p>]]></content><author><name>Egon Willighagen</name></author><category term="cml" /><category term="inchi" /><category term="blog" /><category term="cb" /><category term="doi:10.1021/CI034244P" /><category term="microformat" /><category term="rdf" /><category term="html" /><summary type="html"><![CDATA[The blogs ChemBark and KinasePro have been discussing the use of SMILES, CML and InChI in Chemical Blogspace (with 70 chemistry blogs now!). Chemists seem to prefer SMILES over InChI, while there is interest in moving towards CML too. Peter commented.]]></summary></entry></feed>