Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added framework to convert the CDK data model into a JEna Model

  • Loading branch information...
commit 0fbe0e02cb7bcc4806fa3bb74a8d1c9130b54d1a 1 parent 5072305
Egon Willighagen egonw authored
4 build.xml
View
@@ -531,7 +531,7 @@
list="io,structgen"/>
<foreach target="compile-module" param="module"
parallel="${parallel}" maxthreads="${threadCount}"
- list="pdb,smiles,sdg,inchi,libiocml"/>
+ list="pdb,smiles,sdg,inchi,libiocml,iordf"/>
<foreach target="compile-module" param="module"
parallel="${parallel}" maxthreads="${threadCount}"
list="control,extra,reaction,pdbcml,libiomd"/>
@@ -569,7 +569,7 @@
parallel="${parallel}" maxthreads="${threadCount}"
list="test-data,test-qsaratomic,test-qsarbond,
test-pdb,test-smiles,test-extra,test-atomtype,
- test-structgen"/>
+ test-structgen,test-iordf"/>
<foreach target="compile-module" param="module" trim="true"
parallel="${parallel}" maxthreads="${threadCount}"
list="test-qsarmolecular,test-builder3d,test-datadebug,
BIN  jar/jena/commons-logging-1.1.1.jar
View
Binary file not shown
BIN  jar/jena/icu4j_3_4.jar
View
Binary file not shown
BIN  jar/jena/iri.jar
View
Binary file not shown
BIN  jar/jena/jena.jar
View
Binary file not shown
BIN  jar/jena/slf4j-api-1.5.6.jar
View
Binary file not shown
BIN  jar/jena/slf4j-simple-1.5.0.jar
View
Binary file not shown
7 src/META-INF/iordf.cdkdepends
View
@@ -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
16 src/META-INF/iordf.libdepends
View
@@ -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
13 src/META-INF/test-iordf.cdkdepends
View
@@ -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
2  src/META-INF/test-iordf.devellibdepends
View
@@ -0,0 +1,2 @@
+junit-4.5.jar
+
16 src/META-INF/test-iordf.libdepends
View
@@ -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
63 src/main/org/openscience/cdk/libio/jena/Convertor.java
View
@@ -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 src/test/org/openscience/cdk/libio/jena/ConvertorTest.java
View
@@ -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());
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.