Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a method to list compounds by dataset URI (and unit tests for b…
…oth listCompounds() methods
  • Loading branch information
egonw committed Aug 11, 2012
1 parent 3977f97 commit 0879da6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Expand Up @@ -188,6 +188,26 @@ CDKMolecule.INCHI_OBJECT, new InChI(
opentox.addMolecules(uriString, molecules);
}

@Test public void testListCompounds() throws Exception {
List<ICDKMolecule> molecules = cdk.createMoleculeList();
molecules.add(cdk.fromSMILES("COC"));
molecules.add(cdk.fromSMILES("CNC"));

String uriString = opentox.createDataset(TEST_SERVER_OT);
opentox.addMolecules(uriString, molecules);

// now do the testing
List<String> compounds = opentox.listCompounds(uriString);
Assert.assertNotNull(compounds);
Assert.assertEquals(2, compounds.size());
}

@Test public void testListCompoundsDataSet2() throws Exception {
List<Integer> compounds = opentox.listCompounds(TEST_SERVER_OT, 2);
Assert.assertNotNull(compounds);
Assert.assertNotSame(0, compounds.size());
}

@Test public void testCreateDataSetFromSet() throws Exception {
List<ICDKMolecule> molecules = cdk.createMoleculeList();
molecules.add(cdk.fromSMILES("COC"));
Expand Down
Expand Up @@ -299,6 +299,14 @@ public interface IOpentoxManager extends IBioclipseManager {
)
public List<Integer> listCompounds(String service, Integer dataSet) throws BioclipseException;

@Recorded
@PublishedMethod(
methodSummary=
"Lists the compounds available from the given data set.",
params="String dataSet"
)
public List<String> listCompounds(String dataSet) throws BioclipseException;

@Recorded
@PublishedMethod(
methodSummary=
Expand Down
Expand Up @@ -443,6 +443,11 @@ public List<String> listModels(String ontologyServer, IProgressMonitor monitor)

public List<Integer> listCompounds(String service, Integer dataSet,
IProgressMonitor monitor) throws BioclipseException {
return listCompounds(service + "dataset/" + dataSet, monitor);
}

public List<Integer> listCompounds(String dataSet,
IProgressMonitor monitor) throws BioclipseException {
List<Integer> compounds = new ArrayList<Integer>();

if (monitor == null) monitor = new NullProgressMonitor();
Expand All @@ -458,7 +463,7 @@ public List<Integer> listCompounds(String service, Integer dataSet,
// download the list of compounds as RDF
rdf.importURL(
store,
service + "dataset/" + dataSet + "/compound",
dataSet + "/compound",
extraHeaders,
monitor
);
Expand Down

0 comments on commit 0879da6

Please sign in to comment.