JOELib Tutorial: A Java based cheminformatics/computational chemistry package | ||
---|---|---|
Prev | Chapter 9. JOELib examples and code snippets | Next |
abc.
abc.
The Chemical Development Kit (CDK) interface supports only the generation of 2D coordinates.
Example 9-25. Chemical Development Kit (CDK) interface
TestSMILES joeMolTest = new TestSMILES(); JOEMol mol = new JOEMol(IOTypeHolder.instance().getIOType("SMILES"), IOTypeHolder.instance().getIOType("SDF")); System.out.println("Generate molecule from SMILES: \"" + smiles + "\""); // create molecule from SMILES string if (!JOESmilesParser.smiToMol(mol, smiles, "Name:" + smiles)) { System.err.println("Molecule could not be generated from \"" + smiles + "\"."); } // Layout test System.out.println("Generate 2D coordinates:"); CDKTools.generate2D(mol); // show molecule with 2D coordinates System.out.println(mol);
The Weka data mining library data mining interface can be used mainly designed for clustering and classification tasks. For regression it's recommended to use e.g. the JavaNNS interface or other interfaces this group will provide.
Example 9-26. Weka data mining interface
// open file input stream FileInputStream in = null; JOEMolVector mols = null; // create molecule vector try { in = new FileInputStream(inputFile); mols = new JOEMolVector(in); } catch (Exception ex) { ex.printStackTrace(); System.exit(1); } // load descriptor binning DescBinning binning = DescBinning.getDescBinning(mols); // create Weka attribute types // we assume the following format: // all attributes are numeric, except the class index, which is // a nominal attribute. // Please refer for further help the Weka tutorial and mailing list Enumeration enum = binning.getDescriptors(); String attributes[] = new String[binning.numberOfDescriptors()]; int attributeTypes[] = new int[binning.numberOfDescriptors()]; int i = 0; int classAttributeIndex = -1; for (; enum.hasMoreElements(); i++) { attributes[i] = (String) enum.nextElement(); if (attributes[i].equals(classAttributeName)) { classAttributeIndex = i; attributeTypes[i] = Attribute.NOMINAL; } else { attributeTypes[i] = Attribute.NUMERIC; } } // check class index if (classAttributeIndex == -1) { logger.error("Class attribute " + classAttributeName + " not found."); System.exit(1); } // create Weka instances MolInstances instances = MolInstances.createMolInstances(mols, attributes, attributeTypes); // set class index instances.setClassIndex(classAttributeIndex);
To use LibGhemical you must install the system specififc JNI interfaces under lib/linux and lib/windows. The LibGhemical parameter sets for initializing the force field must be also already installed. The default path is /usr/local/share/libghemical/1.51/, but these things can vary with a new release or if you have compiled LibGhemical on your own (recommended).
Example 9-27. Create 3D coordinates using the Ghemical force field (molecular mechanics)
TestSMILES joeMolTest = new TestSMILES(); JOEMol mol = new JOEMol(IOTypeHolder.instance().getIOType("SMILES"), IOTypeHolder.instance().getIOType("SDF")); System.out.println("Generate molecule from SMILES: \"" + smiles + "\""); // create molecule from SMILES string if (!JOESmilesParser.smiToMol(mol, smiles, "Name:" + smiles)) { System.err.println("Molecule could not be generated from \"" + smiles + "\"."); } // Layout test System.out.println("Generate 3D coordinates:"); double tresholdDeltaE = 1.0e-14; double tresholdStep = 6.0e-11; int numSteps = 2000; // when all coordinates are zero the molecule coordinates will be initialized // with random coordinates if (!GhemicalInterface.instance().doGeometryOptimization( mol, numSteps, tresholdDeltaE, tresholdStep, true)) { logger.error("Could not apply energy minimization."); System.exit(1); } // show molecule with 2D coordinates System.out.println(mol);
abc.
Download the JOELib-Matlab toolbox to use this feature.
This can be esablished when using the JMatLink JNI interface (see also the Section called Matlab toolbox in Chapter 1).