Skip to content

Commit

Permalink
Implemented a progressbar that ticks by descr/mol calculation and add…
Browse files Browse the repository at this point in the history
…ed option to cancel build.

git-svn-id: https://bioclipse.svn.sourceforge.net/svnroot/bioclipse/bioclipse2/trunk@7041 fcb5ba71-d80d-0410-8237-ba3920747fcc
  • Loading branch information
ospjuth authored and egonw committed Jul 17, 2009
1 parent 32ae53e commit 94c6c75
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/net.bioclipse.cdk.qsar.test/META-INF/MANIFEST.MF
Expand Up @@ -12,7 +12,10 @@ Require-Bundle: org.eclipse.ui,
net.bioclipse.core;bundle-version="2.0.0",
net.bioclipse.qsar;bundle-version="1.0.0",
org.junit4;bundle-version="4.3.1",
org.eclipse.emf.ecore.edit;bundle-version="2.4.0"
org.eclipse.emf.ecore.edit;bundle-version="2.4.0",
net.bioclipse.core.tests;bundle-version="0.1.0",
org.eclipse.core.resources;bundle-version="3.4.0",
org.openscience.cdk;bundle-version="1.1.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Import-Package: org.apache.log4j;version="1.2.15"
Expand Up @@ -2,10 +2,17 @@

import static org.junit.Assert.*;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import net.bioclipse.cdk.business.ICDKManager;
import net.bioclipse.cdk.domain.ICDKMolecule;
import net.bioclipse.core.MockIFile;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.domain.IMolecule;
import net.bioclipse.core.domain.SmilesMolecule;
Expand All @@ -20,9 +27,15 @@
import net.bioclipse.qsar.descriptor.model.DescriptorProvider;
import net.bioclipse.qsar.init.Activator;

import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.junit.Test;
import org.osgi.framework.Bundle;

public class TestCDKQsar {

Expand Down Expand Up @@ -225,6 +238,41 @@ public void testCalculateXlogPFromSmiles() throws BioclipseException{


}

@Test
public void testCalculateXlogPFromCML() throws BioclipseException, FileNotFoundException, IOException, CoreException{

ICDKManager cdk=net.bioclipse.cdk.business.Activator.getDefault().getCDKManager();

Bundle bun=Platform.getBundle(net.bioclipse.cdk.qsar.test.Activator.PLUGIN_ID);
System.out.println("wee bun: " + bun);

URL url=FileLocator.find(bun, new Path("src/testFiles/0037.cml"), null);
System.out.println("wee url: " + url);

String str=FileLocator.toFileURL(url).getFile();
System.out.println("wee File: " + str);

ICDKMolecule mol = cdk.loadMolecule( new MockIFile(str), null );

IDescriptorResult dres1=qsar.calculate(mol, xlogpID);
assertNotNull(dres1);
assertNull(dres1.getErrorMessage(),dres1.getErrorMessage());
assertEquals(xlogpID, dres1.getDescriptorId());

System.out.println("Mol: " + mol.getSmiles() +
" ; Desc: " + dres1.getDescriptorId() +": ");
for (int i=0; i<dres1.getValues().length;i++){
System.out.println(" " + dres1.getLabels()[i]
+ "=" + dres1.getValues()[i] );
}

assertEquals("XLogP", dres1.getLabels()[0]);
assertEquals(0.184, dres1.getValues()[0]);


}


@Test
public void testCalculateBCUTFromSmiles() throws BioclipseException{
Expand Down
@@ -0,0 +1,67 @@
package net.bioclipse.cdk.qsar.test;

import java.io.InputStream;

import org.openscience.cdk.atomtype.CDKAtomTypeMatcher;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IChemFile;
import org.openscience.cdk.io.CMLReader;
import org.openscience.cdk.io.ReaderFactory;
import org.openscience.cdk.io.formats.CMLFormat;
import org.openscience.cdk.io.formats.IChemFormatMatcher;
import org.openscience.cdk.tools.CDKHydrogenAdder;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;

public class testCDKAT {

/**
* @param args
*/
public static void main(String[] args) {

InputStream ins = testCDKAT.class.getResourceAsStream("/testFiles/0037.cml");

CMLReader reader=new CMLReader(ins);

IChemFile chemFile = new org.openscience.cdk.ChemFile();


//Read file
try {
chemFile=(IChemFile)reader.read(chemFile);
} catch (CDKException e) {
e.printStackTrace();
}

IAtomContainer container = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);

try {

CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(container.getBuilder());
for (IAtom atom : container.atoms()) {
IAtomType matched = matcher.findMatchingAtomType(container, atom);
if (matched != null){
AtomTypeManipulator.configure(atom, matched);
}else{
System.out.println("Could not find matching atom type for atom: " + atom);
}
}

CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(container.getBuilder());
hAdder.addImplicitHydrogens(container);
AtomContainerManipulator.convertImplicitToExplicitHydrogens(container);

} catch (Exception e1) {
System.out.println("Error addding hydrogens : " + e1.getMessage());
}



}

}
1 change: 1 addition & 0 deletions plugins/net.bioclipse.cdk.qsar.test/src/testFiles/0037.cml
@@ -0,0 +1 @@
<cml xmlns="http://www.xml-cml.org/schema"><molecule title="" id="nmrshiftdb20110444"><atomArray><atom id="a1" elementType="C" x2="2.89" y2="-1.25" formalCharge="0" hydrogenCount="0" /><atom id="a2" elementType="C" x2="2.89" y2="-0.42" formalCharge="0" hydrogenCount="0" /><atom id="a3" elementType="C" x2="2.17" y2="0.0" formalCharge="0" hydrogenCount="0" /><atom id="a4" elementType="C" x2="1.44" y2="-0.42" formalCharge="0" hydrogenCount="0" /><atom id="a5" elementType="C" x2="1.44" y2="-1.25" formalCharge="0" hydrogenCount="0" /><atom id="a6" elementType="C" x2="0.72" y2="-1.67" formalCharge="0" hydrogenCount="0" /><atom id="a7" elementType="C" x2="3.61" y2="-1.67" formalCharge="0" hydrogenCount="0" /><atom id="a8" elementType="C" x2="2.17" y2="-2.5" formalCharge="0" hydrogenCount="0" /><atom id="a9" elementType="C" x2="2.89" y2="-2.92" formalCharge="0" hydrogenCount="0" /><atom id="a10" elementType="C" x2="1.44" y2="-2.92" formalCharge="0" hydrogenCount="0" /><atom id="a11" elementType="C" x2="0.0" y2="-4.58" formalCharge="0" hydrogenCount="0" /><atom id="a12" elementType="C" x2="0.72" y2="-5.0" formalCharge="0" hydrogenCount="0" /><atom id="a13" elementType="C" x2="0.0" y2="-3.75" formalCharge="0" hydrogenCount="0" /><atom id="a14" elementType="C" x2="2.89" y2="-3.75" formalCharge="0" hydrogenCount="0" /><atom id="a15" elementType="C" x2="3.61" y2="-4.17" formalCharge="0" hydrogenCount="0" /><atom id="a16" elementType="C" x2="4.33" y2="-3.75" formalCharge="0" hydrogenCount="0" /><atom id="a17" elementType="C" x2="4.33" y2="-2.92" formalCharge="0" hydrogenCount="0" /><atom id="a18" elementType="C" x2="3.61" y2="-2.5" formalCharge="0" hydrogenCount="0" /><atom id="a19" elementType="O" x2="1.44" y2="-3.75" formalCharge="0" hydrogenCount="0" /><atom id="a20" elementType="N" x2="2.17" y2="-1.67" formalCharge="0" hydrogenCount="0" /><atom id="a21" elementType="N" x2="0.0" y2="-2.08" formalCharge="0" hydrogenCount="0" /><atom id="a22" elementType="Si" x2="0.72" y2="-4.17" formalCharge="0" hydrogenCount="0" /></atomArray><bondArray><bond id="b1" atomRefs2="a1 a20" order="S" /><bond id="b2" atomRefs2="a1 a2" order="S" /><bond id="b3" atomRefs2="a1 a7" order="S" /><bond id="b4" atomRefs2="a2 a3" order="S" /><bond id="b5" atomRefs2="a3 a4" order="S" /><bond id="b6" atomRefs2="a4 a5" order="S" /><bond id="b7" atomRefs2="a5 a20" order="S" /><bond id="b8" atomRefs2="a5 a6" order="S" /><bond id="b9" atomRefs2="a6 a21" order="T" /><bond id="b10" atomRefs2="a8 a20" order="S" /><bond id="b11" atomRefs2="a8 a9" order="S" /><bond id="b12" atomRefs2="a8 a10" order="S" /><bond id="b13" atomRefs2="a9 a14" order="D" /><bond id="b14" atomRefs2="a9 a18" order="S" /><bond id="b15" atomRefs2="a10 a19" order="S" /><bond id="b16" atomRefs2="a11 a22" order="S" /><bond id="b17" atomRefs2="a12 a22" order="S" /><bond id="b18" atomRefs2="a13 a22" order="S" /><bond id="b19" atomRefs2="a14 a15" order="S" /><bond id="b20" atomRefs2="a15 a16" order="D" /><bond id="b21" atomRefs2="a16 a17" order="S" /><bond id="b22" atomRefs2="a17 a18" order="D" /><bond id="b23" atomRefs2="a19 a22" order="S" /></bondArray></molecule></cml>

0 comments on commit 94c6c75

Please sign in to comment.