Hi,
Am Donnerstag, den 03.02.2011, 20:35 +0100 schrieb Greg Landrum:
> Hi Hari,
>
> On Thu, Feb 3, 2011 at 4:47 PM, hari jayaram <[email protected]> wrote:
> > I have some rdkit code that calculates the Lipinski parameters for a given
> > rdkitmoleule.
> > I am working with someone who wants to port this code to java. I know very
> > little about swig or jython but wondering what the best way to accomplish
> > an equivalent functionality using rdkit within a java ecosystem would be.
> > Is there a jar file readily available for rdkit whereby one could write this
> > function in java . I did see some swig examples on the wiki that did this
> > from c code...but I dont know how to apply that to my case.
>
> There is not currently a convenient way to use the RDKit from java.
> We're currently working on something that should be ready in the next
> month or so that will make things easier than they are now. I will
> post an announcement when it's ready.
As a temporary workaround you can use jep
( http://jepp.sourceforge.net/ ) .
But you still have to install the complete (with python) rdkit on the
system which is running the python code. Not sure if this qualifies as a
solution. It's a workable solution if you have a relative narrow
interface between the rdkit and your java program.
Attached are a java and the corresponding python file.
regards,
Uwe
package jep;
import java.io.*;
import java.util.ArrayList;
import jep.python.*;
public class RDKTest implements Runnable {
private Jep jep = null;
public RDKTest() {}
public void run() {
try {
File pwd = new File(".");
this.jep = new Jep(false, pwd.getAbsolutePath());
jep.runScript("rdkit_test_descriptor.py");
int[] lipinskiResults = new int[10];
String[] lipinskiDescriptionResults = new String[10];
jep.invoke("lipinski",
"c1ccncc1CCCCCC(=O)OS",
lipinskiResults,
lipinskiDescriptionResults);
for(int i = 0; i < lipinskiResults.length; i++)
System.out.println(lipinskiDescriptionResults[i]+" : "+lipinskiResults[i]);
} catch(JepException e) {
System.out.println(e.getMessage());
}
}
public static void main(String argv[]) throws Throwable {
new Thread(new RDKTest()).start();
System.gc();
}
}
from jep import *
__builtins__.__import__ = jep.jimport
from java.lang import *
from java.util import HashMap
from java.io import FileInputStream
from rdkit import Chem
from rdkit.Chem import Lipinski
lipinski_methods = dict(
NOCount=Lipinski.NOCount,
NumHAcceptors=Lipinski.NumHAcceptors,
NumHDonors=Lipinski.NumHDonors,
NumHeteroatoms=Lipinski.NumHeteroatoms,
NumRotatableBonds=Lipinski.NumRotatableBonds,
RingCount=Lipinski.RingCount,
NHOHCount=Lipinski.NHOHCount)
def lipinski(smiles,resultArray,resultDescriptionArray):
mol = Chem.MolFromSmiles(smiles)
for ind,name in enumerate(lipinski_methods.keys()):
res=lipinski_methods[name](mol)
resultArray[ind] = res
resultDescriptionArray[ind] = name
resultArray.commit()
resultDescriptionArray.commit()
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss