2変数によるLogPの回帰

せっかくcdk-1.3.12をインストールしたので、新クラスを使ってみます。


非常にシンプルなLogP計算手法が実装されています。
なんと、「炭素数」と「ヘテロ原子数」の2変数だけから回帰します(参考までに、XLogPは90変数)。

提案された原著論文*1によると、
従来法と遜色ない精度を示すそうです。


/* mannholdlogp.java */

import java.io.*;
import org.openscience.cdk.interfaces.*;
import org.openscience.cdk.io.iterator.IteratingSMILESReader;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.config.Elements;

class mannholdlogp {
public static void main(String args[]){

if(args.length!=1){
System.err.println("mannholdlogp <smiles-file>");
System.exit(1);
}
FileInputStream fis = null;
IteratingSMILESReader isr = null;
try{
fis = new FileInputStream(new File(args[0]));
isr = new IteratingSMILESReader(fis);
} catch (Exception e) {
e.printStackTrace();
}
while( isr.hasNext() ){
IMolecule imol = (IMolecule)isr.next();
String id = (String)imol.getProperty("cdk:Title");

int carbonCount = 0;
int heteroCount = 0;
for (IAtom atom : imol.atoms()) {
if (!Elements.HYDROGEN.getSymbol().equals(atom.getSymbol())) {
if (Elements.CARBON.getSymbol().equals(atom.getSymbol())) {
carbonCount++;
} else {
heteroCount++;
}
}
}
double mLogP = 1.46 + 0.11*carbonCount - 0.11*heteroCount;

System.out.printf("%s\t%.3f\n", id, mLogP);
}
}
}

コードも短くて読みやすいのです。

*1: Mannhold et al. Calculation of molecular lipophilicity: State-of-the-art and comparison of log P methods on more than 96,000 compounds. J Pharm Sci. (2009) 98, 861-93 PubMed