<?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/pra3006.xml" rel="self" type="application/atom+xml" /><link href="https://chem-bla-ics.linkedchemistry.info/" rel="alternate" type="text/html" /><updated>2026-02-28T20:19:43+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/feed/by_tag/pra3006.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 #23: research output for the future</title><link href="https://chem-bla-ics.linkedchemistry.info/2018/11/04/programming-in-life-sciences-23.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #23: research output for the future" /><published>2018-11-04T00:00:00+00:00</published><updated>2018-11-04T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2018/11/04/programming-in-life-sciences-23</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2018/11/04/programming-in-life-sciences-23.html"><![CDATA[<p><span style="width: 30%; display: block; margin-left: auto; margin-right: auto; float: right">
<img src="/assets/images/15528-illustration-of-a-ten-of-clubs-playing-card-pv.png" /> <br />
A random public domain picture with 10 in it.<br />
</span>
Ensuring that you and others can understand you research output five years from now requires effort. This is why scholars tend to keep lab
notebooks. The computational age has perhaps made us a bit lazy here, but we still make an effort. A series of <em>Ten Simple Rules</em> articles
outline some of the things to think about:</p>

<ol>
  <li>Goodman A, Pepe A, Blocker AW, Borgman CL, Cranmer K, Crosas M, et al. <a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003542"><strong>Ten Simple Rules</strong> for the Care and Feeding of Scientific Data</a>. Bourne PE, editor. PLoS Computational Biology. 2014 Apr 24;10(4):e1003542.</li>
  <li>List M, Ebert P, Albrecht F. <a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005265"><strong>Ten Simple Rules</strong> for Developing Usable Software in Computational Biology</a>. Markel S, editor. PLOS Computational Biology. 2017 Jan 5;13(1):e1005265.</li>
  <li>Perez-Riverol Y, Gatto L, Wang R, Sachsenberg T, Uszkoreit J, Leprevost F da V, et al. <a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1004947"><strong>Ten Simple Rules</strong> for Taking Advantage of Git and GitHub</a>. Markel S, editor. PLOS Computational Biology. 2016 Jul 14;12(7):e1004947.</li>
  <li>Prlić A, Procter JB. <a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1002802"><strong>Ten Simple Rules</strong> for the Open Development of Scientific Software</a>. PLoS Computational Biology. 2012 Dec 6;8(12):e1002802.</li>
  <li>Sandve GK, Nekrutenko A, Taylor J, Hovig E. <a href="https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003285"><strong>Ten Simple Rules</strong> for Reproducible Computational Research</a>. Bourne PE, editor. PLoS Computational Biology. 2013 Oct 24;9(10):e1003285.</li>
</ol>

<p>Regarding licensing, I can highly recommend reading this book:</p>

<ol>
  <li>Rosen L. Open Source Licensing [Internet]. 2004. Available from: <a href="https://www.rosenlaw.com/oslbook.htm">https://www.rosenlaw.com/oslbook.htm</a></li>
</ol>

<p>Regarding Git, I recommend these two resources:</p>

<ol>
  <li>Wiegley J. Git From the Bottom Up [Internet]. 2017. Available from: <a href="https://jwiegley.github.io/git-from-the-bottom-up/">https://jwiegley.github.io/git-from-the-bottom-up/</a></li>
  <li>Task 1: How to set up a repository on GitHub [Internet]. 2018. Available from: <a href="https://github.com/OpenScienceMOOC/Module-5-Open-Research-Software-and-Open-Source/blob/master/content_development/Task_1.md">https://github.com/OpenScienceMOOC/Module-5-Open-Research-Software-and-Open-Source/blob/master/content_development/Task_1.md</a></li>
</ol>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="justdoi:10.1371/journal.pcbi.1003542" /><category term="justdoi:10.1371/journal.pcbi.1005265" /><category term="justdoi:10.1371/journal.pcbi.1004947" /><category term="justdoi:10.1371/journal.pcbi.1002802" /><category term="justdoi:10.1371/journal.pcbi.1003285" /><summary type="html"><![CDATA[A random public domain picture with 10 in it. Ensuring that you and others can understand you research output five years from now requires effort. This is why scholars tend to keep lab notebooks. The computational age has perhaps made us a bit lazy here, but we still make an effort. A series of Ten Simple Rules articles outline some of the things to think about:]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/15528-illustration-of-a-ten-of-clubs-playing-card-pv.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/15528-illustration-of-a-ten-of-clubs-playing-card-pv.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Programming in the Life Sciences #21: 2014 Screenshots #1</title><link href="https://chem-bla-ics.linkedchemistry.info/2015/01/11/programming-in-life-sciences-21-2014.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #21: 2014 Screenshots #1" /><published>2015-01-11T00:00:00+00:00</published><updated>2015-01-11T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2015/01/11/programming-in-life-sciences-21-2014</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2015/01/11/programming-in-life-sciences-21-2014.html"><![CDATA[<p>December saw the end of this year’s PRA3006 course (aka <a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-1-six-day.html">#mcspils</a>).
Time to blog some screenshots of the student projects. Like last year, the aim is to use the <a href="https://dev.openphacts.org/">Open PHACTS API</a>
to collect data with <a href="https://github.com/openphacts/ops.js">ops.js</a> and which should then be visualized in a HTML page, preferably with
<a href="http://d3js.org/">d3.js</a>. This year, all projects reached that goal.</p>

<h2 id="ace-inhibitors">ACE inhibitors</h2>

<p>The first team (Mischa-Alexander and Hamza) focused on the <a href="https://en.wikipedia.org/wiki/ACE_inhibitor">ACE inhibitors</a> (type:”drug class”) and the
<a href="http://wikipathways.org/index.php/Pathway:WP554">WP554 from WikiPathways</a>. The use a tree structure to list inhibitors along with their activity:</p>

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

<p>The source code for this project is available under a MIT license.</p>

<h2 id="diabetes">Diabetes</h2>

<p>The second team (Catherine and Moritz) looked at compounds hitting diabetes mellitus targets. They take advantage from the new disease API methods and
first ask for all targets for the disease, and then query for all compounds. Mind you, the compounds are not filtered by activity, so it mostly shows
interactions that real targets.</p>

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

<p>This product too is available with the MIT license.</p>

<h2 id="tuberculosis">Tuberculosis</h2>

<p>The third project (Nadia en Loic) also goes from disease to targets and they looked at tuberculosis.</p>

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

<h2 id="asynchronous-calls">Asynchronous calls</h2>

<p>If you know the ops.js, d3.js, and JavaScript a bit, you know that these projects are not trivial. The remote web service calls are made in an
asynchronous manner: each call comes with a callback function that gets called when the server returns an answer, at some future point in time.
Therefore, if you want to visualization, for example, compounds with activities against targets for a particular disease, you need two web service
calls, with the second made in the callback function of the first call. Now, try to globally collect the data from that with JavaScript and HTML,
and make sure to call the visualization call when all information is collected! But even without that, the students need to convert the returned
web service answer into a format that d3.js can handle. In short: quite a challenge for six practical days!</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="openphacts" /><summary type="html"><![CDATA[December saw the end of this year’s PRA3006 course (aka #mcspils). Time to blog some screenshots of the student projects. Like last year, the aim is to use the Open PHACTS API to collect data with ops.js and which should then be visualized in a HTML page, preferably with d3.js. This year, all projects reached that goal.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/pra3006_screenshot1.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/pra3006_screenshot1.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Programming in the Life Sciences #19: debugging</title><link href="https://chem-bla-ics.linkedchemistry.info/2014/11/16/programming-in-life-sciences-19.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #19: debugging" /><published>2014-11-16T00:00:00+00:00</published><updated>2014-11-16T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2014/11/16/programming-in-life-sciences-19</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2014/11/16/programming-in-life-sciences-19.html"><![CDATA[<p>Debugging is the process find removing a fault in your code
(<a href="https://en.wikipedia.org/wiki/Software_bug#Etymology">the etymology</a> goes further back
than the moth story, I learned today). Being able to debug is an essential programming skill,
and being able to program flawlessly is not enough; the bug can be outside your own code.
(… there is much that can be written up about module interactions, APIs, documentation, etc,
that lead to <em>malfunctioning</em> code …)</p>

<p>While there are full debugging tools, achieving the task of finding where the bug is can
often be reached with simpler means:</p>

<ol>
  <li>take notice of error messages</li>
  <li>add debug statements in your code</li>
</ol>

<h2 id="error-messages">Error messages</h2>

<p>Keeping track of error messages is first starting point. This skill is almost an art:
it requires having seen enough for them to understand how to interpret them. I guess
error messages are the worst developed aspects of programming language, and I do not
frequently see programming language tutorial that discuss error messages. The field can
certainly improve here.</p>

<p>However, at least error messages in general give an indication where the problem occurs.
Often by a line number, though this number is not always accurate. Underlying causes of
that are the problem that if there is a problem in the code, it is not always clear what
the problem is. For example, if there is a closing (or opening) bracket missing somewhere,
how can the <a href="http://chem-bla-ics.blogspot.nl/2013/10/exercise-what-variable-type-would-you.html">compiler</a>
decide what the author of the code meant? Web browsers like Firefox/Iceweasel and
Chrome (Ctrl-Shift-C) have a console that displays compiler errors and warnings:</p>

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

<p>Another issue is that error messages can be cryptic and misleading. For example, the
above error message <em>“TypeError: searcher.bytag is not a function example1.html:73”</em>
is confusing for a starting programmer. Surely, the source code calls <code class="language-plaintext highlighter-rouge">searcher.bytag()</code>
which definately is a function. So, why does the compiler say it is not?? The bug here,
of course, is that the function called in the source code is not found: it should be
<a href="https://github.com/openphacts/ops.js/blob/master/src/ConceptWikiSearch.js#L9">byTag()</a>.</p>

<p>But this bug at least can be detected during interpretation and executing of the code.
That is, it is clear to the compiler that it doesn’t know how to handle the code.
Another common problem is the situation where the code looks fine (to the compiler),
but the data it handles makes the code break down. For example, an variable doesn’t
have the expected value, leading to errors (e.g. null pointer-style). Therefore,
understanding the variable values at a particular point in your code can be of
great use.</p>

<h2 id="console-output">Console output</h2>

<p>A simple way to inspect the content of a variable is to use this console visible in
the above screenshot. Many programming languages have their custom call to send output
there. Java has the <code class="language-plaintext highlighter-rouge">System.out.println()</code> and JavaScript has <code class="language-plaintext highlighter-rouge">console.log()</code>:</p>

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

<p>Thus, if you have some complex bit of code with multiple for-loops, if-else statements,
etc, this can be used to see if some part of your code that you expect to be called
really is:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">console</span><span class="p">.</span><span class="nf">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">He, I'm here!</span><span class="dl">"</span><span class="p">);</span>
</code></pre></div></div>

<p>This can be very useful when using asynchronous web service calls! Similarly, see
what the value of some variable is:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">label</span> <span class="o">=</span> <span class="nx">jsonResponse</span><span class="p">.</span><span class="nx">items</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">prefLabel</span><span class="p">;</span>
<span class="nx">console</span><span class="p">.</span><span class="nf">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">label: </span><span class="dl">"</span> <span class="o">+</span> <span class="nx">label</span><span class="p">);</span>
</code></pre></div></div>

<p>Also, because JavaScript is not a <a href="https://en.wikipedia.org/wiki/Strong_and_weak_typing">strongly typed programming</a>
I frequently find myself inspecting the <a href="http://chem-bla-ics.blogspot.nl/2013/10/exercise-what-variable-type-would-you.html">data type</a>
of a variable:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">label</span> <span class="o">=</span> <span class="nx">jsonResponse</span><span class="p">.</span><span class="nx">items</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">prefLabel</span><span class="p">;</span>

<span class="nx">console</span><span class="p">.</span><span class="nf">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">typeof label: </span><span class="dl">"</span> <span class="o">+</span> <span class="k">typeof</span><span class="p">(</span><span class="nx">label</span><span class="p">));</span>
</code></pre></div></div>

<h2 id="conclusion">Conclusion</h2>

<p>These tools are very useful to find the location of a bug. And this matters. Yesterday,
I was trying to use the <a href="http://chem-bla-ics.blogspot.nl/2014/11/programming-in-life-sciences-18.html">histogram code in example6.html</a>
to visualize a set of values with negative numbers (<a href="https://en.wikipedia.org/wiki/Zeta_potential">zeta potentials</a>
of nanomaterials, to be precise) and I was debugging the issue, trying to find where
my code when wrong. I used the above approaches, and the array of values looked in
order, but different from the original example. But still the histogram was not
showing up. Well, after hours, and having asked someone else to look at the code
too, and having ruled out many alternatives, she pointed out that the problem was
not in the JavaScript part of the code, but in the HTML: I was mixing up how
default JavaScript and the d3.js library add SVG content to the HTML data model.
That is, I was using <code class="language-plaintext highlighter-rouge">&lt;div id="chart"&gt;</code>, which works with <code class="language-plaintext highlighter-rouge">document.getElementById("chart").innerHTML</code>,
but needed to use <code class="language-plaintext highlighter-rouge">&lt;div class="chart"&gt;</code> with the <code class="language-plaintext highlighter-rouge">d3.select(".chart").innerHTML</code>
code I was using later.</p>

<p>OK, that bug was on my account. However, it still was not working: I did see a
histogram, but it didn’t look good. Again debugging, and after again much too long,
I found out that this was a bug in the d3.js code that makes it impossible to use
their histogram example code for negative values. Again, once I knew where the bug
was, I could Google and quickly found
<a href="http://stackoverflow.com/questions/15388481/d3-js-histogram-with-positive-and-negative-values">the solution for it on StackOverflow</a>.</p>

<p>So, the workflow of debugging at a top level, looks like:</p>

<ol>
  <li>find where the problem is</li>
  <li>try to solve the problem</li>
</ol>

<p>Happy debugging!</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><summary type="html"><![CDATA[Debugging is the process find removing a fault in your code (the etymology goes further back than the moth story, I learned today). Being able to debug is an essential programming skill, and being able to program flawlessly is not enough; the bug can be outside your own code. (… there is much that can be written up about module interactions, APIs, documentation, etc, that lead to malfunctioning code …)]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/debug2.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/debug2.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Programming in the Life Sciences #20: extracting data from JSON</title><link href="https://chem-bla-ics.linkedchemistry.info/2014/11/16/programming-in-life-sciences-20.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #20: extracting data from JSON" /><published>2014-11-16T00:00:00+00:00</published><updated>2014-11-16T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2014/11/16/programming-in-life-sciences-20</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2014/11/16/programming-in-life-sciences-20.html"><![CDATA[<p>I previously wrote about the <a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-10.html">JavaScript Object Notation</a>
(JSON) which has become a de facto standard for sharing data by web services. I personally
still prefer something using the <a href="https://en.wikipedia.org/wiki/Resource_Description_Framework">Resource Description Framework</a>
(RDF) because of its clear link to ontologies, but perhaps
<a href="https://en.wikipedia.org/wiki/JSON-LD">JSON-LD</a> combines the best of both worlds.</p>

<p>The <a href="https://dev.openphacts.org/">Open PHACTS API</a> support various formats and this
JSON is the default format used by the <a href="https://github.com/openphacts/ops.js">ops.js</a>
library. However, the amount of information returned by the Open PHACTS cache is complex,
and generally includes more than you want to use in the next step. Therefore, it is
needed to extract data from the JSON document, which was not covered in the
<a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-10.html">post #10</a>
<a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-11-html.html">or #11</a>.</p>

<p>Let’s start with the example JSON given in that post, and let’s consider this is the
value of a variable with the name jsonData:</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">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
    </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Foo"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"price"</span><span class="p">:</span><span class="w"> </span><span class="mi">123</span><span class="p">,</span><span class="w">
    </span><span class="nl">"tags"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"Bar"</span><span class="p">,</span><span class="w"> </span><span class="s2">"Eek"</span><span class="w"> </span><span class="p">],</span><span class="w">
    </span><span class="nl">"stock"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
        </span><span class="nl">"warehouse"</span><span class="p">:</span><span class="w"> </span><span class="mi">300</span><span class="p">,</span><span class="w">
        </span><span class="nl">"retail"</span><span class="p">:</span><span class="w"> </span><span class="mi">20</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>We can see that this JSON value starts with a map-like structure. We can also see that
there is a list embedded, and another map. I guess that one of the reasons why JSON
has taken such a flight is how well it integrates with the JavaScript language: selecting
content can be done in terms of core language features, different from, for example,
<a href="https://en.wikipedia.org/wiki/XPath">XPath</a> statements needed for
<a href="https://en.wikipedia.org/wiki/XML">XML</a> or <a href="https://en.wikipedia.org/wiki/SPARQL">SPARQL</a>
for RDF content. This is because the notation just follows core data types of JavaScript
and data is stored as native data types and objects.</p>

<p>For example, to get the price value from the above JSON code, we use:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">price</span> <span class="o">=</span> <span class="nx">jsonData</span><span class="p">.</span><span class="nx">price</span><span class="p">;</span>
</code></pre></div></div>

<p>Or, if we want to get the first value in the Bar-Eek list, we use:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">tag</span> <span class="o">=</span> <span class="nx">jsonData</span><span class="p">.</span><span class="nx">tags</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
</code></pre></div></div>

<p>Or, if we want to inspect the warehouse stock:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">inStock</span> <span class="o">=</span> <span class="nx">jsonData</span><span class="p">.</span><span class="nx">stock</span><span class="p">.</span><span class="nx">warehouse</span><span class="p">;</span>
</code></pre></div></div>

<p>Now, the JSON returned by the Open PHACTS API has a lot more information. This is why the
online, interactive documentation is so helpful: it shows the JSON. In fact, given that
JSON is so much used, there are many tools online that help you, such as
<a href="http://jsoneditoronline.org/">jsoneditoronline.org</a> (yes, it will show error messages
if the syntax is wrong):</p>

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

<p>BTW, I also recommend installing a JSON viewer extension for
<a href="https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc?hl=en#sthash.vsIhyalK.dpuf">Chrome</a>
or for <a href="https://addons.mozilla.org/en-US/firefox/addon/jsonview/">Firefox</a>. Once you
have installed this plugin, you can not just read the JSON on Open PHACTS’
interactive documentation page, but also open the Request URL into a separate browser
window. Just copy/paste the URL from this output:</p>

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

<p>And with a JSON viewing extension, opening this <em>https://beta.openphacts.org/1.3/pathways/…</em>
URL in your browser window will look something like:</p>

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

<p>And because these extensions typically use syntax highlighting, it is easier to understand
how to access information from within your JavaScript code. For example, if we want the
number of pathways in which the compound <a href="http://www.conceptwiki.org/concept/index/7e0a4dd4-8160-4906-9db1-fdb300e888ea">testosterone</a>
(the link is the <a href="http://scholar.google.com/scholar?hl=nl&amp;q=ConceptWiki">ConceptWiki</a>
URL in the above example) is found, we can use this code:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">pathwayCount</span> <span class="o">=</span> <span class="nx">jsonData</span><span class="p">.</span><span class="nx">result</span><span class="p">.</span><span class="nx">primaryTopic</span><span class="p">.</span><span class="nx">pathway_count</span><span class="p">;</span>
</code></pre></div></div>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="inchikey:MUMGGOZAMZWBJJ-DYKIIFRCSA-N" /><summary type="html"><![CDATA[I previously wrote about the JavaScript Object Notation (JSON) which has become a de facto standard for sharing data by web services. I personally still prefer something using the Resource Description Framework (RDF) because of its clear link to ontologies, but perhaps JSON-LD combines the best of both worlds.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/debug3.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/debug3.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Programming in the Life Sciences #17: The Open PHACTS scientific questions</title><link href="https://chem-bla-ics.linkedchemistry.info/2014/11/06/programming-in-life-sciences-17-open.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #17: The Open PHACTS scientific questions" /><published>2014-11-06T00:00:00+00:00</published><updated>2014-11-06T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2014/11/06/programming-in-life-sciences-17-open</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2014/11/06/programming-in-life-sciences-17-open.html"><![CDATA[<p>I think the authors of the <a href="http://www.openphacts.org/">Open PHACTS</a> proposal made a right choice
in defining a small set of questions that the solution to be developed could be tested against.
The questions being specific, it is much easier to understand the needs. In fact, I suspect it may
even be a very useful form of requirement analysis, and makes it hard to keep using vague terms.</p>

<p><img src="/assets/images/opsSciencyQs.jpg" alt="" /></p>

<p>Open PHACTS has come up with 20 questions (doi:<a href="https://doi.org/10.1016/j.drudis.2013.05.008">10.1016/j.drudis.2013.05.008</a>;
Open Access):</p>

<ol>
  <li><em>Give me all oxidoreductase inhibitors active &lt;100 nM in human and mouse</em></li>
  <li><em>Given compound X, what is its predicted secondary pharmacology? What are the on- and off-target safety concerns for a compound? What is the evidence and how reliable is that evidence (journal impact factor, KOL) for findings associated with a compound?</em></li>
  <li><em>Given a target, find me all actives against that target. Find/predict polypharmacology of actives. Determine ADMET profile of actives</em></li>
  <li><em>For a given interaction profile – give me similar compounds</em></li>
  <li><em>The current Factor Xa lead series is characterized by substructure X. Retrieve all bioactivity data in serine protease assays for molecules that contain substructure X</em></li>
  <li><em>A project is considering protein kinase C alpha (PRKCA) as a target. What are all the compounds known to modulate the target directly? What are the compounds that could modulate the target directly? I.e. return all compounds active in assays where the resolution is at least at the level of the target family (i.e. PKC) from structured assay databases and the literature</em></li>
  <li><em>Give me all active compounds on a given target with the relevant assay data</em></li>
  <li><em>Identify all known protein–protein interaction inhibitors</em></li>
  <li><em>For a given compound, give me the interaction profile with targets</em></li>
  <li><em>For a given compound, summarize all ‘similar compounds’ and their activities</em></li>
  <li><em>Retrieve all experimental and clinical data for a given list of compounds defined by their chemical structure (with options to match stereochemistry or not)</em></li>
  <li><em>For my given compound, which targets have been patented in the context of Alzheimer’s disease?</em></li>
  <li><em>Which ligands have been described for a particular target associated with transthyretin-related amyloidosis, what is their affinity for that target and how far are they advanced into preclinical/clinical phases, with links to publications/patents describing these interactions?</em></li>
  <li><em>Target druggability: compounds directed against target X have been tested in which indications? Which new targets have appeared recently in the patent literature for a disease? Has the target been screened against in AZ before? What information on in vitro or in vivo screens has already been performed on a compound?</em></li>
  <li><em>Which chemical series have been shown to be active against target X? Which new targets have been associated with disease Y? Which companies are working on target X or disease Y?</em></li>
  <li><em>Which compounds are known to be activators of targets that relate to Parkinson’s disease or Alzheimer’s disease</em></li>
  <li><em>For my specific target, which active compounds have been reported in the literature? What is also known about upstream and downstream targets?</em></li>
  <li><em>Compounds that agonize targets in pathway X assayed in only functional assays with a potency &lt;1 μM</em></li>
  <li><em>Give me the compound(s) that hit most specifically the multiple targets in a given pathway (disease)</em></li>
  <li><em>For a given disease/indication, give me all targets in the pathway and all active compounds hitting them</em></li>
</ol>

<p>Students in the <a href="http://chem-bla-ics.blogspot.nl/search/label/%23mscpils">Programming in the Life Sciences course</a>
will this year pick one of these questions as a starting point in the project. The goal is to develop
a HTML+JavaScript solution that will answer the question the selected. There is freedom to tweak the
question to personal interests, of course. By selecting a simpler pharmacological question that last
year, more time and effort can be put into visualization and interpretation of the found data.</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="justdoi:10.1016/j.drudis.2013.05.008" /><summary type="html"><![CDATA[I think the authors of the Open PHACTS proposal made a right choice in defining a small set of questions that the solution to be developed could be tested against. The questions being specific, it is much easier to understand the needs. In fact, I suspect it may even be a very useful form of requirement analysis, and makes it hard to keep using vague terms.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/opsSciencyQs.jpg" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/opsSciencyQs.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Programming in the Life Sciences #13: Another screenshot</title><link href="https://chem-bla-ics.linkedchemistry.info/2013/12/06/programming-in-life-sciences-13-another.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #13: Another screenshot" /><published>2013-12-06T00:10:00+00:00</published><updated>2013-12-06T00:10:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2013/12/06/programming-in-life-sciences-13-another</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2013/12/06/programming-in-life-sciences-13-another.html"><![CDATA[<p>I got a one more source code zip file from the <a href="http://www.maastrichtuniversity.nl/web/Schools/MaastrichtScienceProgramme.htm">Maastricht Science Programme</a>
students (see also the <a href="http://chem-bla-ics.blogspot.nl/2013/12/programming-in-life-sciences-12-first.html">first two screenshots</a>). Vincent and Błażej extended the
<a href="http://d3js.org/">d3.js</a> tree view, showing classification information from <a href="http://www.ebi.ac.uk/chebi/">ChEBI</a> (they also
<a href="https://github.com/openphacts/ops.js/pull/2">submitted</a> <a href="https://github.com/openphacts/ops.js/pull/3">three</a>
<a href="https://github.com/openphacts/ops.js/pull/4">patches</a> to the <a href="http://www.openphacts.org/">Open PHACTS</a> <a href="https://github.com/openphacts/ops.js">ops.js</a>):</p>

<p><img src="/assets/images/blazejAndVincent.png" alt="" /></p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="openphacts" /><category term="chebi" /><summary type="html"><![CDATA[I got a one more source code zip file from the Maastricht Science Programme students (see also the first two screenshots). Vincent and Błażej extended the d3.js tree view, showing classification information from ChEBI (they also submitted three patches to the Open PHACTS ops.js):]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/blazejAndVincent.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/blazejAndVincent.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Programming in the Life Sciences #12: First screenshots</title><link href="https://chem-bla-ics.linkedchemistry.info/2013/12/06/programming-in-life-sciences-12-first.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #12: First screenshots" /><published>2013-12-06T00:00:00+00:00</published><updated>2013-12-06T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2013/12/06/programming-in-life-sciences-12-first</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2013/12/06/programming-in-life-sciences-12-first.html"><![CDATA[<p>Yesterday was the last <a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-1-six-day.html">Programming in the Life Sciences</a> practical day,
and the 2nd and 3rd year B.Sc. <a href="http://www.maastrichtuniversity.nl/web/Schools/MaastrichtScienceProgramme.htm">MSC</a> students presented their results yesterday
afternoon. I am impressed with the results that they reached in only six practical days. I have suggested them to upload the presentations to SlideShare or
<a href="http://figshare.com/">FigShare</a> (with the advantage that you get a DOI), and asked them to send them their tools. Below are some screenshots.</p>

<p>The first app is by Tim and Taís, and look up activities from the <a href="http://www.openphacts.org/">Open PHACTS</a> platform and filters it for activities related
to a set of five anti-oxidants (see also <a href="http://figshare.com/articles/Tais_and_Tim_Final_Presentation_pptx/870474">their FigShare</a>):</p>

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

<p>The next app is by Janneke and Lukas and uses the Open PHACTS <a href="https://dev.openphacts.org/">API</a> to report on single protein targets for the compound
the user enters (see also <a href="http://www.slideshare.net/lukasfreedaheimfriedeheim/target-search-janneke-mes-lukas-friedeheim">their SlideShare</a>):</p>

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

<p>More apps will follow soon.</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="openphacts" /><category term="justdoi:10.6084/m9.figshare.870474.v1" /><summary type="html"><![CDATA[Yesterday was the last Programming in the Life Sciences practical day, and the 2nd and 3rd year B.Sc. MSC students presented their results yesterday afternoon. I am impressed with the results that they reached in only six practical days. I have suggested them to upload the presentations to SlideShare or FigShare (with the advantage that you get a DOI), and asked them to send them their tools. Below are some screenshots.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/jannekeAndLukas.png" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/jannekeAndLukas.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><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 #10: JavaScript Object Notation (JSON)</title><link href="https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-10.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #10: JavaScript Object Notation (JSON)" /><published>2013-10-30T00:10:00+00:00</published><updated>2013-10-30T00:10:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-10</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-10.html"><![CDATA[<p>As said, <a href="https://en.wikipedia.org/wiki/JSON">JSON</a> is the format we will use as serialization format
for answers given by the <a href="https://dev.openphacts.org/docs">Open PHACTS LDA</a>. The API actually supports
XML, RDF, HTML, and TSV too, but I think JSON is a good balance between expressiveness and compactness.
Moreover, and perhaps a much better argument, JSON works very well in a JavaScript environment: it is
very easy to convert the serialization into a data model:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">jsonData</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="nx">jsonString</span><span class="p">);</span>
</code></pre></div></div>

<p>Now, we previously covered maps. Maps have keys and values: the keys unlock a particular value.
For example, take this JavaScript:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">map</span> <span class="o">=</span> <span class="p">{</span> <span class="dl">"</span><span class="s2">key</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">value</span><span class="dl">"</span><span class="p">,</span> <span class="dl">"</span><span class="s2">key2</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">value2</span><span class="dl">"</span> <span class="p">};</span>
</code></pre></div></div>

<p>We define here a key-value object, and we can access the two values with the two keys:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">map</span><span class="p">[</span><span class="dl">"</span><span class="s2">key2</span><span class="dl">"</span><span class="p">];</span> <span class="c1">// == value2</span>
</code></pre></div></div>

<p>These examples are JavaScript source code. Not a string. The content of the map variable is a data
structure. But when we communicate with a web service, we need a (string) serialization of the data
model, because we cannot send around memory pointers (which a variable is) because they are only
valid on a single machine.</p>

<p>This is where the JSON format comes in. We can convert the content of the above map variable into a
string representation with this code:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">mapStringified</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">map</span><span class="p">);</span>
</code></pre></div></div>

<p>which gives us the following output:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="nl">"key"</span><span class="p">:</span><span class="s2">"value"</span><span class="p">,</span><span class="nl">"key2"</span><span class="p">:</span><span class="s2">"value2"</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>This string looks an awful lot like the JavaScript code we wrote earlier.</p>

<p>And, likewise we can convert the JSON string back into a JavaScript data model again, with:</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">mapAgain</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="nx">mapStringified</span><span class="p">);</span>
</code></pre></div></div>

<p>Now, I did warn you earlier that values can be lists and maps itself again, so consider this
JSON example from Wikipedia:</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">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
    </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Foo"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"price"</span><span class="p">:</span><span class="w"> </span><span class="mi">123</span><span class="p">,</span><span class="w">
    </span><span class="nl">"tags"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"Bar"</span><span class="p">,</span><span class="w"> </span><span class="s2">"Eek"</span><span class="w"> </span><span class="p">],</span><span class="w">
    </span><span class="nl">"stock"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
        </span><span class="nl">"warehouse"</span><span class="p">:</span><span class="w"> </span><span class="mi">300</span><span class="p">,</span><span class="w">
        </span><span class="nl">"retail"</span><span class="p">:</span><span class="w"> </span><span class="mi">20</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>Here we see that the value behind the stock key is another map, and the value behind the tags
key is a list. This creates a quite flexible serialization format, which is happily used by
Open PHACTS. (And for the semantic web readers, yes, we can make JSON more semantic. The Open
PHACTS LDA supports a “rdfjson” format.)</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="json" /><summary type="html"><![CDATA[As said, JSON is the format we will use as serialization format for answers given by the Open PHACTS LDA. The API actually supports XML, RDF, HTML, and TSV too, but I think JSON is a good balance between expressiveness and compactness. Moreover, and perhaps a much better argument, JSON works very well in a JavaScript environment: it is very easy to convert the serialization into a data model:]]></summary></entry><entry><title type="html">Programming in the Life Sciences #9: APIs and Web Services</title><link href="https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-9-apis-and.html" rel="alternate" type="text/html" title="Programming in the Life Sciences #9: APIs and Web Services" /><published>2013-10-30T00:00:00+00:00</published><updated>2013-10-30T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-9-apis-and</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-9-apis-and.html"><![CDATA[<p>Continuing on the <a href="http://chem-bla-ics.blogspot.nl/2013/10/exercise-what-variable-type-would-you.html">theory</a>
<a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-8-coding.html">covered</a> in this course,
this part will talk about <a href="https://en.wikipedia.org/wiki/Application_programming_interface">application programming interfaces</a>
(APIs) and <a href="https://en.wikipedia.org/wiki/Web_service">web services</a>.</p>

<h2 id="application-programming-interfaces">Application Programming Interfaces</h2>

<p>APIs define how programs can be used by other programs. An API defines how methods are called and what feedback
you can expect. It basically is the combination of documentation and the program itself. But, unlike any piece
of software, an API is aimed at users, rather than use in the same program. The API is how you communicate
between programs.</p>

<p>Now, in this course we will see two key types of APIs. The first are the APIs provided by the libraries that we
use. For example, we already indicated that we will be using at least the following two libraries,
<a href="http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-8-coding.html">ops.js and d3.js</a>.
These libraries are a collection of functional bits (e.g. classes and methods). For example, ops.js
defines an API which wraps closely the <a href="https://dev.openphacts.org/docs">Open PHACTS Linked Data API</a>
(LDA) itself. The API requires as to do a few things: 1. create a wrapper for the LDA; 2. define a
call back function; 3. invoke the actual</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">call</span><span class="p">.</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">appID</span><span class="p">,</span> <span class="nx">appKey</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="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="p">};</span>  
<span class="nx">searcher</span><span class="p">.</span><span class="nf">findCompounds</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="nx">callback</span><span class="p">);</span>
</code></pre></div></div>

<h2 id="web-services">Web Services</h2>

<p>Web services are a special kind of APIs: they expose an API over the web. That imposes some features of
these APIs: first, they are based on a web transport layer, commonly
<a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a>, but
<a href="https://en.wikipedia.org/wiki/Xmpp">XMPP</a> is possible too. HTTP is used by your web browser too. Secondly,
the web server needs a common communication language to serialize the method call. Here, two key standards
are used, <a href="https://en.wikipedia.org/wiki/XML">XML</a> and <a href="https://en.wikipedia.org/wiki/JSON">JSON</a>.
We will cover these in more detail later. For now, it suffices to think of these as
envelopes in which are message is sent. Now, another aspect standardized is how to call the web services.
For that, <a href="https://en.wikipedia.org/wiki/SOAP">SOAP</a> and <a href="https://en.wikipedia.org/wiki/REST">REST</a> are
the most important standards for the life sciences (though I still think
<a href="http://www.biomedcentral.com/1471-2105/10/279">Wagener’s XMPP approach</a> is still
worthwhile checking out!). SOAP and REST use XML and JSON are underlying serialization format.</p>

<p>So, web services are theoretically complex. For this course, most of it is hidden by the client library that will take care of the HTTP and SOAP/REST layers. The students who wish to use Java instead of JavaScript, will face the problem that you first need to find a Java client library for the LDA. There is this library, but that needs exploring for use with the latest Open PHACTS LDA. Higher stakes, higher rewards.</p>

<h2 id="take-home-message">Take home message</h2>

<p>Practically, you do not need to know much of the technologies behind web services, just like you do not need to know machine instructions CPUs follow to run your program. But, it is important to have seen these terms. You will run into them, and need enough context to know where and how to find answers to the questions that you will have.</p>

<p>There is one exception: JavaScript Object Notation, JSON. That is the format in which the data is returned by the service, and you will have to handle that. JSON will be the topic of the next post.</p>]]></content><author><name>Egon Willighagen</name></author><category term="pra3006" /><category term="doi:10.1186/1471-2105-10-279" /><summary type="html"><![CDATA[Continuing on the theory covered in this course, this part will talk about application programming interfaces (APIs) and web services.]]></summary></entry></feed>