Skip to content
Browse files

Added the OPSIN 0.9.0, with manager method parseIUPACName()

  • Loading branch information...
1 parent 34c3c5b commit ee1914a2c13a40712066e6c1743a996631029ce7 @egonw egonw committed Nov 19, 2010
View
7 features/net.bioclipse.chemoinformatics_feature/feature.xml
@@ -583,4 +583,11 @@ The Eclipse Public License accompanies this distribution, and is available at ht
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="net.bioclipse.opsin"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
View
8 plugins/net.bioclipse.opsin/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="lib" path="jar/opsin-0.9.0.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
28 plugins/net.bioclipse.opsin/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.bioclipse.opsin</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
19 plugins/net.bioclipse.opsin/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Opsin
+Bundle-SymbolicName: net.bioclipse.opsin; singleton:=true
+Bundle-Version: 2.4.2
+Bundle-Activator: net.bioclipse.opsin.Activator
+Export-Package: net.bioclipse.opsin, net.bioclipse.opsin.business
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ net.bioclipse.core,
+ net.bioclipse.scripting,
+ org.springframework.bundle.spring.aop,
+ net.sf.cglib,
+ org.springframework.osgi.aopalliance.osgi,
+ net.bioclipse.cdk.business
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .,
+ jar/opsin-0.9.0.jar
View
68 plugins/net.bioclipse.opsin/META-INF/spring/context.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+ <osgi:service id="javaOpsinManagerOSGI"
+ ref="javaOpsinManager"
+ interface="net.bioclipse.opsin.business.IJavaOpsinManager" />
+
+ <osgi:service id="javaScriptOpsinManagerOSGI"
+ ref="javaScriptOpsinManager"
+ interface="net.bioclipse.opsin.business.IJavaScriptOpsinManager" />
+
+ <osgi:reference id="recordingAdvice"
+ interface="net.bioclipse.recording.IRecordingAdvice" />
+
+ <osgi:reference id="javaManagerDispatcherAdvisor"
+ interface="net.bioclipse.managers.business.IJavaManagerDispatcherAdvisor" />
+
+ <osgi:reference id="javaScriptManagerDispatcherAdvisor"
+ interface="net.bioclipse.managers.business.IJavaScriptManagerDispatcherAdvisor" />
+
+ <osgi:reference id="wrapInProxyAdvice"
+ interface="net.bioclipse.recording.IWrapInProxyAdvice" />
+
+ <bean id="recordingAdvisor"
+ class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
+ <property name="advice" ref="recordingAdvice" />
+ <property name="pattern" value=".*" /> <!-- See also class implementation -->
+ </bean>
+
+ <bean id="OpsinManagerTarget"
+ class="net.bioclipse.opsin.business.OpsinManager">
+ </bean>
+
+ <bean id="javaScriptOpsinManager"
+ class="org.springframework.aop.framework.ProxyFactoryBean">
+ <property name="target"
+ ref="OpsinManagerTarget" />
+ <property name="proxyInterfaces"
+ value="net.bioclipse.opsin.business.IJavaScriptOpsinManager" />
+ <property name="interceptorNames" >
+ <list>
+ <value>recordingAdvisor</value>
+ <value>wrapInProxyAdvice</value>
+ <value>javaScriptManagerDispatcherAdvisor</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="javaOpsinManager"
+ class="org.springframework.aop.framework.ProxyFactoryBean">
+ <property name="target"
+ ref="OpsinManagerTarget" />
+ <property name="proxyInterfaces"
+ value="net.bioclipse.opsin.business.IJavaOpsinManager" />
+ <property name="interceptorNames" >
+ <list>
+ <value>recordingAdvisor</value>
+ <value>wrapInProxyAdvice</value>
+ <value>javaManagerDispatcherAdvisor</value>
+ </list>
+ </property>
+ </bean>
+</beans>
View
11 plugins/net.bioclipse.opsin/build.properties
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ jar/,\
+ jar/opsin-0.9.0.jar
+source.. = src/
+source.jar/opsin-0.9.0.jar =
+jars.compile.order = jar/opsin-0.9.0.jar,\
+ .
View
BIN plugins/net.bioclipse.opsin/jar/opsin-0.9.0.jar
Binary file not shown.
View
13 plugins/net.bioclipse.opsin/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="net.bioclipse.scripting.contribution">
+ <scriptContribution
+ service="net.bioclipse.opsin.business.OpsinManagerFactory"
+ id="net.bioclipse.opsin.business.OpsinManager">
+ </scriptContribution>
+ </extension>
+
+</plugin>
View
105 plugins/net.bioclipse.opsin/src/net/bioclipse/opsin/Activator.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Egon Willighagen <egon.willighagen@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.opsin;
+
+import net.bioclipse.opsin.business.IOpsinManager;
+import net.bioclipse.opsin.business.IJavaOpsinManager;
+import net.bioclipse.opsin.business.IJavaScriptOpsinManager;
+
+import org.apache.log4j.Logger;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * The Activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ private static final Logger logger = Logger.getLogger(Activator.class);
+
+ // The shared instance
+ private static Activator plugin;
+
+ // Trackers for getting the managers
+ private ServiceTracker javaFinderTracker;
+ private ServiceTracker jsFinderTracker;
+
+ public Activator() {
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ javaFinderTracker
+ = new ServiceTracker( context,
+ IJavaOpsinManager.class.getName(),
+ null );
+
+ javaFinderTracker.open();
+ jsFinderTracker
+ = new ServiceTracker( context,
+ IJavaScriptOpsinManager.class.getName(),
+ null );
+
+ jsFinderTracker.open();
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public IOpsinManager getJavaOpsinManager() {
+ IOpsinManager manager = null;
+ try {
+ manager = (IOpsinManager)
+ javaFinderTracker.waitForService(1000*10);
+ }
+ catch (InterruptedException e) {
+ throw new IllegalStateException(
+ "Could not get the Java OpsinManager",
+ e );
+ }
+ if (manager == null) {
+ throw new IllegalStateException(
+ "Could not get the Java OpsinManager");
+ }
+ return manager;
+ }
+
+ public IJavaScriptOpsinManager getJavaScriptOpsinManager() {
+ IJavaScriptOpsinManager manager = null;
+ try {
+ manager = (IJavaScriptOpsinManager)
+ jsFinderTracker.waitForService(1000*10);
+ }
+ catch (InterruptedException e) {
+ throw new IllegalStateException(
+ "Could not get the JavaScript OpsinManager",
+ e );
+ }
+ if (manager == null) {
+ throw new IllegalStateException(
+ "Could not get the JavaScript OpsinManager");
+ }
+ return manager;
+ }
+}
View
15 plugins/net.bioclipse.opsin/src/net/bioclipse/opsin/business/IJavaOpsinManager.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Egon Willighagen <egon.willighagen@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: Bioclipse Project <http://www.bioclipse.net>
+ ******************************************************************************/
+package net.bioclipse.opsin.business;
+
+public interface IJavaOpsinManager extends IOpsinManager {
+
+}
View
18 plugins/net.bioclipse.opsin/src/net/bioclipse/opsin/business/IJavaScriptOpsinManager.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Egon Willighagen <egon.willighagen@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: Bioclipse Project <http://www.bioclipse.net>
+ ******************************************************************************/
+package net.bioclipse.opsin.business;
+
+import net.bioclipse.managers.business.IBioclipseJSManager;
+
+public interface IJavaScriptOpsinManager
+ extends IOpsinManager, IBioclipseJSManager {
+
+}
View
30 plugins/net.bioclipse.opsin/src/net/bioclipse/opsin/business/IOpsinManager.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Egon Willighagen <egon.willighagen@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.opsin.business;
+
+import net.bioclipse.cdk.domain.ICDKMolecule;
+import net.bioclipse.core.PublishedClass;
+import net.bioclipse.core.PublishedMethod;
+import net.bioclipse.managers.business.IBioclipseManager;
+
+@PublishedClass(
+ value="Manager for the OPSIN functionality to convert IUPAC names into " +
+ "chemical structures."
+)
+public interface IOpsinManager extends IBioclipseManager {
+
+ @PublishedMethod(
+ params="String iupacName",
+ methodSummary="Converts an IUPAC name into a chemical structure"
+ )
+ public ICDKMolecule parseIUPACName(String iupacName);
+
+}
View
72 plugins/net.bioclipse.opsin/src/net/bioclipse/opsin/business/OpsinManager.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Egon Willighagen <egon.willighagen@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.opsin.business;
+
+import java.io.IOException;
+
+import net.bioclipse.cdk.business.CDKManager;
+import net.bioclipse.cdk.domain.ICDKMolecule;
+import net.bioclipse.core.business.BioclipseException;
+import net.bioclipse.managers.business.IBioclipseManager;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import uk.ac.cam.ch.wwmm.opsin.NameToStructure;
+import uk.ac.cam.ch.wwmm.opsin.NameToStructureException;
+import uk.ac.cam.ch.wwmm.opsin.OpsinResult;
+import uk.ac.cam.ch.wwmm.opsin.OpsinResult.OPSIN_RESULT_STATUS;
+
+public class OpsinManager implements IBioclipseManager {
+
+ private CDKManager cdk = new CDKManager();
+
+ /**
+ * Gives a short one word name of the manager used as variable name when
+ * scripting.
+ */
+ public String getManagerName() {
+ return "opsin";
+ }
+
+ public ICDKMolecule parseIUPACName(String iupacName, IProgressMonitor monitor)
+ throws BioclipseException {
+ if (monitor == null) monitor = new NullProgressMonitor();
+
+ monitor.beginTask("Processing IUPAC name", 1);
+ NameToStructure nameToStructure;
+ try {
+ nameToStructure = NameToStructure.getInstance();
+ } catch (NameToStructureException e) {
+ throw new BioclipseException(
+ "Error while loading OPSIN: " + e.getMessage(),
+ e
+ );
+ }
+ OpsinResult result = nameToStructure.parseChemicalName(
+ iupacName, false
+ );
+ if (result.getStatus() == OPSIN_RESULT_STATUS.SUCCESS) {
+ try {
+ return cdk.fromCml(result.getCml().toXML());
+ } catch (IOException exception) {
+ throw new BioclipseException(
+ "Error while converting CML into a CDKMolecule: " + exception.getMessage(),
+ exception
+ );
+ }
+ }
+ throw new BioclipseException(
+ "Could not parse the IUPAC name (" + iupacName + "), because: " +
+ result.getMessage()
+ );
+ }
+}
View
49 plugins/net.bioclipse.opsin/src/net/bioclipse/opsin/business/OpsinManagerFactory.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Egon Willighagen <egon.willighagen@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.opsin.business;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IExecutableExtensionFactory;
+
+import net.bioclipse.opsin.Activator;
+
+/**
+ * Factory used for giving the manager to extension points.
+ *
+ * e.g. the extension point that is used for getting manager into the scripting
+ * environment.
+ *
+ * @author jonalv
+ */
+public class OpsinManagerFactory
+ implements IExecutableExtension, IExecutableExtensionFactory {
+
+ private Object manager;
+
+ public void setInitializationData( IConfigurationElement config,
+ String propertyName,
+ Object data ) throws CoreException {
+
+ manager = Activator.getDefault().getJavaScriptOpsinManager();
+
+ if ( manager == null ) {
+ throw new IllegalStateException(
+ "Could not get the JavaScript flavoured " +
+ "OpsinManager" );
+ }
+ }
+
+ public Object create() throws CoreException {
+ return manager;
+ }
+}

0 comments on commit ee1914a

Please sign in to comment.
Something went wrong with that request. Please try again.