Commits

gigadot  committed 09d2cf7

Added ChemID to CompChemCML

  • Participants
  • Parent commits a03f962

Comments (0)

Files changed (1)

File semsci-converters-chem/src/main/java/gigadot/semsci/converters/chem/CompChemCML2RDF.java

 import gigadot.semsci.converters.chem.uri.HasURIGenerator;
 import gigadot.semsci.converters.chem.uri.URIGenerator;
 import gigadot.semsci.chem.schema.CompChemSematics;
+import nu.xom.Node;
+import org.xmlcml.cml.element.CMLIdentifier;
 
 /**
  *
             // N3:       a qm:Computation;
             Resource unq_com_res = compchemModel.createResource(
                     createUUIDURIString(cml), CompChemSematics.qmComputation);
-            // N3:       cml:representedBy <./target/CH4.cml>;
-            unq_com_res.addProperty(CompChemSematics.cmlrdfRepresentedBy, path_res);
-            // N3:       cml:representedBy <./target/CH4.cml>;
-            unq_com_res.addProperty(CompChemSematics.cmlrdfRepresentedBy, path_res);
-            unq_com_res.addProperty(CompChemSematics.cmlrdfRepresentedBy, path_res);
+
+            CMLModule joblist_mod = (CMLModule) joblist_nodes.get(0);
+            // N3:       chemid:EmpiricalFormula "H4O4Si";
+            Nodes id_nodes = joblist_mod.query("./cml:identifier", CMLNamespace.CML_XPATH);
+            for (int i = 0; i < id_nodes.size(); i++) {
+                CMLIdentifier id = (CMLIdentifier) id_nodes.get(i);
+                if (id.getConvention().equals("chemid:EmpiricalFormula")) {
+                    unq_com_res.addProperty(CompChemSematics.chemidEmpiricalFormula, id.getCMLValue());
+                } else if (id.getConvention().equals("chemid:CanonicalSmiles")) {
+                    unq_com_res.addProperty(CompChemSematics.chemidCanonicalSmiles, id.getCMLValue());
+                } else if (id.getConvention().equals("chemid:IsomericSmiles")) {
+                    unq_com_res.addProperty(CompChemSematics.chemidIsomericSmiles, id.getCMLValue());
+                } else if (id.getConvention().equals("chemid:InChI")) {
+                    unq_com_res.addProperty(CompChemSematics.chemidInChI, id.getCMLValue());
+                }
+            }
+
             // N3:       qm:jobs ( jim:job1 ).
 
-            CMLModule joblist_mod = (CMLModule) joblist_nodes.get(0);
             // expecting a series of job module
             Nodes job_nodes = joblist_mod.query("./cml:module[@role='job']", CMLNamespace.CML_XPATH);
             List<RDFNode> jobs_rdf_list = new ArrayList<RDFNode>(job_nodes.size());
         compchemModel.setNsPrefix("cmlrdf", CompChemSematics.CMLRDF_SCHEMA_NS);
         compchemModel.setNsPrefix("qm", CompChemSematics.CMLQMRDF_SCHEMA_NS);
         compchemModel.setNsPrefix("chem", CompChemSematics.CMLAXIOM_NS);
+        compchemModel.setNsPrefix("chemid", CompChemSematics.CHEMID_NS);
         compchemModel.setNsPrefix("xsd", CompChemSematics.XSD_NS);
         compchemModel.setNsPrefix("rdf", CompChemSematics.RDF_NS);
     }
 //    public Type getInputType() {
 //        return Type.CML;
 //    }
-
     public Element convertToXML(Element xml) {
         Model compchemModel = null;
         try {