Saturday, January 20, 2018

Winter solstice challenge #3: the winner is Bianca Kramer!

Part of the winning submission in the category 'best tool'.
A bit later than intended, but I am pleased to announce the winner of the Winter solstice challenge: Bianca Kramer! Of course, she was the only contender, but her solution is awesome! In fact, I am surprised no one took her took, ran it on their own data and just submit that (which was perfectly well within the scope of the challenge).

Best Tool: Bianca Kramer
The best tool (see the code snippet on the right) uses R and a few R packages (rorcid, rjson, httpcache) and services like ORCID and CrossRef (and the I4OC project), and the (also awesome) project. The code is available on GitHub.

Highest Open Knowledge Score: Bianca Kramer
I did not check the self-reported score of 54%, but since no one challenged here, Bianca wins this category too.

So, what next? First, start calculating your own Open Knowledge Scores. Just to be prepared for the next challenge in 11 months. Of course, there is still a lot to explore. For example, how far should we recurse with calculating this score? The following tweet by Daniel Gonzales visualizes the importance so clearly (go RT it!):

We have all been there, and I really think we should not teach our students it is normal that you have to trust your current read and no be able to look up details. I do not know how much time Gonzales spent on traversing this trail, but it must not take more than a minute, IMHO. Clearly, any paper in this trail that is not Open, will require a look up, and if your library does not have access, an ILL will make the traverse much, much longer. Unacceptable. And many seem to agree, because Sci-Hub seems to be getting more popular every day. About the latter, almost two years ago I wrote Sci-Hub: a sign on the wall, but not a new sign.

Of course, in the end, it is the scholars that should just make their knowledge open, so that every citizen can benefit from it (keep in mind, a European goal is to educate half the population with higher education, so half of the population is basically able to read primary literature!).

That completes the circle back to the winner. After all, Bianca Kramer has done really important work on how scientists can exactly do that: make their research open. I was shocked to see this morning that Bianca did not have a Scholia page yet, but that is fixed now (though far from complete):

Other papers that you should be read more include:
Congratulations, Bianca!

Sunday, January 14, 2018

Faceted browsing of chemicals in Wikidata

A few days ago Aidan and José introduced GraFa on the Wikidata mailing list. It is a faceted browser for content in Wikidata, and the screenshot on the right shows that for chemical compounds. They are welcoming feedback.

GraFa run on things of type chemical compound.
Besides this screenshot, I have not played with it a lot. It looks quite promising, and my initial feedback would be a feature to sort the results, and ability to export the full list to some other tool, e.g. download all those items as RDF.

Saturday, January 06, 2018

"All things must come to an end"

Cover of the book.
No worries, this is just about my Groovy Cheminformatics book. Seven years ago I started a project that was very educational to me: self-publishing a book. With the help from I managed to get a book out that sold over 100 copies and that was regularly updated. But their lies the problem: supply creates demand. So, I had a system that supplied me with an automated set up that reran scripts, recreated text output and even figures for the book (2D chemical diagrams). I wanted to make an edition for every CDK release. All in all, I got quite far with that: eleven editions.

But the current research setting, or at least in academia, does not provide me with the means to keep this going. Sad thing is, the hardest part is actually updating the graphics for the cover, which needs to resize each time the book gets ticker. But John Mayfield introduced so many API changes, I just did not have the time to update the book. I tried, and I have a twelfth edition on my desk. But where my automated setup scales quite nicely, I don't.

It may we worth reiterating why I started the book. We have had several places where information was given, and questions were answered: the mailing list, wiki pages, JavaDoc, the Chemistry Toolkit Rosetta Wiki, and more. Nothing in the book was not already answered somewhere else. The book was just a boon for me to answer those questions and provide an easy way for people to get many answers.

Now, because I could not keep up with the recent API changes, I am no longer feeling comfortable with releasing the book. As such, I have "retired" the book.

I am now working out on how to move from here. An earlier edition is already online under a Creative Commons license, and it's tempting to release the latest version like this too. That said, I have also been talking with the other CDK project leaders about alternatives. More on this soon, I guess.

Here's an overview of posts about the book:

Saturday, December 30, 2017

Adding SMILES, InChI, etc to Wikidata alkane pages

Ten alkanes in Wikidata. The ones without CAS regsitry
number previously did not have InChIKey or
PubChem CID. But no more; I added those.
While working on the 'chemical class' aspect for Scholia yesterday I noted that the page for alkanes was quite large, with a list of more than 50 long chain alkanes with pages in the Japanese Wikipedia with no SMILES, InChI, InChIKey, etc.

So, I dug up my Bioclipse scripts to add chemicals to Wikidata starting with a SMILES (btw, the script has significantly evolved since) and extended the query of that Scholia aspect to list just the Wikidata Q-code and name.  This script starts with one or more SMILES strings and generated QuickStatements (a must-learner).

Because the Wikidata entries also had the English IUPAC name, I can use that to autogenerate SMILES. Enter the OPSIN (doi:10.1021/ci100384d) plugin for Bioclipse which in combination with the CDK allowed me to create the matching SMILES, InChI, InChIKey, and use the latter to look up the PubChem compound identifier (CID). This is the script I ended up with:

inputFile = "/Wikidata/Alkanes/alkanes.tsv"
new File(bioclipse.fullPath(inputFile)).eachLine { line ->
  fields = line.split("\t")
  if (fields[0].startsWith("")) {
    wdid = fields[0].substring("".length())
    name = fields[1]
    if (fields.length > 2) { // skip entities that already have an InChIKey
      inchikey = fields[2]
      // println "Skipping: $wdid $inchikey"
    } else { // ok, consider adding it
      // println "Considering $wdid $name"
      try {
        mol = opsin.parseIUPACName(name)
        smiles = cdk.calculateSMILES(
        //println "  SMILES: $smiles"
        println "${smiles}\t${wdid}"
      } catch (Exception error) {
        //println "Could not parse $name with OPSIN: ${error.message}" 

That way, I ended up with changes like this:

Friday, December 29, 2017

Using Scholia as Open Notebook Science tool to support literature searching

Source: Compound Interest, Andy Brunning.
I have blogged about Scholia and the underlying Wikidata before. Following the example of this WikiProject Zika Corpus I am using Scholia (doi:10.1007/978-3-319-70407-4_36, or in Scholia, of course :) as a tool to support a literature study, to collect articles about a certain topic. Previously I used it to track the publication trail around the Elsevier-SciHub interactions. But when I was linking the Compound Interest infographics for the Advent 2017 series to Wikidata items (aiming to archive them on Zenodo) and ran into the poisonous mistletoe graphics of day 9. In this graphics it mentions the phoratoxins. Sadly, not too much was recorded about that in Wikidata.

So, I did an quick scan of literature (about half an hour, using Google Scholar). I ended up with a few articles about the chemistry of this compound, and as good open scientists I used Wikidata and Scholia as a notebook:

From these papers I found reference to six specific, phoratoxins A-F, for which I subsequently created Wikidata items:

I have a lot to discover about these cyclic peptides and they cannot be found in PubChem or ChemSpider (yet):

The SPARQL I uses is as follows and can be run yourself (note the "edit" link in the left corner of this link):

SELECT ?mol ?molLabel ?InChIKey ?CAS ?ChemSpider ?PubChem_CID WITH {
      ?mol wdt:P31/wdt:P279* wd:Q46995757 .
    } LIMIT 500
  } AS %result
    INCLUDE %result
    OPTIONAL { ?mol wdt:P235 ?InChIKey }
    OPTIONAL { ?mol wdt:P231 ?CAS }
    OPTIONAL { ?mol wdt:P661 ?ChemSpider }
    OPTIONAL { ?mol wdt:P662 ?PubChem_CID }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }

And since I had a few other compound classes there, and in our metabolomics research too, of course, I finally hacked up an extension of Scholia for chemical classes (pull request pending). This is what it looks like for fatty acid:

That makes browsing information about chemicals in Wikidata a lot easier and support our effort to link WikiPathways to Wikidata considerable.

I also used this approach for other topics:

Looking at these pages again, it's great to see the community nature of Wikidata in action. The pages grow in richness over time :)