From a90047977da5a635072f2833816726eaf721aa88 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 9 Nov 2016 10:03:46 +0100 Subject: CDK 2.0 --- java/CdkDescriptorInfo.class | Bin 1705 -> 1826 bytes java/CdkDescriptorInfo.java | 5 ++-- java/CdkDescriptors.class | Bin 6167 -> 6240 bytes java/CdkDescriptors.java | 56 +++++++++++++++++++++---------------------- java/Rakefile | 6 ++--- java/cdk-1.4.19.jar | Bin 16877592 -> 0 bytes java/cdk-2.0-SNAPSHOT.jar | Bin 0 -> 26800460 bytes test/descriptor.rb | 5 ++-- 8 files changed, 37 insertions(+), 35 deletions(-) delete mode 100644 java/cdk-1.4.19.jar create mode 100644 java/cdk-2.0-SNAPSHOT.jar diff --git a/java/CdkDescriptorInfo.class b/java/CdkDescriptorInfo.class index 9b9408e..ff67505 100644 Binary files a/java/CdkDescriptorInfo.class and b/java/CdkDescriptorInfo.class differ diff --git a/java/CdkDescriptorInfo.java b/java/CdkDescriptorInfo.java index 73a65ac..296c93d 100644 --- a/java/CdkDescriptorInfo.java +++ b/java/CdkDescriptorInfo.java @@ -1,11 +1,12 @@ import java.util.*; -import org.openscience.cdk.qsar.descriptors.molecular.*; +import org.openscience.cdk.DefaultChemObjectBuilder; import org.openscience.cdk.qsar.*; +//import org.openscience.cdk.qsar.descriptors.molecular.*; class CdkDescriptorInfo { public static void main(String[] args) { - DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR); + DescriptorEngine engine = new DescriptorEngine(IMolecularDescriptor.class,null); for (Iterator it = engine.getDescriptorInstances().iterator(); it.hasNext(); ) { IDescriptor descriptor = it.next(); diff --git a/java/CdkDescriptors.class b/java/CdkDescriptors.class index 49bfaf2..e37a69a 100644 Binary files a/java/CdkDescriptors.class and b/java/CdkDescriptors.class differ diff --git a/java/CdkDescriptors.java b/java/CdkDescriptors.java index 1236240..b5f8672 100644 --- a/java/CdkDescriptors.java +++ b/java/CdkDescriptors.java @@ -1,10 +1,10 @@ import java.util.*; import java.io.*; import org.openscience.cdk.DefaultChemObjectBuilder; -import org.openscience.cdk.interfaces.IMolecule; -import org.openscience.cdk.io.iterator.IteratingMDLReader; +import org.openscience.cdk.IImplementationSpecification; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.io.iterator.IteratingSDFReader; import org.openscience.cdk.qsar.*; -import org.openscience.cdk.qsar.DescriptorValue; import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; import org.openscience.cdk.exception.NoSuchAtomTypeException; @@ -17,8 +17,8 @@ class CdkDescriptors { System.exit(1); } if (! new File(args[0]).exists()){ - System.err.println("file not found "+args[0]); - System.exit(1); + System.err.println("file not found "+args[0]); + System.exit(1); } // command line descriptor params can be either "descriptorName" or "descriptorValueName" @@ -34,19 +34,19 @@ class CdkDescriptors { for (int i =1; i < args.length; i++) { String descriptorName; if (args[i].indexOf(".")!=-1) { - descriptorValueNames.add(args[i]); - descriptorName = args[i].substring(0,args[i].indexOf(".")); + descriptorValueNames.add(args[i]); + descriptorName = args[i].substring(0,args[i].indexOf(".")); } else { - descriptorNames.add(args[i]); - descriptorName = args[i]; + descriptorNames.add(args[i]); + descriptorName = args[i]; } classNames.add(getDescriptorClassName(descriptorName)); } - engine = new DescriptorEngine(new ArrayList(classNames)); + engine = new DescriptorEngine(new ArrayList(classNames),null); List instances = engine.instantiateDescriptors(new ArrayList(classNames)); - List specs = engine.initializeSpecifications(instances); + List specs = engine.initializeSpecifications(instances); engine.setDescriptorInstances(instances); engine.setDescriptorSpecifications(specs); @@ -54,13 +54,13 @@ class CdkDescriptors { BufferedReader br = new BufferedReader(new FileReader(args[0])); PrintWriter yaml = new PrintWriter(new FileWriter(args[0]+"cdk.yaml")); // parse 3d sdf from file and calculate descriptors - IteratingMDLReader reader = new IteratingMDLReader( br, DefaultChemObjectBuilder.getInstance()); + IteratingSDFReader reader = new IteratingSDFReader( br, DefaultChemObjectBuilder.getInstance()); int c = 0; while (reader.hasNext()) { try { System.out.println("computing "+(args.length-1)+" descriptors for compound "+(++c)); - IMolecule molecule = (IMolecule)reader.next(); - molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule); + IAtomContainer molecule = (IAtomContainer)reader.next(); + molecule = (IAtomContainer) AtomContainerManipulator.removeHydrogens(molecule); try { AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); } @@ -110,21 +110,21 @@ class CdkDescriptors { * problem: Descriptor is not always at the end of the class (APolDescriptor), but may be in the middle (AutocorrelationDescriptorPolarizability) * this method makes a class-lookup using trial and error */ static String getDescriptorClassName(String descriptorName) { - String split = splitCamelCase(descriptorName)+" "; // space mark possible positions for 'Descriptor' - for(int i = split.length()-1; i>0; i--) { - if (split.charAt(i)==' ') { // iterate over all spaces, starting with the trailing one - String test = split.substring(0,i)+"Descriptor"+split.substring(i+1,split.length()); // replace current space with 'Descriptor' .. - test = test.replaceAll("\\s",""); // .. and remove other spaces - String className = "org.openscience.cdk.qsar.descriptors.molecular." + test; - try { - Class.forName(className); - return className; - } catch (ClassNotFoundException e) {} - } + String split = splitCamelCase(descriptorName)+" "; // space mark possible positions for 'Descriptor' + for(int i = split.length()-1; i>0; i--) { + if (split.charAt(i)==' ') { // iterate over all spaces, starting with the trailing one + String test = split.substring(0,i)+"Descriptor"+split.substring(i+1,split.length()); // replace current space with 'Descriptor' .. + test = test.replaceAll("\\s",""); // .. and remove other spaces + String className = "org.openscience.cdk.qsar.descriptors.molecular." + test; + try { + Class.forName(className); + return className; + } catch (ClassNotFoundException e) {} } - System.err.println("Descriptor not found: "+descriptorName); - System.exit(1); - return null; + } + System.err.println("Descriptor not found: "+descriptorName); + System.exit(1); + return null; } /** inserts space in between camel words */ diff --git a/java/Rakefile b/java/Rakefile index a865528..214c3aa 100644 --- a/java/Rakefile +++ b/java/Rakefile @@ -1,7 +1,7 @@ # Java class, classpath java_classes = [ - ["CdkDescriptors", "cdk-1.4.19.jar"], - ["CdkDescriptorInfo", "cdk-1.4.19.jar"], + ["CdkDescriptors", "cdk-2.0-SNAPSHOT.jar"], + ["CdkDescriptorInfo", "cdk-2.0-SNAPSHOT.jar"], ["JoelibDescriptors", "joelib2.jar:."], ["JoelibDescriptorInfo", "joelib2.jar:."], ] @@ -10,6 +10,6 @@ task :default => java_classes.collect{|c| "#{c.first}.class"} java_classes.each do |c| file "#{c.first}.class" => "#{c.first}.java" do - puts `javac -classpath #{c.last} #{c.first}.java` + puts `javac -Xlint:deprecation -classpath #{c.last} #{c.first}.java` end end diff --git a/java/cdk-1.4.19.jar b/java/cdk-1.4.19.jar deleted file mode 100644 index 3281c87..0000000 Binary files a/java/cdk-1.4.19.jar and /dev/null differ diff --git a/java/cdk-2.0-SNAPSHOT.jar b/java/cdk-2.0-SNAPSHOT.jar new file mode 100644 index 0000000..f55e55e Binary files /dev/null and b/java/cdk-2.0-SNAPSHOT.jar differ diff --git a/test/descriptor.rb b/test/descriptor.rb index 42d4661..6eb4316 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -4,10 +4,11 @@ class DescriptorTest < MiniTest::Test def test_list # check available descriptors - assert_equal 355,PhysChem.descriptors.size,"incorrect number of physchem descriptors" assert_equal 15,PhysChem.openbabel_descriptors.size,"incorrect number of Openbabel descriptors" - assert_equal 295,PhysChem.cdk_descriptors.size,"incorrect number of Cdk descriptors" assert_equal 45,PhysChem.joelib_descriptors.size,"incorrect number of Joelib descriptors" + p PhysChem.cdk_descriptors + assert_equal 286,PhysChem.cdk_descriptors.size,"incorrect number of Cdk descriptors" + assert_equal 346,PhysChem.descriptors.size,"incorrect number of physchem descriptors" end def test_smarts -- cgit v1.2.3