Commits

Anonymous committed 201b904

Added new deposit-nmr command (still pending to do actual work; currently, only NWChem duplication).

  • Participants
  • Parent commits be5eb4b

Comments (0)

Files changed (4)

         </dependency>
 
         <dependency>
+            <groupId>net.chempound.nmr</groupId>
+            <artifactId>nmr-importer</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>

src/main/java/uk/ac/cam/ch/wwmm/quixote/client/QuixoteClientCLI.java

 import uk.ac.cam.ch.wwmm.quixote.client.cif.DepositCifCommand;
 import uk.ac.cam.ch.wwmm.quixote.client.gaussian.DepositGaussianCommand;
 import uk.ac.cam.ch.wwmm.quixote.client.nwchem.DepositNWChemCommand;
+import uk.ac.cam.ch.wwmm.quixote.client.nmr.DepositNMRCommand;
 
 /**
  * @author Sam Adams
         addCommand(jCommander, "deposit-cif", new DepositCifCommand());
         addCommand(jCommander, "deposit-gaussian", new DepositGaussianCommand());
         addCommand(jCommander, "deposit-nwchem", new DepositNWChemCommand());
+        addCommand(jCommander, "deposit-nmr", new DepositNMRCommand());
     }
 }

src/main/java/uk/ac/cam/ch/wwmm/quixote/client/nmr/DepositNMRCommand.java

+package uk.ac.cam.ch.wwmm.quixote.client.nmr;
+
+import net.chempound.client.SwordUtil;
+import net.chempound.client.cli.command.DepositCommand;
+import net.chempound.client.cli.options.GlobalOptions;
+import net.chempound.nmr.NWChemLogImporter;
+import net.chempound.nmr.rdf.CompChemPersonalities;
+import org.apache.commons.io.FilenameUtils;
+import org.swordapp.client.Deposit;
+import org.swordapp.client.DepositReceipt;
+import org.swordapp.client.SWORDClient;
+
+import java.io.File;
+
+/**
+ * @author Sam Adams
+ */
+public class DepositNMRCommand extends DepositCommand {
+
+    static {
+        CompChemPersonalities.init();
+    }
+
+    private final DepositNMROptions depositOptions;
+
+    public DepositNMRCommand() {
+        super(new DepositNMROptions());
+        this.depositOptions = (DepositNMROptions) super.depositOptions;
+    }
+
+    @Override
+    public void invoke(final GlobalOptions globalOptions) {
+        NWChemLogImporter importer = new NWChemLogImporter();
+
+//        if (depositOptions.title != null) {
+//            importer.setTitle(depositOptions.title);
+//        }
+        if (depositOptions.slug != null) {
+            importer.setId(depositOptions.slug);
+        }
+
+        final String filename = depositOptions.files.get(0);
+        final File cifFile = globalOptions.workingDirectory == null ? new File(filename) : new File(globalOptions.workingDirectory, filename);
+        importer.setLogFile(cifFile, FilenameUtils.getName(filename));
+
+        final SWORDClient swordClient = new SWORDClient();
+        final String url = globalOptions.repository;
+        try {
+            final Deposit deposit = SwordUtil.createSwordDeposit(importer.generateDepositRequest());
+            final DepositReceipt receipt = swordClient.deposit(url, deposit);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

src/main/java/uk/ac/cam/ch/wwmm/quixote/client/nmr/DepositNMROptions.java

+package uk.ac.cam.ch.wwmm.quixote.client.nmr;
+
+import net.chempound.client.cli.options.DepositOptions;
+
+/**
+ * @author Sam Adams
+ */
+public class DepositNMROptions extends DepositOptions {
+}