Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added framework to convert the CDK data model into a JEna Model
- Loading branch information
Showing
14 changed files
with
172 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cdk-annotation.jar | ||
cdk-interfaces.jar | ||
cdk-ioformats.jar | ||
cdk-core.jar | ||
cdk-standard.jar | ||
cdk-atomtype.jar | ||
cdk-io.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
vecmath1.2-1.14.jar | ||
jena/antlr-2.7.5.jar | ||
jena/arq-extra.jar | ||
jena/arq.jar | ||
jena/commons-logging-1.1.1.jar | ||
jena/concurrent.jar | ||
jena/icu4j_3_4.jar | ||
jena/iri.jar | ||
jena/jena.jar | ||
jena/json.jar | ||
jena/log4j-1.2.12.jar | ||
jena/lucene-core-2.3.1.jar | ||
jena/slf4j-simple-1.5.0.jar | ||
jena/stax-api-1.0.jar | ||
jena/wstx-asl-3.0.0.jar | ||
jena/xml-apis.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cdk-annotation.jar | ||
cdk-interfaces.jar | ||
cdk-ioformats.jar | ||
cdk-core.jar | ||
cdk-standard.jar | ||
cdk-atomtype.jar | ||
cdk-io.jar | ||
cdk-iordf.jar | ||
cdk-diff.jar | ||
cdk-data.jar | ||
cdk-nonotify.jar | ||
cdk-test.jar | ||
cdk-test-io.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
junit-4.5.jar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
vecmath1.2-1.14.jar | ||
jena/antlr-2.7.5.jar | ||
jena/arq-extra.jar | ||
jena/arq.jar | ||
jena/commons-logging-1.1.1.jar | ||
jena/concurrent.jar | ||
jena/icu4j_3_4.jar | ||
jena/iri.jar | ||
jena/jena.jar | ||
jena/json.jar | ||
jena/log4j-1.2.12.jar | ||
jena/lucene-core-2.3.1.jar | ||
jena/slf4j-simple-1.5.0.jar | ||
jena/stax-api-1.0.jar | ||
jena/wstx-asl-3.0.0.jar | ||
jena/xml-apis.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net> | ||
* | ||
* Contact: jchempaint-devel@lists.sourceforge.net | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
* All we ask is that proper credit is given for our work, which includes | ||
* - but is not limited to - adding the above copyright notice to the beginning | ||
* of your source code files, and to any copyright notice that you may distribute | ||
* with programs based on this work. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
package org.openscience.cdk.libio.jena; | ||
|
||
import org.openscience.cdk.interfaces.IChemObjectBuilder; | ||
import org.openscience.cdk.interfaces.IMolecule; | ||
|
||
import com.hp.hpl.jena.rdf.model.Model; | ||
import com.hp.hpl.jena.rdf.model.ModelFactory; | ||
import com.hp.hpl.jena.rdf.model.Resource; | ||
import com.hp.hpl.jena.vocabulary.RDF; | ||
|
||
/** | ||
* @cdk.module iordf | ||
* @cdk.githash | ||
* @cdk.keyword Resource Description Framework | ||
* @cdk.keyword Jena | ||
* @cdk.keyword RDF | ||
* @cdk.keyword Web Ontology Language | ||
* @cdk.keyword OWL | ||
*/ | ||
public class Convertor { | ||
|
||
public static Model molecule2Model(IMolecule molecule) { | ||
Model model = ModelFactory.createOntologyModel(); | ||
model.setNsPrefix("cdk", "http://cdk.sourceforge.net/model.owl#"); | ||
Resource subject = model.createResource( | ||
"http://cdk.sf.net/model/molecule/" + 1 | ||
); | ||
model.add( | ||
subject, RDF.type, | ||
model.createResource("cdk:Molecule") | ||
); | ||
return model; | ||
} | ||
|
||
public static IMolecule model2Molecule(Model model, | ||
IChemObjectBuilder builder) { | ||
IMolecule mol = builder.newMolecule(); | ||
return mol; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
src/test/org/openscience/cdk/libio/jena/ConvertorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net> | ||
* | ||
* Contact: cdk-devel@lists.sourceforge.net | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
* All we ask is that proper credit is given for our work, which includes | ||
* - but is not limited to - adding the above copyright notice to the beginning | ||
* of your source code files, and to any copyright notice that you may distribute | ||
* with programs based on this work. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
package org.openscience.cdk.libio.jena; | ||
|
||
import junit.framework.Assert; | ||
|
||
import org.junit.Test; | ||
import org.openscience.cdk.CDKTestCase; | ||
import org.openscience.cdk.interfaces.IChemObjectBuilder; | ||
import org.openscience.cdk.interfaces.IMolecule; | ||
import org.openscience.cdk.nonotify.NNMolecule; | ||
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder; | ||
import org.openscience.cdk.tools.diff.AtomContainerDiff; | ||
|
||
import com.hp.hpl.jena.rdf.model.Model; | ||
|
||
/** | ||
* @cdk.module test-iordf | ||
*/ | ||
public class ConvertorTest extends CDKTestCase { | ||
|
||
private static IChemObjectBuilder builder = | ||
NoNotificationChemObjectBuilder.getInstance(); | ||
|
||
@Test public void roundtripMolecule() { | ||
IMolecule mol = new NNMolecule(); | ||
Model model = Convertor.molecule2Model(mol); | ||
IMolecule rtMol = Convertor.model2Molecule(model, builder); | ||
String diff = AtomContainerDiff.diff(mol, rtMol); | ||
Assert.assertEquals(0, diff.length()); | ||
} | ||
|
||
} |