Recently I use web app made with ruby.
The app is very useful for me, but there is not chemoinformatics library in ruby.
So, I want to find way to use rdkit from ruby.
I found some web page that described how to run shell script from ruby. The simplest way is using back quotation.
It is means call “python xxx.py” from ruby.
I tested it.
At first, I wrote sample script named test.py. Just load SDF and print molecules as smiles.
from rdkit import Chem sdf = Chem.SDMolSupplier( 'cdk2.sdf' ) for mol in sdf: smi = Chem.MolToSmiles( mol ) print( smi )
Then, I wrote ruby script.
It just call test.py. That’s all. ;-)
callpy.rb
res = `python test.py` print res
Run callpy.rb.
iwatobipen$ ruby callpy.rb ........... Cn1cnc2c(NCc3ccccc3)nc(NCCO)nc21 CCC(CO)Nc1nc(NCc2ccccc2)c2ncn(C(C)C)c2n1 COc1ccc(CNc2nc(N(CCO)CCO)nc3c2ncn3C(C)C)cc1 Nc1nc(N)c(N=O)c(OCC2CCCCC2)n1 COc1ccc2c(c1)C(=Cc1cnc[nH]1)C(=O)N2 COc1cc[nH]c1C=C1C(=O)Nc2ccc([N+](=O)[O-])cc21 CCc1cnc(CSc2cnc(NC(=O)C(C)C)s2)o1 CCCCOc1c(C(=O)c2nccs2)cnc2[nH]ncc12 COc1cc(-c2ccc[nH]2)c2c3c(ccc(F)c13)NC2=O [NH3+]CCSc1cc(-c2ccc[nH]2)c2c3c(ccc(F)c13)NC2=O NC(=O)Nc1cccc2c1C(=O)c1c-2n[nH]c1-c1cccs1 COc1ccc2c(c1)C(=Cc1[nH]cc3c1CCOC3=O)C(=O)N2 CNS(=O)(=O)c1ccc2c(c1)C(=Cc1[nH]cc3c1CCNC3=O)C(=O)N2 CC(=O)Nc1cccc2c1C(=O)c1c-2n[nH]c1-c1ccncc1 ....
It worked. ;-)
There are some ways to call shell script from ruby. I will try another method soon.