Commits

Sam Adams committed 4236c0d

Refactoring CompChem Importers

Comments (0)

Files changed (10)

compchem-importer/src/main/java/net/chempound/compchem/CmlComp2RdfConverter.java

 import com.hp.hpl.jena.vocabulary.OWL;
 import com.hp.hpl.jena.vocabulary.RDF;
 import com.hp.hpl.jena.vocabulary.RDFS;
+import com.hp.hpl.jena.vocabulary.XSD;
 import net.chempound.chemistry.Cml2RdfConverter;
 import net.chempound.compchem.rdf.ont.CompChem;
 import net.chempound.rdf.DCTerms;
 import net.chempound.rdf.cml.CmlRdf;
 import net.chempound.rdf.dc.DCUtils;
+import nu.xom.Document;
 import nu.xom.Elements;
 import nu.xom.Nodes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.xmlcml.cml.base.CMLConstants;
 import org.xmlcml.cml.element.*;
 
 import java.net.URI;
     private static final String CMLCOMP_ENVIRONMENT = COMP_NS + "environment";
     private static final String CMLCOMP_FINALIZATION = COMP_NS + "finalization";
 
+    public Model generateModel(final Document document, final URI baseUri) {
+        final CMLModule jobList = getJobList(document);
+        return generateModel(jobList, baseUri);
+    }
+    
     public Model generateModel(final CMLModule jobList, final URI baseUri) {
         final Model model = ModelFactory.createDefaultModel();
         generateModel(jobList, model.getResource(baseUri.toString()));
         model.setNsPrefix("cml", CmlRdf.getURI());
         model.setNsPrefix("compchem", CompChem.getURI());
         model.setNsPrefix("gaussian", "http://www.xml-cml.org/dictionary/gaussian/");
+        model.setNsPrefix("xsd", XSD.getURI());
         model.setNsPrefix("dc", DCTerms.getURI());
 
         final List<CMLModule> jobs = CompChemTool.getJobs(jobList);
         throw new IllegalArgumentException("Unsupported identifer: " + convention);
     }
 
+    private CMLModule getJobList(final Document doc) {
+        final Nodes nodes = doc.query("//cml:module[substring-after(@dictRef, ':') = 'jobList']", CMLConstants.CML_XPATH);
+        if (nodes.size() == 0) {
+            throw new RuntimeException("No joblist!");
+        }
+        return (CMLModule) nodes.get(0);
+    }
+
 }

compchem-importer/src/main/java/net/chempound/compchem/CompChemCmlUtils.java

+package net.chempound.compchem;
+
+import nu.xom.Document;
+import nu.xom.Element;
+import nu.xom.Nodes;
+import nu.xom.XPathContext;
+
+/**
+ * @author Sam Adams
+ */
+public class CompChemCmlUtils {
+
+    private static final XPathContext CML_XPATH_CONTEXT = new XPathContext("cml", "http://www.xml-cml.org/schema");
+
+    public static Element getMoleculeFromJob(final Document document) {
+        final Element molecule = getMoleculeFromInitialisation(document);
+        if (molecule != null) {
+            return molecule;
+        }
+        return getMoleculeFromFinalization(document);
+    }
+
+    public static Element getJobList(final Document doc) {
+        final Nodes nodes = doc.query("//cml:module[substring-after(@dictRef, ':') = 'jobList']", CML_XPATH_CONTEXT);
+        if (nodes.size() == 0) {
+            throw new RuntimeException("No joblist!");
+        }
+        return (Element) nodes.get(0);
+    }
+
+    private static Element getMoleculeFromInitialisation(final Document document) {
+        final Nodes nodes = document.query("//cml:module[contains(@dictRef, ':job')]/cml:module[contains(@dictRef, ':initialization')]/cml:molecule", CML_XPATH_CONTEXT);
+        if (nodes.size() != 0) {
+            return (Element) nodes.get(0);
+        }
+        return null;
+    }
+
+    private static Element getMoleculeFromFinalization(final Document document) {
+        final Nodes nodes = document.query("//cml:module[contains(@dictRef, ':job')]/cml:module[contains(@dictRef, ':finalization')]/cml:molecule", CML_XPATH_CONTEXT);
+        if (nodes.size() != 0) {
+            return (Element) nodes.get(0);
+        }
+        return null;
+    }
+    
+}

compchem-importer/src/main/java/net/chempound/compchem/CompChemImporter.java

 
 import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.sparql.vocabulary.FOAF;
 import com.hp.hpl.jena.vocabulary.RDFS;
 import net.chempound.chemistry.CmlImporter;
 import net.chempound.chemistry.ImageGenerator;
 import net.chempound.storage.DepositResource;
 import net.chempound.storage.LocalResource;
 import nu.xom.Document;
-import nu.xom.Node;
-import nu.xom.Nodes;
-import org.xmlcml.cml.base.CMLConstants;
-import org.xmlcml.cml.base.CMLUtil;
 import org.xmlcml.cml.element.CMLModule;
 import org.xmlcml.cml.element.CMLMolecule;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.xmlcml.cml.base.CMLConstants.CML_XPATH;
+import static net.chempound.compchem.CompChemCmlUtils.getJobList;
+import static net.chempound.compchem.CompChemCmlUtils.getMoleculeFromJob;
 
 public abstract class CompChemImporter extends CmlImporter {
 
             depositRequest.addResource(resource);
         }
 
-        final CMLModule jobList = getJobList(doc);
+        final CMLModule jobList = (CMLModule) getJobList(doc);
 
         final CmlComp2RdfConverter converter = new CmlComp2RdfConverter();
         final Model model = converter.generateModel(jobList, URI.create(""));
         createImageResources(doc, getId() == null ? generateId() : getId());
 
         final ChempoundAggregation item = depositRequest.getResourceMetadata();
-//        addResources(depositRequest, item);
         attachImages(depositRequest);
 
         addType(item);
         return depositRequest;
     }
 
-    protected void addResources(final DepositRequest loadRequest, final ChempoundAggregation item) {
-        if (imageResource != null) {
-            loadRequest.addResource(imageResource);
-            item.addProperty(FOAF.img, imageResource);
+    protected void createImageResources(final Document doc, final String id) throws IOException {
+        final CMLMolecule molecule = (CMLMolecule) getMoleculeFromJob(doc);
+        if (molecule == null) {
+            throw new RuntimeException("Unable to locate molecule");
         }
-        if (thumbnailResource != null) {
-            loadRequest.addResource(thumbnailResource);
-            item.addProperty(FOAF.thumbnail, thumbnailResource);
-        }
-    }
-
-    private CMLModule getJobList(final Document doc) {
-        final Nodes nodes = doc.query("//cml:module[substring-after(@dictRef, ':') = 'jobList']", CMLConstants.CML_XPATH);
-        if (nodes.size() == 0) {
-            throw new RuntimeException("No joblist!");
-        }
-        return (CMLModule) nodes.get(0);
-    }
-
-    protected void createImageResources(final Document doc, final String id) throws IOException {
-        final List<Node> nodes = CMLUtil.getQueryNodes(doc, "//cml:module[@dictRef='cc:initialization' or @dictRef='cc:finalization']/cml:molecule", CML_XPATH);
-        if (nodes.isEmpty()) {
-            throw new RuntimeException("No molecule found!");
-        }
-        createImages((CMLMolecule) nodes.get(nodes.size() - 1), id);
+        createImages(molecule, id);
     }
 
     protected void addType(final ChempoundAggregation item) {

compchem-importer/src/main/java/net/chempound/compchem/GaussianLogImporter.java

-package net.chempound.compchem;
-
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.vocabulary.RDFS;
-import net.chempound.chemistry.ImageGenerator;
-import net.chempound.chemistry.InChIGenerator;
-import net.chempound.chemistry.cml.ChemicalMime;
-import net.chempound.compchem.rdf.ont.CompChem;
-import net.chempound.rdf.DCTerms;
-import net.chempound.rdf.chempound.ChempoundAggregation;
-import net.chempound.storage.DepositResource;
-import net.chempound.storage.InMemoryResource;
-import net.chempound.storage.LocalFileResource;
-import net.chempound.storage.LocalResource;
-import nu.xom.Document;
-import nu.xom.Element;
-import nu.xom.Node;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.xmlcml.cml.base.CMLUtil;
-import org.xmlcml.cml.converters.compchem.gaussian.log.GaussianLog2XMLConverter;
-import org.xmlcml.cml.converters.compchem.gaussian.log.GaussianLogXML2CompchemConverter;
-import org.xmlcml.cml.element.CMLMolecule;
-
-import javax.inject.Inject;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import static org.xmlcml.cml.base.CMLConstants.CML_XPATH;
-
-/**
- * @author Sam Adams
- */
-public class GaussianLogImporter extends CompChemImporter {
-
-    public static final String GAUSSIAN_CALC = "http://www.xml-cml.org/dictionary/gaussian/Calculation";
-
-    protected LocalResource inputFile;
-    protected LocalResource logFile;
-
-    public GaussianLogImporter() {
-        this(new ImageGenerator(), new InChIGenerator());
-    }
-
-    @Inject
-    public GaussianLogImporter(final ImageGenerator imageGenerator, final InChIGenerator inchiGenerator) {
-        super(imageGenerator, inchiGenerator);
-    }
-
-    public LocalResource getInputFile() {
-        return inputFile;
-    }
-
-    public void setInputFile(final InputStream in, final String path) throws IOException {
-        inputFile = new InMemoryResource(path, ChemicalMime.CHEMICAL_GAUSSIAN_INPUT, in);
-    }
-
-    public void setInputFile(final File file, final String path) {
-        inputFile = new LocalFileResource(path, file);
-    }
-
-
-    public LocalResource getLogFile() {
-        return logFile;
-    }
-
-    public void setLogFile(final InputStream in, final String path) throws IOException {
-        logFile = new InMemoryResource(path, ChemicalMime.CHEMICAL_GAUSSIAN_LOG, in);
-    }
-
-    public void setLogFile(final File file, final String path) {
-        logFile = new LocalFileResource(path, file, ChemicalMime.CHEMICAL_GAUSSIAN_LOG);
-    }
-
-    @Override
-    protected String generateId() {
-        final String filename = logFile.getPath();
-        final String ext = FilenameUtils.getExtension(filename).toLowerCase();
-        if ("log".equals(ext) || "txt".equals(ext) || "out".equals(ext) || "gau".equals(ext)) {
-            final int l = filename.length();
-            return filename.substring(0, l - (ext.length() + 1));
-        }
-        return filename;
-    }
-
-    @Override
-    protected Document generateCml() throws Exception {
-        if (logFile == null) {
-            throw new IllegalStateException("Logfile must be specifed");
-        }
-
-        final Element cml = convertLogToCml(logFile);
-        final Document doc = reloadCml(cml);
-        final List<Node> molecules = CMLUtil.getQueryNodes(doc, "//cml:molecule", CML_XPATH);
-        for (final Node node : molecules) {
-            attachIdentifiers((CMLMolecule) node);
-        }
-        return doc;
-    }
-
-    @Override
-    protected void addResources(final List<DepositResource> resources) {
-        if (inputFile != null) {
-            resources.add(inputFile);
-        }
-        resources.add(logFile);
-        super.addResources(resources);
-    }
-
-    @Override
-    protected void addType(final ChempoundAggregation item) {
-        final Resource compChemType = item.getModel().getResource(CompChem.Calculation.getURI());
-        item.addProperty(DCTerms.type, compChemType);
-
-        final Resource gauType = item.getModel().getResource(GAUSSIAN_CALC);
-        gauType.addLiteral(RDFS.label, "Gaussian Calculation");
-        item.addProperty(DCTerms.type, gauType);
-    }
-
-
-    private Element convertLogToCml(final LocalResource logFile) throws IOException {
-        final InputStream in = logFile.openInputStream();
-        try {
-            return convertLogToCml(in);
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
-    }
-
-    private Element convertLogToCml(final InputStream in) {
-        final Element xml = convertLogToXml(in);
-        final GaussianLogXML2CompchemConverter converter = new GaussianLogXML2CompchemConverter();
-        return converter.convertToXML(xml);
-    }
-
-    private Element convertLogToXml(final InputStream in) {
-        final GaussianLog2XMLConverter converter = new GaussianLog2XMLConverter();
-        return converter.convertToXML(in);
-    }
-
-}

compchem-importer/src/main/java/net/chempound/compchem/NWChemLogImporter.java

-package net.chempound.compchem;
-
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.vocabulary.RDFS;
-import net.chempound.chemistry.ImageGenerator;
-import net.chempound.chemistry.InChIGenerator;
-import net.chempound.chemistry.cml.ChemicalMime;
-import net.chempound.chemistry.inchi.InchiTool;
-import net.chempound.compchem.rdf.ont.CompChem;
-import net.chempound.rdf.DCTerms;
-import net.chempound.rdf.chempound.ChempoundAggregation;
-import net.chempound.storage.DepositResource;
-import net.chempound.storage.InMemoryResource;
-import net.chempound.storage.LocalFileResource;
-import net.chempound.storage.LocalResource;
-import nu.xom.Document;
-import nu.xom.Element;
-import nu.xom.ParsingException;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2XMLConverter;
-import org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLogXML2CompchemConverter;
-
-import javax.inject.Inject;
-import java.io.*;
-import java.util.List;
-
-/**
- * @author Sam Adams
- */
-public class NWChemLogImporter extends CompChemImporter {
-
-    public static final String NWCHEM_CALC = "http://www.xml-cml.org/dictionary/nwchem/Calculation";
-
-    protected LocalResource inputFile;
-    protected LocalResource logFile;
-
-    public NWChemLogImporter() {
-        this(new ImageGenerator(), new InChIGenerator());
-    }
-
-    @Inject
-    public NWChemLogImporter(final ImageGenerator imageGenerator, final InChIGenerator inchiGenerator) {
-        super(imageGenerator, inchiGenerator);
-    }
-
-    public LocalResource getInputFile() {
-        return inputFile;
-    }
-
-    public void setInputFile(final InputStream in, final String path) throws IOException {
-        inputFile = new InMemoryResource(path, ChemicalMime.CHEMICAL_NWCHEM, in);
-    }
-
-    public void setInputFile(final File file, final String path) throws IOException {
-        final BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
-        try {
-            setInputFile(in, path);
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
-    }
-
-
-    public LocalResource getLogFile() {
-        return logFile;
-    }
-
-    public void setLogFile(final InputStream in, final String path) throws IOException {
-        logFile = new InMemoryResource(path, ChemicalMime.CHEMICAL_NWCHEM, in);
-    }
-
-    public void setLogFile(final File file, final String path) {
-        logFile = new LocalFileResource(path, file, ChemicalMime.CHEMICAL_NWCHEM);
-    }
-
-    @Override
-    protected String generateId() {
-        final String filename = logFile.getPath();
-        final String ext = FilenameUtils.getExtension(filename).toLowerCase();
-        if ("log".equals(ext) || "txt".equals(ext) || "out".equals(ext)) {
-            final int l = filename.length();
-            return filename.substring(0, l - (ext.length() + 1));
-        }
-        return filename;
-    }
-
-    @Override
-    protected Document generateCml() throws IOException, ParsingException {
-        final Element cml = convertLogToCml(logFile);
-        final Document doc = reloadCml(cml);
-        InchiTool.attachIdentifiers(doc);
-        return doc;
-    }
-
-    @Override
-    protected void addResources(final List<DepositResource> resources) {
-        if (inputFile != null) {
-            resources.add(inputFile);
-        }
-        resources.add(logFile);
-        super.addResources(resources);
-    }
-
-    @Override
-    protected void addType(final ChempoundAggregation item) {
-        final Resource compChemType = item.getModel().getResource(CompChem.Calculation.getURI());
-        item.addProperty(DCTerms.type, compChemType);
-
-        final Resource nwchemType = item.getModel().getResource(NWCHEM_CALC);
-        nwchemType.addLiteral(RDFS.label, "NWChem Calculation");
-        item.addProperty(DCTerms.type, nwchemType);
-    }
-
-
-    private Element convertLogToCml(final LocalResource logFile) throws IOException {
-        final InputStream in = logFile.openInputStream();
-        try {
-            return convertLogToCml(in);
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
-    }
-
-    private Element convertLogToCml(final InputStream in) {
-        final Element xml = convertLogToXml(in);
-        final NWChemLogXML2CompchemConverter converter = new NWChemLogXML2CompchemConverter();
-        return converter.convertToXML(xml);
-    }
-
-    private Element convertLogToXml(final InputStream in) {
-        final NWChemLog2XMLConverter converter = new NWChemLog2XMLConverter();
-        return converter.convertToXML(in);
-    }
-
-}

compchem-importer/src/main/java/net/chempound/compchem/gaussian/GaussianLogImporter.java

+package net.chempound.compchem.gaussian;
+
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.vocabulary.RDFS;
+import net.chempound.chemistry.ImageGenerator;
+import net.chempound.chemistry.InChIGenerator;
+import net.chempound.chemistry.cml.ChemicalMime;
+import net.chempound.compchem.CompChemImporter;
+import net.chempound.compchem.rdf.ont.CompChem;
+import net.chempound.rdf.DCTerms;
+import net.chempound.rdf.chempound.ChempoundAggregation;
+import net.chempound.storage.DepositResource;
+import net.chempound.storage.InMemoryResource;
+import net.chempound.storage.LocalFileResource;
+import net.chempound.storage.LocalResource;
+import nu.xom.Document;
+import nu.xom.Element;
+import nu.xom.Node;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.xmlcml.cml.base.CMLUtil;
+import org.xmlcml.cml.converters.compchem.gaussian.log.GaussianLog2XMLConverter;
+import org.xmlcml.cml.converters.compchem.gaussian.log.GaussianLogXML2CompchemConverter;
+import org.xmlcml.cml.element.CMLMolecule;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import static org.xmlcml.cml.base.CMLConstants.CML_XPATH;
+
+/**
+ * @author Sam Adams
+ */
+public class GaussianLogImporter extends CompChemImporter {
+
+    public static final String GAUSSIAN_CALC = "http://www.xml-cml.org/dictionary/gaussian/Calculation";
+
+    protected LocalResource inputFile;
+    protected LocalResource logFile;
+
+    public GaussianLogImporter() {
+        this(new ImageGenerator(), new InChIGenerator());
+    }
+
+    @Inject
+    public GaussianLogImporter(final ImageGenerator imageGenerator, final InChIGenerator inchiGenerator) {
+        super(imageGenerator, inchiGenerator);
+    }
+
+    public LocalResource getInputFile() {
+        return inputFile;
+    }
+
+    public void setInputFile(final InputStream in, final String path) throws IOException {
+        inputFile = new InMemoryResource(path, ChemicalMime.CHEMICAL_GAUSSIAN_INPUT, in);
+    }
+
+    public void setInputFile(final File file, final String path) {
+        inputFile = new LocalFileResource(path, file);
+    }
+
+
+    public LocalResource getLogFile() {
+        return logFile;
+    }
+
+    public void setLogFile(final InputStream in, final String path) throws IOException {
+        logFile = new InMemoryResource(path, ChemicalMime.CHEMICAL_GAUSSIAN_LOG, in);
+    }
+
+    public void setLogFile(final File file, final String path) {
+        logFile = new LocalFileResource(path, file, ChemicalMime.CHEMICAL_GAUSSIAN_LOG);
+    }
+
+    @Override
+    protected String generateId() {
+        final String filename = logFile.getPath();
+        final String ext = FilenameUtils.getExtension(filename).toLowerCase();
+        if ("log".equals(ext) || "txt".equals(ext) || "out".equals(ext) || "gau".equals(ext)) {
+            final int l = filename.length();
+            return filename.substring(0, l - (ext.length() + 1));
+        }
+        return filename;
+    }
+
+    @Override
+    protected Document generateCml() throws Exception {
+        if (logFile == null) {
+            throw new IllegalStateException("Logfile must be specifed");
+        }
+
+        final Element cml = convertLogToCml(logFile);
+        final Document doc = reloadCml(cml);
+        final List<Node> molecules = CMLUtil.getQueryNodes(doc, "//cml:molecule", CML_XPATH);
+        for (final Node node : molecules) {
+            attachIdentifiers((CMLMolecule) node);
+        }
+        return doc;
+    }
+
+    @Override
+    protected void addResources(final List<DepositResource> resources) {
+        if (inputFile != null) {
+            resources.add(inputFile);
+        }
+        resources.add(logFile);
+        super.addResources(resources);
+    }
+
+    @Override
+    protected void addType(final ChempoundAggregation item) {
+        final Resource compChemType = item.getModel().getResource(CompChem.Calculation.getURI());
+        item.addProperty(DCTerms.type, compChemType);
+
+        final Resource gauType = item.getModel().getResource(GAUSSIAN_CALC);
+        gauType.addLiteral(RDFS.label, "Gaussian Calculation");
+        item.addProperty(DCTerms.type, gauType);
+    }
+
+
+    private Element convertLogToCml(final LocalResource logFile) throws IOException {
+        final InputStream in = logFile.openInputStream();
+        try {
+            return convertLogToCml(in);
+        } finally {
+            IOUtils.closeQuietly(in);
+        }
+    }
+
+    private Element convertLogToCml(final InputStream in) {
+        final Element xml = convertLogToXml(in);
+        final GaussianLogXML2CompchemConverter converter = new GaussianLogXML2CompchemConverter();
+        return converter.convertToXML(xml);
+    }
+
+    private Element convertLogToXml(final InputStream in) {
+        final GaussianLog2XMLConverter converter = new GaussianLog2XMLConverter();
+        return converter.convertToXML(in);
+    }
+
+}

compchem-importer/src/main/java/net/chempound/compchem/nwchem/NWChemLogImporter.java

+package net.chempound.compchem.nwchem;
+
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.vocabulary.RDFS;
+import net.chempound.chemistry.ImageGenerator;
+import net.chempound.chemistry.InChIGenerator;
+import net.chempound.chemistry.cml.ChemicalMime;
+import net.chempound.chemistry.inchi.InchiTool;
+import net.chempound.compchem.CompChemImporter;
+import net.chempound.compchem.rdf.ont.CompChem;
+import net.chempound.rdf.DCTerms;
+import net.chempound.rdf.chempound.ChempoundAggregation;
+import net.chempound.storage.DepositResource;
+import net.chempound.storage.InMemoryResource;
+import net.chempound.storage.LocalFileResource;
+import net.chempound.storage.LocalResource;
+import nu.xom.Document;
+import nu.xom.Element;
+import nu.xom.ParsingException;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2XMLConverter;
+import org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLogXML2CompchemConverter;
+
+import javax.inject.Inject;
+import java.io.*;
+import java.util.List;
+
+/**
+ * @author Sam Adams
+ */
+public class NWChemLogImporter extends CompChemImporter {
+
+    public static final String NWCHEM_CALC = "http://www.xml-cml.org/dictionary/nwchem/Calculation";
+
+    protected LocalResource inputFile;
+    protected LocalResource logFile;
+
+    public NWChemLogImporter() {
+        this(new ImageGenerator(), new InChIGenerator());
+    }
+
+    @Inject
+    public NWChemLogImporter(final ImageGenerator imageGenerator, final InChIGenerator inchiGenerator) {
+        super(imageGenerator, inchiGenerator);
+    }
+
+    public LocalResource getInputFile() {
+        return inputFile;
+    }
+
+    public void setInputFile(final InputStream in, final String path) throws IOException {
+        inputFile = new InMemoryResource(path, ChemicalMime.CHEMICAL_NWCHEM, in);
+    }
+
+    public void setInputFile(final File file, final String path) throws IOException {
+        final BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
+        try {
+            setInputFile(in, path);
+        } finally {
+            IOUtils.closeQuietly(in);
+        }
+    }
+
+
+    public LocalResource getLogFile() {
+        return logFile;
+    }
+
+    public void setLogFile(final InputStream in, final String path) throws IOException {
+        logFile = new InMemoryResource(path, ChemicalMime.CHEMICAL_NWCHEM, in);
+    }
+
+    public void setLogFile(final File file, final String path) {
+        logFile = new LocalFileResource(path, file, ChemicalMime.CHEMICAL_NWCHEM);
+    }
+
+    @Override
+    protected String generateId() {
+        final String filename = logFile.getPath();
+        final String ext = FilenameUtils.getExtension(filename).toLowerCase();
+        if ("log".equals(ext) || "txt".equals(ext) || "out".equals(ext)) {
+            final int l = filename.length();
+            return filename.substring(0, l - (ext.length() + 1));
+        }
+        return filename;
+    }
+
+    @Override
+    protected Document generateCml() throws IOException, ParsingException {
+        final Element cml = convertLogToCml(logFile);
+        final Document doc = reloadCml(cml);
+        InchiTool.attachIdentifiers(doc);
+        return doc;
+    }
+
+    @Override
+    protected void addResources(final List<DepositResource> resources) {
+        if (inputFile != null) {
+            resources.add(inputFile);
+        }
+        resources.add(logFile);
+        super.addResources(resources);
+    }
+
+    @Override
+    protected void addType(final ChempoundAggregation item) {
+        final Resource compChemType = item.getModel().getResource(CompChem.Calculation.getURI());
+        item.addProperty(DCTerms.type, compChemType);
+
+        final Resource nwchemType = item.getModel().getResource(NWCHEM_CALC);
+        nwchemType.addLiteral(RDFS.label, "NWChem Calculation");
+        item.addProperty(DCTerms.type, nwchemType);
+    }
+
+
+    private Element convertLogToCml(final LocalResource logFile) throws IOException {
+        final InputStream in = logFile.openInputStream();
+        try {
+            return convertLogToCml(in);
+        } finally {
+            IOUtils.closeQuietly(in);
+        }
+    }
+
+    private Element convertLogToCml(final InputStream in) {
+        final Element xml = convertLogToXml(in);
+        final NWChemLogXML2CompchemConverter converter = new NWChemLogXML2CompchemConverter();
+        return converter.convertToXML(xml);
+    }
+
+    private Element convertLogToXml(final InputStream in) {
+        final NWChemLog2XMLConverter converter = new NWChemLog2XMLConverter();
+        return converter.convertToXML(in);
+    }
+
+}

compchem-importer/src/test/java/net/chempound/compchem/GaussianImporterTest.java

 import com.hp.hpl.jena.rdf.model.RDFReader;
 import net.chempound.chemistry.ImageGenerator;
 import net.chempound.chemistry.InChIGenerator;
+import net.chempound.compchem.gaussian.GaussianLogImporter;
 import net.chempound.compchem.rdf.CompChemCalculation;
 import net.chempound.compchem.rdf.CompChemPersonalities;
 import net.chempound.content.DepositRequest;

compchem-test-harness/src/test/java/net/chempound/compchem/CompChemIntegrationTest.java

 import net.chempound.DefaultChempoundModule;
 import net.chempound.chemistry.ImageGenerator;
 import net.chempound.chemistry.InChIGenerator;
+import net.chempound.compchem.gaussian.GaussianLogImporter;
 import net.chempound.config.ChempoundConfiguration;
 import net.chempound.config.DefaultChempoundConfiguration;
 import net.chempound.content.DepositRequest;

compchem-test-harness/src/test/java/net/chempound/compchem/CompChemSearchIntegrationTest.java

 import net.chempound.chemistry.ImageGenerator;
 import net.chempound.chemistry.InChIGenerator;
 import net.chempound.client.SwordUtil;
+import net.chempound.compchem.gaussian.GaussianLogImporter;
 import net.chempound.config.ChempoundConfiguration;
 import net.chempound.config.DefaultChempoundConfiguration;
 import net.chempound.content.DepositRequest;