Skip to content

Commit

Permalink
Added the other four Tissue API methods
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Nov 14, 2015
1 parent ff4295d commit c4012f6
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/java/com/github/egonw/ops4j/Tissues.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,32 @@ public String info(List<String> uris, Object... objects) throws ClientProtocolEx
return runRequest(server + "tissue/batch", params, objects);
}

public String forProteinCount(String uri, Object... objects) throws ClientProtocolException, IOException, HttpException {
Map<String,String> params = new HashMap<String,String>();
params.put("uri", uri);
return runRequest(server + "tissue/byProtein/count", params, objects);
}

public String forProteinList(String uri, int page, int pageSize, Object... objects) throws ClientProtocolException, IOException, HttpException {
Map<String,String> params = new HashMap<String,String>();
params.put("uri", uri);
params.put("_page", Integer.toString(page));
params.put("_pageSize", Integer.toString(pageSize));
return runRequest(server + "tissue/byProtein", params, objects);
}

public String getProteinCount(String uri, Object... objects) throws ClientProtocolException, IOException, HttpException {
Map<String,String> params = new HashMap<String,String>();
params.put("uri", uri);
return runRequest(server + "tissue/getProteins/count", params, objects);
}

public String getProteinList(String uri, int page, int pageSize, Object... objects) throws ClientProtocolException, IOException, HttpException {
Map<String,String> params = new HashMap<String,String>();
params.put("uri", uri);
params.put("_page", Integer.toString(page));
params.put("_pageSize", Integer.toString(pageSize));
return runRequest(server + "tissue/getProteins", params, objects);
}

}
48 changes: 48 additions & 0 deletions src/test/java/com/github/egonw/ops4j/TissuesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,52 @@ public void infoBatch() throws ClientProtocolException, IOException, HttpExcepti
Assert.assertTrue(turtle.contains("ftp://ftp.nextprot.org/pub/current_release/controlled_vocabularies/caloha.obo#TS-0171"));
Assert.assertTrue(turtle.contains("ftp://ftp.nextprot.org/pub/current_release/controlled_vocabularies/caloha.obo#TS-0173"));
}

@Test
public void forProteinCount() throws ClientProtocolException, IOException, HttpException {
Tissues client = Tissues.getInstance(super.server, super.appID, super.appKey);
Assert.assertNotNull(client);
String turtle = client.forProteinCount("http://purl.uniprot.org/uniprot/P55795");
Assert.assertNotNull(turtle);
Assert.assertTrue(turtle.contains("prefix"));
Assert.assertTrue(turtle.contains("tissueExpressionTotalResults"));
Assert.assertFalse(turtle.contains(": 0,"));
}

@Test
public void forProteinList() throws ClientProtocolException, IOException, HttpException {
Tissues client = Tissues.getInstance(super.server, super.appID, super.appKey);
Assert.assertNotNull(client);
String turtle = client.forProteinList(
"http://purl.uniprot.org/uniprot/P55795",
1, 4
);
Assert.assertNotNull(turtle);
Assert.assertTrue(turtle.contains("prefix"));
Assert.assertTrue(turtle.contains("http://www.nextprot.org/db/search#NX_P55795"));
}

@Test
public void getProteinCount() throws ClientProtocolException, IOException, HttpException {
Tissues client = Tissues.getInstance(super.server, super.appID, super.appKey);
Assert.assertNotNull(client);
String turtle = client.getProteinCount("ftp://ftp.nextprot.org/pub/current_release/controlled_vocabularies/caloha.obo#TS-0016");
Assert.assertNotNull(turtle);
Assert.assertTrue(turtle.contains("prefix"));
Assert.assertTrue(turtle.contains("tissueExpressionTotalResults"));
Assert.assertFalse(turtle.contains(": 0,"));
}

@Test
public void getProteinList() throws ClientProtocolException, IOException, HttpException {
Tissues client = Tissues.getInstance(super.server, super.appID, super.appKey);
Assert.assertNotNull(client);
String turtle = client.getProteinList(
"ftp://ftp.nextprot.org/pub/current_release/controlled_vocabularies/caloha.obo#TS-0016",
1, 4
);
Assert.assertNotNull(turtle);
Assert.assertTrue(turtle.contains("prefix"));
Assert.assertTrue(turtle.contains("nextprot.org/"));
}
}

0 comments on commit c4012f6

Please sign in to comment.