Skip to content

Commit

Permalink
First method done: listOrganisms
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Dec 20, 2015
1 parent e5f0f32 commit e976ed1
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.Rcheck/
*.tar.*
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
language: r
sudo: required
11 changes: 11 additions & 0 deletions rWikiPathways/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: rWikiPathways
Type: Package
Title: rWikiPathways - R client library for the WikiPathways API
Version: 0.0.1
Date: 2015-12-20
Author: Egon Willighagen <egon.willighagen@maastrichtuniversity.nl>
Maintainer: Egon Willighagen <egon.willighagen@maastrichtuniversity.nl>
Depends: jsonlite, curl, plyr
Suggests: testthat
Description: Use this package to interface with the WikiPathways API.
License: MIT + file LICENSE
2 changes: 2 additions & 0 deletions rWikiPathways/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2015
COPYRIGHT HOLDER: Egon L Willighagen
7 changes: 7 additions & 0 deletions rWikiPathways/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
importFrom(jsonlite, fromJSON)
importFrom(curl, curl, new_handle, handle_setheaders)
importFrom(plyr, laply)

export(
listOrganisms
)
11 changes: 11 additions & 0 deletions rWikiPathways/R/listOrganisms.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
listOrganisms <- function() {
handle = new_handle()
handle_setheaders(handle, "User-Agent" = "r/rwikipathways")
handle_setheaders(handle, "Accept" = "application/json")

url = paste("http://webservice.wikipathways.org/listOrganisms?format=json", sep="")
conn <- curl::curl(url, handle, open="r")
txt <- readLines(conn, warn=FALSE)
close(conn)
data = fromJSON(txt)$organisms
}
20 changes: 20 additions & 0 deletions rWikiPathways/man/listOrganisms.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
\name{listOrganisms}
\alias{listOrganisms}
\title{
Lists the organisms available from the WikiPathways API server
}
\description{
Lists the organisms available from the WikiPathways API server
}
\usage{
listOrganisms()
}
\value{
\item{data}{the available organisms}
}
\examples{
organisms <- listOrganisms()
}
\author{
Egon Willighagen
}
4 changes: 4 additions & 0 deletions rWikiPathways/tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(rWikiPathways)

test_check("rWikiPathways")
8 changes: 8 additions & 0 deletions rWikiPathways/tests/testthat/test-listOrganisms.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
library(rWikiPathways)
context("Lists")

test_that("organisms are found", {
organisms = listOrganisms()
expect_that(nrow(organisms), not(equals(0)))
expect_true("Anopheles gambiae" %in% organisms)
})

0 comments on commit e976ed1

Please sign in to comment.