Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added test suite stuff for the QSAR feature

  • Loading branch information...
commit 0564437603f5866ff7e34259ac77bc772b80158b 1 parent 7568cc1
Egon Willighagen authored September 06, 2011
17  features/net.bioclipse.qsar.test_feature/.project
... ...
@@ -0,0 +1,17 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<projectDescription>
  3
+	<name>net.bioclipse.qsar.test_feature</name>
  4
+	<comment></comment>
  5
+	<projects>
  6
+	</projects>
  7
+	<buildSpec>
  8
+		<buildCommand>
  9
+			<name>org.eclipse.pde.FeatureBuilder</name>
  10
+			<arguments>
  11
+			</arguments>
  12
+		</buildCommand>
  13
+	</buildSpec>
  14
+	<natures>
  15
+		<nature>org.eclipse.pde.FeatureNature</nature>
  16
+	</natures>
  17
+</projectDescription>
49  features/net.bioclipse.qsar.test_feature/QSARPluginTestSuite.launch
... ...
@@ -0,0 +1,49 @@
  1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
  3
+<setAttribute key="additional_plugins"/>
  4
+<booleanAttribute key="append.args" value="true"/>
  5
+<booleanAttribute key="askclear" value="false"/>
  6
+<booleanAttribute key="automaticAdd" value="true"/>
  7
+<booleanAttribute key="automaticValidate" value="false"/>
  8
+<stringAttribute key="bootstrap" value=""/>
  9
+<stringAttribute key="checked" value="[NONE]"/>
  10
+<booleanAttribute key="clearConfig" value="true"/>
  11
+<booleanAttribute key="clearws" value="true"/>
  12
+<booleanAttribute key="clearwslog" value="false"/>
  13
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
  14
+<booleanAttribute key="default" value="false"/>
  15
+<stringAttribute key="featureDefaultLocation" value="workspace"/>
  16
+<stringAttribute key="featurePluginResolution" value="workspace"/>
  17
+<booleanAttribute key="includeOptional" value="true"/>
  18
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
  19
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
  20
+<listEntry value="/net.bioclipse.qsar.test/src/net/bioclipse/qsar/business/test/AllQsarManagerPluginTests.java"/>
  21
+</listAttribute>
  22
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
  23
+<listEntry value="1"/>
  24
+</listAttribute>
  25
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
  26
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
  27
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
  28
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
  29
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.bioclipse.qsar.test.business.AllQsarManagerPluginTests"/>
  30
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
  31
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="net.bioclipse.qsar.test"/>
  32
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
  33
+<stringAttribute key="pde.version" value="3.3"/>
  34
+<stringAttribute key="product" value="net.bioclipse.ui.product"/>
  35
+<booleanAttribute key="run_in_ui_thread" value="true"/>
  36
+<setAttribute key="selected_features">
  37
+<setEntry value="net.bioclipse.qsar.test_feature:default"/>
  38
+<setEntry value="net.bioclipse.qsar_feature:default"/>
  39
+<setEntry value="net.bioclipse.core_feature:default"/>
  40
+<setEntry value="org.eclipse.equinox.p2.user.ui:default"/>
  41
+<setEntry value="org.eclipse.rcp:default"/>
  42
+</setAttribute>
  43
+<booleanAttribute key="show_selected_only" value="true"/>
  44
+<booleanAttribute key="tracing" value="false"/>
  45
+<booleanAttribute key="useCustomFeatures" value="true"/>
  46
+<booleanAttribute key="useDefaultConfig" value="true"/>
  47
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
  48
+<booleanAttribute key="useProduct" value="true"/>
  49
+</launchConfiguration>
1  features/net.bioclipse.qsar.test_feature/build.properties
... ...
@@ -0,0 +1 @@
  1
+bin.includes = feature.xml
169  features/net.bioclipse.qsar.test_feature/feature.xml
... ...
@@ -0,0 +1,169 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<feature
  3
+      id="net.bioclipse.qsar.test_feature"
  4
+      label="QSAR Test Feature"
  5
+      version="2.5.0.qualifier"
  6
+      provider-name="The Bioclipse Project"
  7
+      plugin="net.bioclipse.qsar.test">
  8
+
  9
+   <description>
  10
+      QSAR (Quantitative Structure-Activity Relationship) functionality
  11
+for Bioclipse.
  12
+   </description>
  13
+
  14
+   <copyright>
  15
+      (C) 2006-2009 The Bioclipse Project contributors and others.
  16
+   </copyright>
  17
+
  18
+   <license url="http://www.eclipse.org/org/documents/epl-v10.php">
  19
+      This feature and the accompanying materials are made available
  20
+under the terms of the Eclipse Public License v1.0 + exception,
  21
+putting no constraints on choice of backend and/or license for
  22
+creating plugins for Bioclipse; it is totally open for both open
  23
+source plugins as well as commercial. The exception allows GPL
  24
+plugins to be written and run in any combination with EPL licensed
  25
+plugins, addressing incompatibility between the EPL and the GPL
  26
+v.2.
  27
+The Eclipse Public License accompanies this distribution, and
  28
+is available at http://www.eclipse.org/legal/epl-v10.html
  29
+   </license>
  30
+
  31
+   <requires>
  32
+      <import feature="net.bioclipse.rdf_feature" version="2.4.0" match="greaterOrEqual"/>
  33
+      <import feature="net.bioclipse.chemoinformatics_feature" version="2.4.0" match="greaterOrEqual"/>
  34
+   </requires>
  35
+
  36
+   <plugin
  37
+         id="net.bioclipse.qsar"
  38
+         download-size="0"
  39
+         install-size="0"
  40
+         version="0.0.0"
  41
+         unpack="false"/>
  42
+
  43
+   <plugin
  44
+         id="org.eclipse.emf"
  45
+         download-size="0"
  46
+         install-size="0"
  47
+         version="0.0.0"
  48
+         unpack="false"/>
  49
+
  50
+   <plugin
  51
+         id="org.eclipse.emf.ecore"
  52
+         download-size="0"
  53
+         install-size="0"
  54
+         version="0.0.0"
  55
+         unpack="false"/>
  56
+
  57
+   <plugin
  58
+         id="org.eclipse.emf.ecore.edit"
  59
+         download-size="0"
  60
+         install-size="0"
  61
+         version="0.0.0"
  62
+         unpack="false"/>
  63
+
  64
+   <plugin
  65
+         id="org.eclipse.emf.ecore.xmi"
  66
+         download-size="0"
  67
+         install-size="0"
  68
+         version="0.0.0"
  69
+         unpack="false"/>
  70
+
  71
+   <plugin
  72
+         id="org.eclipse.emf.edit"
  73
+         download-size="0"
  74
+         install-size="0"
  75
+         version="0.0.0"
  76
+         unpack="false"/>
  77
+
  78
+   <plugin
  79
+         id="org.eclipse.emf.common"
  80
+         download-size="0"
  81
+         install-size="0"
  82
+         version="0.0.0"
  83
+         unpack="false"/>
  84
+
  85
+   <plugin
  86
+         id="org.eclipse.emf.edit.ui"
  87
+         download-size="0"
  88
+         install-size="0"
  89
+         version="0.0.0"
  90
+         unpack="false"/>
  91
+
  92
+   <plugin
  93
+         id="org.eclipse.emf.databinding"
  94
+         download-size="0"
  95
+         install-size="0"
  96
+         version="0.0.0"
  97
+         unpack="false"/>
  98
+
  99
+   <plugin
  100
+         id="org.eclipse.emf.databinding.edit"
  101
+         download-size="0"
  102
+         install-size="0"
  103
+         version="0.0.0"
  104
+         unpack="false"/>
  105
+
  106
+   <plugin
  107
+         id="org.eclipse.emf.common.ui"
  108
+         download-size="0"
  109
+         install-size="0"
  110
+         version="0.0.0"
  111
+         unpack="false"/>
  112
+
  113
+   <plugin
  114
+         id="net.bioclipse.cdk.qsar"
  115
+         download-size="0"
  116
+         install-size="0"
  117
+         version="0.0.0"
  118
+         unpack="false"/>
  119
+
  120
+   <plugin
  121
+         id="net.bioclipse.qsar.model"
  122
+         download-size="0"
  123
+         install-size="0"
  124
+         version="0.0.0"
  125
+         unpack="false"/>
  126
+
  127
+   <plugin
  128
+         id="net.bioclipse.qsar.model.edit"
  129
+         download-size="0"
  130
+         install-size="0"
  131
+         version="0.0.0"
  132
+         unpack="false"/>
  133
+
  134
+   <plugin
  135
+         id="net.bioclipse.qsar.ui"
  136
+         download-size="0"
  137
+         install-size="0"
  138
+         version="0.0.0"
  139
+         unpack="false"/>
  140
+
  141
+   <plugin
  142
+         id="net.bioclipse.bibtexml"
  143
+         download-size="0"
  144
+         install-size="0"
  145
+         version="0.0.0"
  146
+         unpack="false"/>
  147
+
  148
+   <plugin
  149
+         id="net.bioclipse.bibtexml.edit"
  150
+         download-size="0"
  151
+         install-size="0"
  152
+         version="0.0.0"
  153
+         unpack="false"/>
  154
+
  155
+   <plugin
  156
+         id="org.eclipse.emf.ecore.change"
  157
+         download-size="0"
  158
+         install-size="0"
  159
+         version="0.0.0"
  160
+         unpack="false"/>
  161
+
  162
+   <plugin
  163
+         id="net.bioclipse.cdk.qsar.rest"
  164
+         download-size="0"
  165
+         install-size="0"
  166
+         version="0.0.0"
  167
+         unpack="false"/>
  168
+
  169
+</feature>
8  plugins/net.bioclipse.qsar.test/META-INF/MANIFEST.MF
@@ -10,10 +10,14 @@ Require-Bundle: org.eclipse.ui,
10 10
  net.bioclipse.core,
11 11
  net.bioclipse.qsar.model;bundle-version="1.0.0",
12 12
  net.bioclipse.qsar.model.edit;bundle-version="1.0.0",
13  
- net.bioclipse.qsar.ui;bundle-version="2.0.0"
  13
+ net.bioclipse.qsar.ui;bundle-version="2.0.0",
  14
+ net.bioclipse.core.tests;bundle-version="2.5.0"
14 15
 Bundle-ActivationPolicy: lazy
15 16
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
16  
-Import-Package: org.apache.log4j, org.junit
  17
+Import-Package: org.apache.log4j,
  18
+ org.junit,
  19
+ org.junit.runner,
  20
+ org.junit.runners
17 21
 Export-Package: net.bioclipse.qsar.test,
18 22
  net.bioclipse.qsar.test.business
19 23
 Bundle-ClassPath: .
37  plugins/net.bioclipse.qsar.test/src/net/bioclipse/qsar/test/business/APITest.java
... ...
@@ -0,0 +1,37 @@
  1
+/*******************************************************************************
  2
+ * Copyright (c) 2011  Egon Willighagen <egon.willighagen@ki.se>
  3
+ * 
  4
+ * All rights reserved. This program and the accompanying materials
  5
+ * are made available under the terms of the Eclipse Public License v1.0
  6
+ * which accompanies this distribution, and is available at
  7
+ * http://www.eclipse.org/legal/epl-v10.html
  8
+ *
  9
+ * Contact: Bioclipse Project <http://www.bioclipse.net>
  10
+ ******************************************************************************/
  11
+package net.bioclipse.qsar.test.business;
  12
+
  13
+import net.bioclipse.core.tests.AbstractManagerTest;
  14
+import net.bioclipse.managers.business.IBioclipseManager;
  15
+import net.bioclipse.qsar.business.IQsarManager;
  16
+import net.bioclipse.qsar.business.QsarManager;
  17
+
  18
+/**
  19
+ * JUnit tests for checking if the tested Manager is properly tested.
  20
+ * 
  21
+ * @author egonw
  22
+ */
  23
+public class APITest extends AbstractManagerTest {
  24
+    
  25
+    private static QsarManager manager = new QsarManager();
  26
+
  27
+    @Override
  28
+    public IBioclipseManager getManager() {
  29
+        return manager;
  30
+    }
  31
+
  32
+    @Override
  33
+    public Class<? extends IBioclipseManager> getManagerInterface() {
  34
+        return IQsarManager.class;
  35
+    }
  36
+
  37
+}
710  plugins/net.bioclipse.qsar.test/src/net/bioclipse/qsar/test/business/AbstractQsarManagerPluginTest.java
... ...
@@ -0,0 +1,710 @@
  1
+/*******************************************************************************
  2
+ * Copyright (c) 2011  Egon Willighagen <egon.willighagen@ki.se>
  3
+ *
  4
+ * All rights reserved. This program and the accompanying materials
  5
+ * are made available under the terms of the Eclipse Public License v1.0
  6
+ * which accompanies this distribution, and is available at
  7
+ * http://www.eclipse.org/legal/epl-v10.html
  8
+ *
  9
+ * Contact: http://www.bioclipse.net/
  10
+ ******************************************************************************/
  11
+package net.bioclipse.qsar.test.business;
  12
+
  13
+import static org.junit.Assert.assertEquals;
  14
+import static org.junit.Assert.assertFalse;
  15
+import static org.junit.Assert.assertNotNull;
  16
+import static org.junit.Assert.assertNull;
  17
+import static org.junit.Assert.assertTrue;
  18
+
  19
+import java.util.ArrayList;
  20
+import java.util.HashMap;
  21
+import java.util.List;
  22
+import java.util.Map;
  23
+
  24
+import org.eclipse.core.runtime.NullProgressMonitor;
  25
+import org.eclipse.core.runtime.preferences.DefaultScope;
  26
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
  27
+import org.eclipse.emf.common.command.BasicCommandStack;
  28
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
  29
+import org.eclipse.emf.edit.domain.EditingDomain;
  30
+import org.junit.Test;
  31
+
  32
+import net.bioclipse.core.business.BioclipseException;
  33
+import net.bioclipse.core.domain.IMolecule;
  34
+import net.bioclipse.core.domain.SMILESMolecule;
  35
+import net.bioclipse.core.tests.AbstractManagerTest;
  36
+import net.bioclipse.qsar.DescriptorType;
  37
+import net.bioclipse.qsar.QSARConstants;
  38
+import net.bioclipse.qsar.QsarFactory;
  39
+import net.bioclipse.qsar.QsarType;
  40
+import net.bioclipse.qsar.business.IQsarManager;
  41
+import net.bioclipse.qsar.business.QsarManager;
  42
+import net.bioclipse.qsar.descriptor.IDescriptorResult;
  43
+import net.bioclipse.qsar.descriptor.model.Descriptor;
  44
+import net.bioclipse.qsar.descriptor.model.DescriptorCalculationResult;
  45
+import net.bioclipse.qsar.descriptor.model.DescriptorCategory;
  46
+import net.bioclipse.qsar.descriptor.model.DescriptorImpl;
  47
+import net.bioclipse.qsar.descriptor.model.DescriptorParameter;
  48
+import net.bioclipse.qsar.descriptor.model.DescriptorProvider;
  49
+import net.bioclipse.qsar.descriptor.model.ResponseUnit;
  50
+import net.bioclipse.qsar.init.Activator;
  51
+import net.bioclipse.qsar.util.QsarAdapterFactory;
  52
+
  53
+public abstract class AbstractQsarManagerPluginTest
  54
+extends AbstractManagerTest {
  55
+
  56
+    protected static IQsarManager qsar;
  57
+
  58
+    @Test
  59
+    public void testQsarManager() {
  60
+		
  61
+		//Unnecessary to use OSGI.
  62
+		qsar=new QsarManager();
  63
+		
  64
+		//Initialize from ontology and EP
  65
+		qsar.getFullCategories();
  66
+		qsar.getFullDescriptors();
  67
+		
  68
+	}
  69
+
  70
+    @Test
  71
+    public void testSetings(){
  72
+        assertNotNull( "Must run as PluginTest.", Activator.PLUGIN_ID );
  73
+        
  74
+    }
  75
+    
  76
+    @Test
  77
+    public void testAddRemoveResponseValues(){
  78
+
  79
+        QsarAdapterFactory factory=new QsarAdapterFactory();
  80
+        EditingDomain editingDomain=new AdapterFactoryEditingDomain(factory, new BasicCommandStack());
  81
+
  82
+        QsarType qsarModel=QsarFactory.eINSTANCE.createQsarType();
  83
+
  84
+        assertEquals( 0, qsarModel.getResponseunit().size() );
  85
+        List<ResponseUnit> list=new ArrayList<ResponseUnit>();
  86
+        
  87
+        ResponseUnit unit1=new ResponseUnit("ic50", "half maximal inhibitory concentration (IC50)");
  88
+        unit1.setShortname( "IC50" );
  89
+        unit1.setDescription( "Measure of the effectiveness of a compound in inhibiting biological or biochemical function");
  90
+        unit1.setUrl( "http://en.wikipedia.org/wiki/IC50" );
  91
+        list.add( unit1 );
  92
+        
  93
+        qsar.addResponseUnitToModel( qsarModel, editingDomain, list );
  94
+        assertEquals( 1, qsarModel.getResponseunit().size() );
  95
+        qsar.removeResponseUnitsFromModel( qsarModel, editingDomain, qsarModel.getResponseunit() );
  96
+        assertEquals( 0, qsarModel.getResponseunit().size() );
  97
+        
  98
+    }
  99
+
  100
+  	
  101
+  	@Test
  102
+  	public void testGetPreferences(){
  103
+
  104
+      String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChain";
  105
+
  106
+  		IEclipsePreferences prefs = new DefaultScope().getNode(Activator.PLUGIN_ID);
  107
+  		assertNotNull(prefs);
  108
+  		String prefsString=prefs.get(QSARConstants.QSAR_PROVIDERS_ORDER_PREFERENCE, null);
  109
+  		assertNotNull(prefsString);
  110
+
  111
+  		System.out.println("Got prefs string: " + prefsString);
  112
+  		assertFalse( prefsString.equals( "ERROR" ) );
  113
+  		
  114
+  		assertTrue(prefsString.contains("descriptorProvider1"));
  115
+  		assertTrue(prefsString.contains("descriptorProvider2"));
  116
+
  117
+  		DescriptorImpl impl=qsar.getPreferredImpl(descriptorID);
  118
+  		assertNotNull(impl);
  119
+  	}
  120
+
  121
+  	@Test
  122
+  	public void testGetCategoriesAndFullCategories(){
  123
+
  124
+  		//Get category IDs
  125
+  		List<String> lst = qsar.getCategories();
  126
+  		assertNotNull(lst);
  127
+  		assertTrue(lst.size()>=2);
  128
+
  129
+  		System.out.println("=======================");
  130
+  		System.out.println("Category IDs:");
  131
+  		for (String str : lst){
  132
+  			System.out.println("  - " + str);
  133
+  		}
  134
+  		System.out.println("=======================");
  135
+
  136
+  		//Get category classes
  137
+  		List<DescriptorCategory> lstFull = qsar.getFullCategories();
  138
+  		assertNotNull(lstFull);
  139
+  		
  140
+  		//Should have same size as IDs
  141
+  		assertTrue(lstFull.size()==(lst.size()));
  142
+
  143
+  	}
  144
+  	
  145
+  	 @Test
  146
+  	  public void testGetStandardResponseValues(){
  147
+
  148
+  	    //Get category IDs
  149
+  	    List<String> lst = qsar.getResponseUnits();
  150
+  	    assertNotNull(lst);
  151
+  	    assertTrue(lst.size()>=4);
  152
+
  153
+  	    System.out.println("=======================");
  154
+  	    System.out.println("Response IDs:");
  155
+  	    for (String str : lst){
  156
+  	      System.out.println("  - " + str);
  157
+  	    }
  158
+  	    System.out.println("=======================");
  159
+
  160
+  	    //Get category classes
  161
+  	    List<ResponseUnit> lstFull = qsar.getFullResponseUnits();
  162
+  	    assertNotNull(lstFull);
  163
+  	    
  164
+  	    //Should have same size as IDs
  165
+  	    assertTrue(lstFull.size()==(lst.size()));
  166
+
  167
+  	  }
  168
+
  169
+  	@Test
  170
+  	public void testGetCategoryByID(){
  171
+
  172
+  		String cat1id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#hybridDescriptor";
  173
+  		String cat2id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#topologicalDescriptor";
  174
+
  175
+  		//Get category IDs
  176
+  		DescriptorCategory cat1 = qsar.getCategoryByID(cat1id);
  177
+  		assertNotNull(cat1);
  178
+  		assertEquals(cat1id, cat1.getId());
  179
+
  180
+  		DescriptorCategory cat2 = qsar.getCategoryByID(cat2id);
  181
+  		assertNotNull(cat2);
  182
+  		assertEquals(cat2id, cat2.getId());
  183
+
  184
+  	}
  185
+
  186
+  	@Test
  187
+  	public void testGetProvidersAndFullProviders(){
  188
+
  189
+  		//Get provider IDs
  190
+  		List<String> lst = qsar.getProviders();
  191
+  		assertNotNull(lst);
  192
+  		assertTrue(lst.size()>=2);
  193
+
  194
+  		System.out.println("=======================");
  195
+  		System.out.println("Provider IDs:");
  196
+  		for (String str : lst){
  197
+  			System.out.println("  - " + str);
  198
+  		}
  199
+  		System.out.println("=======================");
  200
+
  201
+  		//Get provider classes
  202
+  		List<DescriptorProvider> lstFull = qsar.getFullProviders();
  203
+  		assertNotNull(lstFull);
  204
+  		
  205
+  		//Should have same size as IDs
  206
+  		assertTrue(lstFull.size()==(lst.size()));
  207
+
  208
+  	}
  209
+
  210
+  	@Test
  211
+  	public void testGetProvidersByID(){
  212
+
  213
+  		String providerID="net.bioclipse.qsar.test.descriptorProvider1";
  214
+  		String expectedNamespace="net.bioclipse.qsar.test.provider1.namespace";
  215
+  		
  216
+  		DescriptorProvider prov = qsar.getProviderByID(providerID);
  217
+  		assertNotNull(prov);
  218
+  		assertEquals(prov.getId(), providerID);
  219
+  		assertNotNull(prov.getShortName());
  220
+  		assertEquals("provider1", prov.getShortName());
  221
+  		assertEquals(expectedNamespace, prov.getNamespace());
  222
+  	}
  223
+  	
  224
+  	@Test
  225
+  	public void testGetProvidersByDescriptorAndProvider() throws BioclipseException{
  226
+
  227
+  		String providerID="net.bioclipse.qsar.test.descriptorProvider1";
  228
+  		String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#BCUT";
  229
+          String expectedImplID="net.bioclipse.qsar.test.descriptor1";
  230
+
  231
+  		DescriptorImpl impl = qsar.getDescriptorImpl(descriptorID, providerID);
  232
+  		assertEquals(expectedImplID, impl.getId());
  233
+  		
  234
+  	}
  235
+  	
  236
+
  237
+  	
  238
+  	
  239
+  	@Test
  240
+  	public void testGetDescriptorsAndFullDescriptors(){
  241
+
  242
+  		List<String> desc=qsar.getDescriptorIDs();
  243
+  		assertNotNull(desc);
  244
+  		assertTrue(desc.size()>0);
  245
+
  246
+  		List<Descriptor> descList=qsar.getFullDescriptors();
  247
+  		assertNotNull(descList);
  248
+  		assertTrue(descList.size()>0);
  249
+  		
  250
+  		assertEquals(desc.size(), descList.size());
  251
+
  252
+  	}
  253
+  	
  254
+  	@Test
  255
+  	public void testGetDescriptorByID(){
  256
+  		
  257
+  		String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#aromaticAtomsCount";
  258
+  		String cat1id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#hybridDescriptor";
  259
+  		String cat2id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#constitutionalDescriptor";
  260
+  		String cat3id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#electronicDescriptor";
  261
+  		
  262
+  		Descriptor desc=qsar.getDescriptorByID(descriptorID);
  263
+  		assertNotNull(desc);
  264
+  		assertEquals(QSARConstants.BO_NAMESPACE, desc.getNamespace());
  265
+
  266
+  		
  267
+  		DescriptorCategory cat1 = qsar.getCategoryByID(cat1id);
  268
+  		DescriptorCategory cat2 = qsar.getCategoryByID(cat2id);
  269
+  		DescriptorCategory cat3 = qsar.getCategoryByID(cat3id);
  270
+  		
  271
+  		assertNotNull(desc.getCategories());
  272
+  		assertFalse(desc.getCategories().contains(cat1));
  273
+  		assertTrue(desc.getCategories().contains(cat2));
  274
+  		assertFalse(desc.getCategories().contains(cat3));
  275
+  		
  276
+  		assertNotNull(desc.getDate());
  277
+  		
  278
+      assertNotNull(desc.getDefinition());
  279
+//      assertNotNull(desc.getDescription());
  280
+  		
  281
+  	}
  282
+
  283
+  	
  284
+  	
  285
+  	@Test
  286
+  	public void testGetDescriptorByCategory(){
  287
+  		
  288
+  		String cat1id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#hybridDescriptor";
  289
+  		String cat2id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#geometricalDescriptor";
  290
+
  291
+  		String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#momentOfInertia";
  292
+
  293
+  		DescriptorCategory cat1 = qsar.getCategoryByID(cat1id);
  294
+  		assertNotNull( cat1 );
  295
+  		DescriptorCategory cat2 = qsar.getCategoryByID(cat2id);
  296
+      assertNotNull( cat2 );
  297
+  		Descriptor desc=qsar.getDescriptorByID(descriptorID);
  298
+  		
  299
+//  		List<Descriptor> descList1 = qsar.getDescriptorsInCategory(cat1);
  300
+//      assertNotNull(descList1);
  301
+//      assertTrue(descList1.contains(desc));
  302
+//      List<String> descList1_1 = qsar.getDescriptorsInCategory(cat1id);
  303
+//      assertNotNull(descList1_1);
  304
+//      assertEquals( descList1.size(), descList1_1.size() );
  305
+      
  306
+  		List<Descriptor> descList2 = qsar.getDescriptorsInCategory(cat2);
  307
+      assertNotNull(descList2);
  308
+      assertTrue(descList2.contains(desc));
  309
+      List<String> descList2_2 = qsar.getDescriptorsInCategory(cat2id);
  310
+      assertNotNull(descList2_2);
  311
+      assertEquals( descList2.size(), descList2_2.size() );
  312
+
  313
+  	}
  314
+
  315
+    @Test
  316
+    public void testGetDescriptorImplsByProvider() throws BioclipseException{
  317
+
  318
+      //Matches plugin.xml
  319
+      String providerID="net.bioclipse.qsar.test.descriptorProvider1";
  320
+      String providerID2="net.bioclipse.qsar.test.descriptorProvider2";
  321
+      
  322
+      String descriptorImplID="net.bioclipse.qsar.test.descriptor3";
  323
+
  324
+      assertEquals(2, qsar.getDescriptorImplsByProvider(providerID).size());
  325
+      assertEquals(4, qsar.getDescriptorImplsByProvider(providerID2).size());
  326
+      
  327
+      assertTrue(qsar.existsDescriptorImpl(descriptorImplID));
  328
+    }
  329
+
  330
+
  331
+  	@Test
  332
+  	public void testGetDescriptorImpls(){
  333
+
  334
+  		String descriptorImplID="net.bioclipse.qsar.test.descriptor3";
  335
+  		
  336
+  		List<DescriptorImpl> descs = qsar.getFullDescriptorImpls();
  337
+  		assertNotNull(descs);
  338
+  		assertTrue(descs.size()>0);
  339
+  		
  340
+  		DescriptorImpl impl=qsar.getDescriptorImplByID(descriptorImplID);
  341
+  		assertNotNull(impl);
  342
+  		
  343
+  		assertTrue(descs.contains(impl));
  344
+  		
  345
+  	}
  346
+  	
  347
+
  348
+  	
  349
+  	@Test
  350
+  	public void testGetDescriptorImplNotInOntology(){
  351
+
  352
+  		System.out.println("=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.");
  353
+  		System.out.println("Impl not in onology:");
  354
+  		System.out.println("=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.");
  355
+  		for (DescriptorImpl impl : qsar.getFullDescriptorImpls()){
  356
+  			if (qsar.getDescriptorIDs().contains(impl.getDefinition())){
  357
+  				//All is well
  358
+  			}
  359
+  			else{
  360
+  				System.out.println("=.= Descriptor impl: " + impl.getName() + " with def: " + impl.getDefinition());
  361
+  				
  362
+  			}
  363
+  			
  364
+  		}
  365
+  		System.out.println("=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.");
  366
+  		
  367
+  		
  368
+  	}
  369
+
  370
+  	
  371
+  	
  372
+
  373
+  	@Test
  374
+  	public void testGetDescriptorIDsImplsFromDescriptor() throws BioclipseException{
  375
+
  376
+  		String expectedImpl="net.bioclipse.qsar.test.descriptor3";
  377
+          String expectedImpl2="net.bioclipse.qsar.test.descriptor3D";
  378
+          String expectedImpl3="net.bioclipse.qsar.test.descriptor1";
  379
+
  380
+          String descriptor="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChain";
  381
+
  382
+  		List<String> descImplIDs = qsar.getDescriptorImpls(descriptor);
  383
+  		assertNotNull(descImplIDs);
  384
+
  385
+  		System.out.println("================");
  386
+  		System.out.println(" ** Descriptor: " + descriptor + " has the following implementations:");
  387
+  		for (String dimpl : descImplIDs){
  388
+  			System.out.println("  -  " + dimpl);
  389
+  		}
  390
+  		System.out.println("================");
  391
+
  392
+  		assertTrue(descImplIDs.contains(expectedImpl));
  393
+  		assertTrue(descImplIDs.contains(expectedImpl2));
  394
+  		assertFalse(descImplIDs.contains(expectedImpl3));
  395
+
  396
+  		DescriptorImpl impl1=qsar.getDescriptorImplByID(expectedImpl);
  397
+  		DescriptorImpl impl2=qsar.getDescriptorImplByID(expectedImpl2);
  398
+  		DescriptorImpl impl3=qsar.getDescriptorImplByID(expectedImpl3);
  399
+  		
  400
+  		List<DescriptorImpl> descImplIDsFull = qsar.getDescriptorImplsForDescriptor(descriptor);
  401
+  		assertNotNull(descImplIDsFull);
  402
+  		assertTrue( descImplIDs.size()>0 );
  403
+  		assertEquals(descImplIDs.size(), descImplIDsFull.size());
  404
+
  405
+  		assertTrue(descImplIDsFull.contains(impl1));
  406
+  		assertTrue(descImplIDsFull.contains(impl2));
  407
+  		assertFalse(descImplIDsFull.contains(impl3));
  408
+
  409
+  	}
  410
+  	
  411
+
  412
+    @Test
  413
+    public void testExistsDescriptor(){
  414
+        String descriptor1="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChain";
  415
+        String descriptor2="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChainWEEE";
  416
+
  417
+        boolean exists=qsar.existsDescriptor( descriptor1 );
  418
+        assertTrue( exists );
  419
+        boolean noexists=qsar.existsDescriptor( descriptor2 );
  420
+        assertFalse( noexists );
  421
+       
  422
+    }
  423
+
  424
+
  425
+
  426
+  	@Test
  427
+  		public void testGetDescriptorImplsByID(){
  428
+  		//Matches plugin.xml
  429
+  		String descriptorImplID="net.bioclipse.qsar.test.descriptor3";
  430
+//  		String cat1id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#molecularDescriptor";
  431
+
  432
+  		//Get decriptor by hardcoded id
  433
+  		DescriptorImpl desc=qsar.getDescriptorImplByID(descriptorImplID);
  434
+  		assertNotNull(desc);
  435
+  		assertNull(desc.getParameters());
  436
+  		assertFalse(desc.isRequires3D());
  437
+  		assertEquals("descriptorProvider2", desc.getProvider().getName());
  438
+  		assertEquals("http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChain", desc.getDefinition());
  439
+  		assertEquals("net.bioclipse.qsar.test.description3", desc.getDescription());
  440
+  	}
  441
+
  442
+  	
  443
+
  444
+  	@Test
  445
+  	public void testGetDescriptorImplsByIDRequire3D(){
  446
+  		//Matches plugin.xml
  447
+  		String descriptorID3D="net.bioclipse.qsar.test.descriptor3D";
  448
+//  		String cat2id="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#constitutionalDescriptor";
  449
+
  450
+  		//Get decriptor by hardcoded id requiring 3D
  451
+  		DescriptorImpl desc=qsar.getDescriptorImplByID(descriptorID3D);
  452
+  		assertNotNull(desc);
  453
+  		assertNull(desc.getParameters());
  454
+  		assertTrue(desc.isRequires3D());
  455
+  		assertEquals("descriptorProvider2", desc.getProvider().getName());
  456
+  		assertEquals("http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChain", desc.getDefinition());
  457
+  		assertEquals("net.bioclipse.qsar.test.description3D", desc.getDescription());
  458
+  	}
  459
+
  460
+  	@Test
  461
+  	public void testGetDescriptorImplsByIDWithParameters(){
  462
+  		//Matches plugin.xml
  463
+  		String descriptorIDParams="net.bioclipse.qsar.test.descriptorParams";
  464
+
  465
+  		//Get decriptor by hardcoded id with parameters
  466
+  		DescriptorImpl desc=qsar.getDescriptorImplByID(descriptorIDParams);
  467
+  		assertNotNull(desc);
  468
+  		assertNotNull(desc.getParameters());
  469
+  		
  470
+  		assertEquals(2, desc.getParameters().size());
  471
+
  472
+  		List<String> paramKeys=new ArrayList<String>();
  473
+  		List<String> paramVals=new ArrayList<String>();
  474
+  		List<String> paramDesc=new ArrayList<String>();
  475
+  		for (DescriptorParameter param: desc.getParameters()){
  476
+  			System.out.println("Param: " + param.getKey() + " = " + param.getDefaultvalue() + " ; " + param.getDescription());
  477
+  			paramKeys.add(param.getKey());
  478
+  			paramVals.add(param.getDefaultvalue());
  479
+  			paramDesc.add(param.getDescription());
  480
+  		}
  481
+  		
  482
+  		assertEquals(paramKeys.get(0), "bogusParameter");
  483
+  		assertEquals(paramKeys.get(1), "bogusParameter2");
  484
+  		
  485
+  		assertEquals(paramVals.get(0), "true");
  486
+  		assertEquals(paramVals.get(1), "101.67");
  487
+  		
  488
+  		assertEquals(paramDesc.get(0), "description1");
  489
+  		assertEquals(paramDesc.get(1), "description2");
  490
+
  491
+  	}
  492
+  	
  493
+    @Test
  494
+    public void testGetPreferredImpl(){
  495
+        String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#BCUT";
  496
+        String expectedImplID="net.bioclipse.qsar.test.descriptor1";
  497
+
  498
+        DescriptorImpl impl = qsar.getPreferredImpl( descriptorID );
  499
+        assertNotNull( impl );
  500
+        assertEquals( expectedImplID,impl.getId());
  501
+
  502
+    }
  503
+
  504
+    @Test
  505
+    public void testDescriptorImpl(){
  506
+        String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#BCUT";
  507
+        String expectedImplID="net.bioclipse.qsar.test.descriptor1";
  508
+
  509
+        DescriptorImpl impl = qsar.getPreferredImpl( descriptorID );
  510
+        assertNotNull( impl );
  511
+        assertEquals( expectedImplID,impl.getId());
  512
+
  513
+    }
  514
+
  515
+  	
  516
+  	
  517
+  	 /*====================================================
  518
+     * Calculations below
  519
+     * ====================================================
  520
+     */
  521
+
  522
+  	
  523
+  	@Test
  524
+  	public void testCalculateSingleMolSingleDescriptor() throws BioclipseException{
  525
+
  526
+  		IMolecule mol=new SMILESMolecule("C1CCCCC1CC(CC)CC");
  527
+  		String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChain";
  528
+  		
  529
+  		IDescriptorResult res=qsar.calculate(mol, descriptorID);
  530
+  		assertNotNull(res);
  531
+  		assertNull("Error message was not null but: " + res.getErrorMessage(), res.getErrorMessage());
  532
+  		assertEquals(descriptorID, res.getDescriptor().getOntologyid());
  533
+  		assertEquals(3, res.getLabels().length);
  534
+  		assertEquals(3, res.getValues().length);
  535
+
  536
+  		//Dummycalculator returns 15.2456 as first result in array
  537
+  		assertEquals(new Float(15.2456), res.getValues()[0]);
  538
+  		
  539
+  	}
  540
+
  541
+  	@Test
  542
+  	public void testCalculateDescriptorWithError() throws BioclipseException{
  543
+
  544
+  		IMolecule mol=new SMILESMolecule("C1CCCCC1CC(CC)CC");
  545
+  		String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#aromaticBondsCount";
  546
+
  547
+  		IDescriptorResult res=qsar.calculate(mol, descriptorID);
  548
+
  549
+  		assertNotNull(res);
  550
+  		
  551
+  		System.out.println("Error message: " + res.getErrorMessage());
  552
+  		assertEquals("Failed to calculate descriptor '" +
  553
+  				descriptorID + "'. Reason: Unknown", 
  554
+  				res.getErrorMessage());
  555
+
  556
+  	}
  557
+
  558
+
  559
+  	@Test
  560
+  	public void testCalculateMultipleMolMultipleDescriptor() throws BioclipseException{
  561
+  		
  562
+  		IMolecule mol1=new SMILESMolecule("C1CCCCC1CC(CC)CC");
  563
+  		IMolecule mol2=new SMILESMolecule("C1CCCCC1CC(CC)CCCCCO");
  564
+//  		String descriptorID="net.bioclipse.qsar.test.descriptor3";
  565
+//  		String descriptorID2="net.bioclipse.qsar.test.descriptor2";
  566
+  		String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChain";
  567
+  		String descriptorID2="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#BCUT";
  568
+  	
  569
+  		List<IMolecule> mols=new ArrayList<IMolecule>();
  570
+  		List<String> descs=new ArrayList<String>();
  571
+  		
  572
+  		mols.add(mol1);
  573
+  		mols.add(mol2);
  574
+  		descs.add(descriptorID);
  575
+  		descs.add(descriptorID2);
  576
+
  577
+  		DescriptorCalculationResult calres = qsar.calculate(mols, descs);
  578
+  		Map<? extends IMolecule, List<IDescriptorResult>> res = calres.getResultMap();
  579
+  		assertNotNull(res);
  580
+  		
  581
+  		List<IDescriptorResult> res1=res.get(mol1);
  582
+  		List<IDescriptorResult> res2=res.get(mol2);
  583
+
  584
+  		assertEquals(2, res1.size());
  585
+  		assertEquals(2, res2.size());
  586
+
  587
+  		IDescriptorResult dres1=res1.get(0);
  588
+  		IDescriptorResult dres11=res1.get(1);
  589
+  		IDescriptorResult dres2=res2.get(0);
  590
+  		IDescriptorResult dres22=res2.get(1);
  591
+
  592
+  		assertNull(dres1.getErrorMessage());
  593
+  		assertNull(dres11.getErrorMessage());
  594
+  		assertNull(dres2.getErrorMessage());
  595
+  		assertNull(dres22.getErrorMessage());
  596
+
  597
+  		System.out.println("Mol: " +
  598
+  				mol1.toSMILES());
  599
+  		System.out.println("Desc " + dres1.getDescriptor().getOntologyid() +": " + 
  600
+  				dres1.getLabels()[0] + "=" + dres1.getValues()[0] +", " + 
  601
+  				dres1.getLabels()[1] + "=" + dres1.getValues()[1] +", " + 
  602
+  				dres1.getLabels()[2] + "=" + dres1.getValues()[2] +", ");
  603
+
  604
+  		System.out.println("Mol: " + 
  605
+  		                   mol1.toSMILES());
  606
+  		System.out.println("Desc " + dres11.getDescriptor().getOntologyid() +": " + 
  607
+  				dres11.getLabels()[0] + "=" + dres11.getValues()[0] +", " + 
  608
+  				dres11.getLabels()[1] + "=" + dres11.getValues()[1] +", " + 
  609
+  				dres11.getLabels()[2] + "=" + dres11.getValues()[2] +", ");
  610
+
  611
+  		System.out.println("Mol: " + 
  612
+  		                   mol2.toSMILES());
  613
+  		System.out.println("Desc " + dres2.getDescriptor().getOntologyid() +": " + 
  614
+  				dres2.getLabels()[0] + "=" + dres2.getValues()[0] +", " + 
  615
+  				dres2.getLabels()[1] + "=" + dres2.getValues()[1] +", " + 
  616
+  				dres2.getLabels()[2] + "=" + dres2.getValues()[2] +", ");
  617
+
  618
+  		System.out.println("Mol: " + 
  619
+                         mol2.toSMILES());
  620
+  		System.out.println("Desc " + dres22.getDescriptor().getOntologyid() +": " + 
  621
+  				dres22.getLabels()[0] + "=" + dres22.getValues()[0] +", " + 
  622
+  				dres22.getLabels()[1] + "=" + dres22.getValues()[1] +", " + 
  623
+  				dres22.getLabels()[2] + "=" + dres22.getValues()[2] +", ");
  624
+
  625
+  		assertEquals(3, dres1.getLabels().length);
  626
+  		assertEquals(3, dres1.getValues().length);
  627
+  		assertEquals("label1", dres1.getLabels()[0]);
  628
+  		assertEquals("label2", dres1.getLabels()[1]);
  629
+  		assertEquals("label3", dres1.getLabels()[2]);
  630
+  		assertEquals(new Float(15.2456), dres1.getValues()[0]);
  631
+  		assertEquals(new Float(47.01), dres1.getValues()[1]);
  632
+  		assertEquals(new Float(-6.44), dres1.getValues()[2]);
  633
+  		
  634
+
  635
+  	}
  636
+  	
  637
+  	 @Test
  638
+  	  public void testCalculateMolDescMap() throws BioclipseException{
  639
+  	    
  640
+  	    IMolecule mol1=new SMILESMolecule("C1CCCCC1CC(CC)CC");
  641
+  	    IMolecule mol2=new SMILESMolecule("C1CCCCC1CC(CC)CCCCCO");
  642
+  	    String descriptorID="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#chiChain";
  643
+  	    String descriptorID2="http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#BCUT";
  644
+
  645
+  	    Descriptor desc1=qsar.getDescriptorByID( descriptorID );
  646
+        Descriptor desc2=qsar.getDescriptorByID( descriptorID2 );
  647
+        DescriptorImpl impl1 = qsar.g