Transcript
Page 1: How to use the Open PHACTS API

How to use the Open PHACTS API

Ian Dunlop

[email protected]

Page 2: How to use the Open PHACTS API

Go to https://dev.openphacts.org

Sign up, sign in or use the app ID/app Keys available from:

http://goo.gl/z3rWwZ

Page 3: How to use the Open PHACTS API

Use the API from the documentation

View results in a browser

Write some code

What shall we do?

Page 4: How to use the Open PHACTS API

Anatomy of an API 1

Required elements with a single value

Optional elements with a single value

Optional elements with a single value or array

Page 5: How to use the Open PHACTS API

Anatomy of an API 2

URI identifying the item you are interested in

Application ID created at https://dev.openphacts.orgApplication Key for the application ID created at https://dev.openphacts.org

Page 7: How to use the Open PHACTS API

Compound Pharmacology

Count

https://beta.openphacts.org/1.3/compound/pharmacology/count?uri=http%3A%2F%2Fwww.conceptwiki.org%2Fconcept%2F38932552-111f-4a4e-a46a-4ed1d7bdf9d5&app_id=a921aad5&app_key=1be1aa775de4126dab09d54ef95e5832&_format=json

http://goo.gl/DNG4uA

Page 8: How to use the Open PHACTS API

Compound Pharmacology

List (page 1, 10 results)

https://beta.openphacts.org/1.3/compound/pharmacology/pages?uri=http%3A%2F%2Fwww.conceptwiki.org%2Fconcept%2F38932552-111f-4a4e-a46a-4ed1d7bdf9d5&app_id=a921aad5&app_key=1be1aa775de4126dab09d54ef95e5832&_format=json

http://goo.gl/nw4YFQ

Page 9: How to use the Open PHACTS API

Compound Pharmacology Filters

How many results are there with an IC50 less than or equal to 1500nM?

Page 10: How to use the Open PHACTS API

Compound Pharmacology Filters

Answer: 146https://beta.openphacts.org/1.3/compound/pharmacology/count?uri=http%3A%2F%2Fwww.conceptwiki.org%2Fconcept%2F38932552-111f-4a4e-a46a-4ed1d7bdf9d5&app_id=a921aad5&app_key=1be1aa775de4126dab09d54ef95e5832&activity_type=IC50&max-activity_value=1500&activity_unit=nanomolar&_format=json

activity_type=IC50

max-activity_value=1500

activity_unit=nanomolar

http://goo.gl/BbHmKN

Page 11: How to use the Open PHACTS API

First 30 results?

Page 12: How to use the Open PHACTS API

First 30 results?

https://beta.openphacts.org/1.3/compound/pharmacology/pages?uri=http%3A%2F%2Fwww.conceptwiki.org%2Fconcept%2F38932552-111f-4a4e-a46a-4ed1d7bdf9d5&app_id=a921aad5&app_key=1be1aa775de4126dab09d54ef95e5832&activity_type=IC50&max-activity_value=1500&activity_unit=nanomolar&_page=1&_pageSize=30&_format=json

activity_type=IC50

max-activity_value=1500

activity_unit=nanomolar

_page=1

_pageSize=30

http://goo.gl/LQmDLz

Page 13: How to use the Open PHACTS API

Write some code

Open up zip (available from http://goo.gl/NaN5BJ)

Start with an empty HTML page– Open compound.html in your browser (file:///….)

Not much to see here– Loads OPS.js and jQuery

Page 14: How to use the Open PHACTS API

Write some code

Open the HTML in your favourite text editor

Add some magic (http://goo.gl/JvE4mt) inside the JavaScript code block

appID = "a921aad5";appKey = "1be1aa775de4126dab09d54ef95e5832";var searcher = new Openphacts.CompoundSearch("https://beta.openphacts.org/1.3", appID, appKey);var callback = function(success, status, response) { var compoundResult = searcher.parseCompoundResponse(response); $("#compound-info").append("I am " + compoundResult.prefLabel + " with molecular weight " + compoundResult.fullMWT); };searcher.fetchCompound('http://www.conceptwiki.org/concept/38932552-111f-4a4e-a46a-4ed1d7bdf9d5', null, callback);

Refresh your browser

Page 15: How to use the Open PHACTS API

Open PHACTS widgets

Collaboration with Biojs

http://openphacts.github.io/ops-html-widgets/

https://github.com/biojs/biojs

Page 16: How to use the Open PHACTS API

Useful links

https://dev.openphacts.org/docs/1.3

https://explorer.openphacts.org

http://jupiter.cs.man.ac.uk

https://github.com/openphacts/ops.js

https://github.com/biojs/biojs

http://goo.gl/JvE4mt (OPS.js code example)