Help:WikiPathways Webservice

From WikiPathways

(Difference between revisions)
Jump to: navigation, search
m
Current revision (19:15, 30 August 2021) (view source)
m (Protected "Help:WikiPathways Webservice" [edit=sysop:move=sysop])
 
(21 intermediate revisions not shown.)
Line 3: Line 3:
{|
{|
  |
  |
-
WikiPathways can be accessed programmatically through a [[wikipedia:Web_service#Service-oriented_architecture|SOAP web service]]. Web services provide <span class="plainlinks">[http://www.straitstimes.com/BreakingNews/Singapore/Story/STIStory_681222.html <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">Susan Lim</span>] powerful means to query, access and interact with the pathway content at WikiPathways. Read all about it in this [http://dx.plos.org/10.1371/journal.pone.0006447 PLoS ONE article].
+
WikiPathways can be accessed programmatically through a REST web service. These services provide powerful means to query, access and interact with the pathway content at WikiPathways.  
  |rowspan="2" valign="top"|__TOC__
  |rowspan="2" valign="top"|__TOC__
  |-
  |-
  |
  |
-
== Showcase ==
 
-
{|style="width:75%;" border="0" valign="top" cellspacing="5" cellpadding="1"
 
-
|colspan="2"|
 
-
{|border="0" align="center" cellpadding="1"
 
-
  |-
 
-
  |align="center"|<big>'''Search'''</big>
 
-
  |-
 
-
|
 
-
{|border="0" align="center" cellpadding="1"
 
-
  |-
 
-
  |align="center"|<big>'''Query interactions'''</big>
 
-
  |-
 
-
  |
 
-
  {|style="background:#ceceff;border:0px;" border="1" cellpadding="1" align="center"
 
-
  |-
 
-
  |align="center"|[http://www.pathvisio.org/Cytoscape_plugin http://www.wikipathways.org/img_auth.php/c/c4/Cytoscape200.png]
 
-
  |}
 
-
  |-
 
-
  |align="center"|''Load pathways as interaction networks in Cytoscape''
 
-
|}
 
-
|
 
-
{|border="0" align="center" cellpadding="1"
 
-
  |-
 
-
  |align="center"|<big>'''Build workflows'''</big>
 
-
  |-
 
-
  |
 
-
  {|style="border:0px;" border="1" cellpadding="1" align="center"
 
-
  |-
 
-
  |align="center"|[http://www.myexperiment.org/packs/30 http://www.wikipathways.org/img_auth.php/f/f6/Taverna200.png]
 
-
  |}
 
-
  |-
 
-
  |align="center"|''Use pathway information in your Taverna workflows''
 
-
|}
 
-
|}
 
-
|}
 
-
 
-
''Note:'' The Atlas Mapper showcase has been discontinued, as the ArrayExpress Atlas team took down the SOAP service that this showcase depends on. [[Help:WikiPathways_Webservice/AtlasMapper|On this page]], you can still find the source code for examples of how to use the WikiPathways web service.
 
-
 
-
== Test Drive ==
 
-
Take the WikiPathways web service for a full-featured test drive:
 
-
# Install the free testing tool, [http://www.soapui.org/ SoapUI] ''(web start version is also available)''.
 
-
# Load [http://www.wikipathways.org/wpi/webservice/webservice.php?wsdl our WSDL file].
 
-
 
-
== How to cite ==
 
-
Kelder T, Pico AR, Hanspers K, van Iersel MP, Evelo C, Conklin BR. (2009) '''Mining Biological Pathways Using WikiPathways Web Services.''' PLoS ONE 4(7): [http://www.plosone.org/article/info:doi/10.1371/journal.pone.0006447 doi:10.1371/journal.pone.0006447]
 
== API Reference ==
== API Reference ==
-
See the [[{{FULLPAGENAME}}/API|API reference]] page for a list of available web service functions and data structures.
+
See the [https://webservice.wikipathways.org Swagger] page for a list of available web service functions and data structures.
=== Java libraries ===
=== Java libraries ===
-
You can get a high-level API to the WikiPathways web service here: [http://www.pathvisio.org/browser/trunk/modules/org.wikipathways.client source] [http://pathvisio.org/data/releases compiled binaries] (choose the most recent wikipathways_client_bin-*).
+
You can get a high-level API to the WikiPathways web service here: [http://developers.pathvisio.org/browser/trunk/modules/org.wikipathways.client source] [http://developers.pathvisio.org/data/releases compiled binaries] (choose the most recent wikipathways_client_bin-*).
=== Working with GPML ===
=== Working with GPML ===
-
The pathways on WikiPathways are stored in the GPML format. This is an XML format and can be processed in any programming language. See [http://www.pathvisio.org/EverythingGPML here] for the GPML specification. If you are developing in Java, we recommend using our [[#Java libraries|Java libraries]].
+
The pathways on WikiPathways are stored in the GPML format. This is an XML format and can be processed in any programming language. See [http://developers.pathvisio.org/wiki/EverythingGpml here] for the GPML specification. If you are developing in Java, we recommend using our [[#Java libraries|Java libraries]].
-
=== SOAP libraries ===
+
=== Libraries ===
-
For most programming languages, libraries exist to make working with SOAP web service easier. Below is a short list of SOAP libraries for popular programming languages that might help you work with the WikiPathways web service.
+
Below is a short list of libraries for popular programming languages that might help you work with the WikiPathways web service.
-
* Java:
+
* R: The rWikiPathways package with vignettes at [https://bioconductor.org/packages/release/bioc/html/rWikiPathways.html bioconductor].
-
** [http://ws.apache.org/axis/java/index.html Apache Axis]
+
* Java: Java API client with code examples at [https://github.com/wikipathways/wikipathways-api-client-java github].
-
** See the [[#Java|Java example code]]
+
* Perl: Perl API client with code examples at [https://github.com/wikipathways/wikipathways-api-client-perl github].
-
* Perl:
+
* Php: Example scripts at [https://github.com/wikipathways/scripts/ github].
-
** [http://www.soaplite.com/ SOAP::Lite]
+
* Python: Python API client with code examples at [https://github.com/wikipathways/wikipathways-api-client-py github].
-
** See the [[#Perl|Perl example code]]
+
-
* Php:
+
-
** [http://nl.php.net/soap SOAP] (official php soap library)
+
-
** [http://phpsoaptoolkit.sourceforge.net/phpsoap/ PHP-SOAP]
+
-
* Python:
+
-
** [http://pywebsvcs.sourceforge.net/ SOAPpy]
+
-
** [http://trac.optio.webfactional.com/ soaplib]
+
-
** See the [[#Python|Python example code]]
+
-
* R
+
-
** [http://www.omegahat.org/SSOAP/ SSOAP]
+
-
** See the [[#R|R example code]]
+
-
== Example Code ==
+
== Other Examples ==
-
Below you find some small example scripts in various languages that may help to get you started.
+
-
 
+
-
=== Java ===
+
-
Use the [[#Java libraries|wikipathways-client and PathVisio libraries]] to access the WikiPathways web service from Java. Below is a short example program in Java.
+
-
 
+
-
<pre>
+
-
package org.pathvisio.wikipathways;
+
-
 
+
-
import java.io.File;
+
-
import java.net.URL;
+
-
 
+
-
import org.bridgedb.Xref;
+
-
import org.bridgedb.bio.BioDataSource;
+
-
import org.pathvisio.model.ObjectType;
+
-
import org.pathvisio.model.Pathway;
+
-
import org.pathvisio.model.PathwayElement;
+
-
import org.pathvisio.wikipathways.WikiPathwaysClient;
+
-
import org.pathvisio.wikipathways.webservice.WSPathway;
+
-
import org.pathvisio.wikipathways.webservice.WSPathwayInfo;
+
-
import org.pathvisio.wikipathways.webservice.WSSearchResult;
+
-
 
+
-
public class Example {
+
-
public static void main(String[] args) {
+
-
try {
+
-
//Create a client to the WikiPathways web service
+
-
WikiPathwaysClient client = new WikiPathwaysClient(
+
-
new URL("http://www.wikipathways.org/wpi/webservice/webservice.php")
+
-
);
+
-
+
-
//Find a pathway by affymetrix probeset
+
-
Xref affy = new Xref("201746_at", BioDataSource.AFFY);
+
-
System.out.println("Searching for pathways with Affymetrix probeset " + affy);
+
-
 
+
-
WSSearchResult[] result = client.findPathwaysByXref(affy);
+
-
for(WSSearchResult r : result) {
+
-
System.out.println("Found pathway: " + r.getName() + " (" + r.getSpecies() + ")");
+
-
}
+
-
+
-
//Download a pathway from WikiPathways
+
-
WSPathway wsPathway = client.getPathway("WP274");
+
-
System.out.println("Downloaded pathway " + wsPathway.getName() +
+
-
", revision " + wsPathway.getRevision());
+
-
//Create a pathway object
+
-
Pathway pathway = WikiPathwaysClient.toPathway(wsPathway);
+
-
+
-
//Get all genes, proteins and metabolites for a pathway
+
-
for(PathwayElement pwElm : pathway.getDataObjects()) {
+
-
//Only take elements with type DATANODE (genes, proteins, metabolites)
+
-
if(pwElm.getObjectType() == ObjectType.DATANODE) {
+
-
//Print information to the screen
+
-
System.out.println(pwElm.getTextLabel());
+
-
System.out.println("\t" + pwElm.getXref());
+
-
System.out.println("\t" + pwElm.getDataNodeType());
+
-
}
+
-
}
+
-
+
-
//Save the pathway locally
+
-
pathway.writeToXml(new File(wsPathway.getName() + ".gpml"), true);
+
-
+
-
//Print info for all WikiPathways pathways
+
-
WSPathwayInfo[] pathwayList = client.listPathways();
+
-
+
-
for(WSPathwayInfo pathwayInfo : pathwayList) {
+
-
System.out.println("Pathway:");
+
-
System.out.println("\tIdentifier:\t" + pathwayInfo.getId());
+
-
System.out.println("\tName:\t" + pathwayInfo.getName());
+
-
System.out.println("\tOrganism:\t" + pathwayInfo.getSpecies());
+
-
}
+
-
} catch(Exception e) {
+
-
e.printStackTrace();
+
-
}
+
-
}
+
-
}
+
-
</pre>
+
-
 
+
-
Once you downloaded the libraries and compiled the Example class, you can run it with
+
-
<pre>
+
-
java -classpath wikipathways-client.jar:. org.pathvisio.wikipathways.Example
+
-
</pre>
+
-
 
+
-
=== Perl ===
+
-
This is a short example of a few ways to interact with the WikiPathways web service in Perl.
+
-
 
+
-
<pre>
+
-
#!perl -w
+
-
use strict;
+
-
 
+
-
# Load module
+
-
use SOAP::Lite;
+
-
 
+
-
# Debugging (optional)
+
-
#SOAP::Lite->import(+trace => qw(debug));
+
-
 
+
-
# Create service interface with fault handler
+
-
my $wp_soap = SOAP::Lite
+
-
->proxy('http://www.wikipathways.org/wpi/webservice/webservice.php')
+
-
->uri('http://www.wikipathways.org/webservice')
+
-
->on_fault(sub {
+
-
my $soap = shift;
+
-
my $res = shift;
+
-
 
+
-
# Map faults to exceptions
+
-
if(ref($res) eq '') {
+
-
die($res);
+
-
} else {
+
-
die($res->faultstring);
+
-
}
+
-
return new SOAP::SOM;
+
-
} );
+
-
 
+
-
# listOrganisms (no args; returns array of strings)
+
-
my @orgList = $wp_soap->listOrganisms()->paramsout;
+
-
unshift(@orgList, $wp_soap->listOrganisms()->result); #add first result to list
+
-
$" = ", ";  # change list separator
+
-
print "listOrganisms: @orgList\n";
+
-
 
+
-
# getPathwayInfo (one arg; returns hash reference)
+
-
my $pwId = SOAP::Data->name(pwId => "WP274");
+
-
my $pathwayInfo =  $wp_soap->getPathwayInfo($pwId)->result;
+
-
# Access data via hash reference
+
-
print "\ngetPathwayInfo(pwId=WP274):\n";
+
-
foreach my $key (keys %{$pathwayInfo}) {
+
-
print "\t$key: $pathwayInfo->{$key}\n";
+
-
}
+
-
 
+
-
# findPathwaysByXref (multiple args; returns array of hash references)
+
-
my $argsXrefData = SOAP::Data->name(
+
-
ids => '201746_at',
+
-
codes => 'X',
+
-
);
+
-
my @foundPathwayRefList = $wp_soap->findPathwaysByXref($argsXrefData)->paramsout;
+
-
unshift(@foundPathwayRefList, $wp_soap->findPathwaysByXref($argsXrefData)->result); #add first result to list
+
-
print "\nfindPathwaysByXref(id=201746_at, code=X):\n";
+
-
foreach my $ref (@foundPathwayRefList){
+
-
foreach my $key (keys %{ $ref}){
+
-
if ($key =~ /^fields$/){ # Print all fields
+
-
foreach my $f (@{ $ref->{$key} }) {
+
-
my $name = $f->{'name'};
+
-
my $value = $f->{'values'};
+
-
print "$name: $value";
+
-
}
+
-
} else {
+
-
print "\t$key: $ref->{$key}\n";
+
-
}
+
-
}
+
-
}
+
-
</pre>
+
-
 
+
-
 
+
-
Here's another example that call getColoredPathway() to color an element on the pathway blue:
+
-
<pre>
+
-
use strict;
+
-
 
+
-
# Load module
+
-
use SOAP::Lite;
+
-
use MIME::Base64;
+
-
 
+
-
# Debugging (optional)
+
-
#SOAP::Lite->import(+trace => qw(debug));
+
-
 
+
-
# Create service interface with fault handler
+
-
my $wp_soap = SOAP::Lite
+
-
      ->proxy('http://www.wikipathways.org/wpi/webservice/webservice.php')
+
-
      ->uri('http://www.wikipathways.org/webservice')
+
-
      ->on_fault(sub {
+
-
              my $soap = shift;
+
-
              my $res = shift;
+
-
              # Map faults to exceptions
+
-
              if(ref($res) eq '') {
+
-
                      die($res);
+
-
              } else {
+
-
                      die($res->faultstring);
+
-
              }
+
-
              return new SOAP::SOM;
+
-
          } );
+
-
 
+
-
# Color the pathway element on pathway WP722 identified by GraphID 'c8d79' blue.
+
-
my $pwId = SOAP::Data->name(pwId => "WP722");
+
-
my $color=SOAP::Data->name(color => "0000FF");
+
-
my $graphId=SOAP::Data->name(graphId=>"c8d79");
+
-
# Use the latest revision of the pathway.
+
-
my $revision=SOAP::Data->name(revision => 0);
+
-
# Return image in SVG format.
+
-
my $fileType=SOAP::Data->name(fileType => 'svg');
+
-
 
+
-
my $graph=$wp_soap->getColoredPathway($pwId,$revision,$graphId,$color,$fileType)->result;
+
-
open (FILE, ">test.svg");
+
-
binmode(FILE);
+
-
my $decoded = decode_base64($graph);
+
-
syswrite(FILE, $decoded);
+
-
close(FILE);
+
-
</pre>
+
-
 
+
-
=== Python ===
+
-
This is a short example of a few ways to interact with the WikiPathways web service in Python.
+
-
 
+
-
<pre>
+
-
# Print out function for query results (see code below function first)
+
-
def printOutput(ws_output):
+
-
    #Loops through a list of dictionary items
+
-
    index=1
+
-
    for object in ws_output:
+
-
        #calls select dictionary keys to print out values
+
-
        print_output = '  '+str(index)+')'+'species:'+object['species']+'\t '
+
-
        print_output+= 'id:'+object['id']+'\t '+'name:'+object['name']
+
-
        print print_output
+
-
        index+=1
+
-
 
+
-
# Load SOAPpy and dependent modules (fpconst) and access the remote
+
-
# SOAP server through a proxy class, SOAPProxy - see:
+
-
# (http://diveintopython.org/soap_web_services/first_steps.html)
+
-
from SOAPpy import SOAPProxy     
+
-
url = 'http://www.wikipathways.org/wpi/webservice/webservice.php'
+
-
namespace = 'http://www.wikipathways.org/webservice'
+
-
server = SOAPProxy(url, namespace)
+
-
 
+
-
# listOrganisms (no args; returns list of strings)
+
-
wp_organisms = server.listOrganisms()
+
-
print '\nSupported organisms at WikiPathways'
+
-
index=1
+
-
for organism in wp_organisms:
+
-
    print '  '+str(index)+')',organism; index+=1
+
-
 
+
-
# getPathwayInfo (one arg; returns dictionary reference)
+
-
pathway = 'WP274'
+
-
pathway_info = server.getPathwayInfo(pwId = pathway)
+
-
print '\nPathway information for %s' % pathway
+
-
# Access data via dictionary reference
+
-
printOutput([pathway_info])
+
-
 
+
-
# findPathwaysByText (multiple args; returns list of dictionary references)
+
-
pathway = 'apoptosis'   
+
-
apoptosis_containing = server.findPathwaysByText(query= pathway, species = "")
+
-
print '\nPathways containing the term %s' % pathway
+
-
printOutput(apoptosis_containing)
+
-
 
+
-
# Define the order of args: needed for this service
+
-
server.config.argsOrdering = {'findPathwaysByXref': ('ids', 'codes') }
+
-
 
+
-
# findPathwaysByXref (multiple args; returns list of dictionary references)
+
-
sc = 'X'; gi = '201746_at'
+
-
probeset_containing = server.findPathwaysByXref(codes=sc, ids=gi )
+
-
print '\nPathways containing the gene ID "%s" for system code "%s"' % (gi,sc)
+
-
printOutput(probeset_containing)
+
-
</pre>
+
-
 
+
-
=== R ===
+
-
Using the [http://www.omegahat.org/SSOAP/ SSOAP] package in [http://www.r-project.org R], you can retrieve pathway information from the WikiPathways web service and use it in your R scripts. Below are a few code snippets that show you how to use SSOAP with the WikiPathways web service. See [[{{FULLPAGENAME}}/Gene set enrichment in R|this page]] for a more extensive example, where we perform gene set enrichment on WikiPathways pathways using the [http://www.bioconductor.org/packages/2.4/bioc/html/PGSEA.html PGSEA library].
+
-
 
+
-
<pre><nowiki>
+
-
## Install SSOAP from Bioconductor ##
+
-
source("http://bioconductor.org/biocLite.R")
+
-
biocLite("SSOAP")
+
-
 
+
-
## Load the SSOAP library ##
+
-
library(SSOAP)
+
-
 
+
-
## Create a SOAPServer instance for the web service ##
+
-
srv = SOAPServer("http://www.wikipathways.org/wpi/webservice/webservice.php");
+
-
 
+
-
## List all organisms on WikiPathways ##
+
-
reply = .SOAP(srv, "listOrganisms", action=I("listOrganisms"), handlers=NULL)
+
-
doc = xmlParse(reply$content, asText=TRUE)
+
-
organismNodes = xmlElementsByTagName(xmlRoot(doc), "organisms", TRUE)
+
-
 
+
-
for(node in organismNodes) {
+
-
print(xmlValue(node)) #Print the organism name to the screen
+
-
}
+
-
 
+
-
## Find all pathways for the 'apoptosis' keyword ##
+
-
reply = .SOAP(srv, "findPathwaysByText", query="apoptosis", species="", action=I("findPathwaysByText"), handlers=NULL)
+
-
doc = xmlParse(reply$content, asText=TRUE)
+
-
 
+
-
# Find the result nodes with an xpath query
+
-
resultNodes = getNodeSet(doc, "//*[local-name()='result']")
+
-
# Print the pathway name, species and url for each result
+
-
for(node in resultNodes) {
+
-
children = xmlChildren(node, addNames= TRUE)
+
-
url = xmlValue(children$url)
+
-
name = xmlValue(children$name);
+
-
species = xmlValue(children$species);
+
-
+
-
print(paste(name, " (", species, "): ", url, sep=""))
+
-
}
+
-
</nowiki></pre>
+
-
 
+
-
=== PHP ===
+
-
<pre><nowiki>
+
-
<?php
+
-
 
+
-
$client = new
+
-
SoapClient('http://www.wikipathways.org/wpi/webservice/webservice.php?wsdl');
+
-
//Show all functions in the WikiPathways webservice
+
-
var_dump($client->__getFunctions());
+
-
 
+
-
// Show all pathways in an object
+
-
var_dump($client->listPathways());
+
-
 
+
-
//List all pathway names
+
-
$pathways = $client->listPathways();
+
-
foreach ($pathways->pathways as $pathway){
+
-
    print $pathway->name."\n";
+
-
}
+
-
 
+
-
//Get pathway Info of Pathway with pwId WP274
+
-
var_dump($client->getPathwayInfo(array('pwId'=>'WP274')));
+
-
 
+
-
//Get pathway history
+
-
var_dump($client->getPathwayHistory(array('pwId'=>'WP716', 'timestamp'
+
-
=> '0')));
+
-
 
+
-
?>
+
-
</nowiki></pre>
+
=== Groovy ===
=== Groovy ===
Line 402: Line 33:
[http://www.helixsoft.nl/blog/?p=153 This blog post] contains an example of how to use the WikiPathways webservice in Groovy.
[http://www.helixsoft.nl/blog/?p=153 This blog post] contains an example of how to use the WikiPathways webservice in Groovy.
-
=== Shell script ===
+
== How to cite ==
-
Andra Waagmeester contributed several linux shell scripts to call the web service: [http://www.bigcat.unimaas.nl/~andra/WP_bashscripts/ download the scripts here].
+
Kelder T, Pico AR, Hanspers K, van Iersel MP, Evelo C, Conklin BR. (2009) '''Mining Biological Pathways Using WikiPathways Web Services.''' PLoS ONE 4(7): [http://www.plosone.org/article/info:doi/10.1371/journal.pone.0006447 doi:10.1371/journal.pone.0006447]
-
The [http://xmlstar.sourceforge.net xmlstarlet] tool makes it easy to parse the results. Below is an example on how to parse the results.
+
-
 
+
-
<pre><nowiki>
+
-
./listPathways.sh |\
+
-
sed "s/<[A-Za-z0-9]*:/</g"|\ # remove the namespaces
+
-
sed "s/<\/[A-Za-z0-9]*:/<\//g"|\ # remove the closing namespaces
+
-
 
+
-
xml sel -t -m //pathways -v "concat(id,',',name,',',species,',',revision,',',url)" -n
+
-
</nowiki></pre>
+
-----
-----
<p>[[:Help:Contents|Return to Help Contents]]</p>
<p>[[:Help:Contents|Return to Help Contents]]</p>

Current revision

Web Services for WikiPathways

WikiPathways can be accessed programmatically through a REST web service. These services provide powerful means to query, access and interact with the pathway content at WikiPathways.

Contents

API Reference

See the Swagger page for a list of available web service functions and data structures.

Java libraries

You can get a high-level API to the WikiPathways web service here: source compiled binaries (choose the most recent wikipathways_client_bin-*).

Working with GPML

The pathways on WikiPathways are stored in the GPML format. This is an XML format and can be processed in any programming language. See here for the GPML specification. If you are developing in Java, we recommend using our Java libraries.

Libraries

Below is a short list of libraries for popular programming languages that might help you work with the WikiPathways web service.

  • R: The rWikiPathways package with vignettes at bioconductor.
  • Java: Java API client with code examples at github.
  • Perl: Perl API client with code examples at github.
  • Php: Example scripts at github.
  • Python: Python API client with code examples at github.

Other Examples

Groovy

This blog post contains an example of how to use the WikiPathways webservice in Groovy.

How to cite

Kelder T, Pico AR, Hanspers K, van Iersel MP, Evelo C, Conklin BR. (2009) Mining Biological Pathways Using WikiPathways Web Services. PLoS ONE 4(7): doi:10.1371/journal.pone.0006447


Return to Help Contents

Personal tools