Skip to content

Instantly share code, notes, and snippets.

@tckb
Created September 21, 2014 10:59
Show Gist options
  • Save tckb/7b27a4e73c618b05b705 to your computer and use it in GitHub Desktop.
Save tckb/7b27a4e73c618b05b705 to your computer and use it in GitHub Desktop.
public class CalculateDescriptors
{
private static void forTrainingSet(String smileFile)
throws FileNotFoundException
{
IteratingSMILESReader reader = new IteratingSMILESReader(new FileInputStream(smileFile), DefaultChemObjectBuilder.getInstance());
while (reader.hasNext())
{
IAtomContainer molecule = reader.next();
ToxDescriptor desc = new ToxDescriptor();
desc.setHBondAcceptors(CDKUtil.Molecule.getHBondAcceptorCount(molecule));
desc.setHBondDonors(CDKUtil.Molecule.getHBondDonorCount(molecule));
desc.setHeteroAtoms(CDKUtil.Molecule.getHeteroAtomCount(molecule));
desc.setMolecularWeight(CDKUtil.Molecule.getExactMass(molecule));
desc.setRotatableBonds(CDKUtil.Molecule.getRotatableBondCount(molecule));
desc.setRuleOfFive(CDKUtil.Molecule.obeysRuleOfFive(molecule));
desc.setTPSA(CDKUtil.Molecule.getTPSA(molecule));
desc.setXLogP(CDKUtil.Molecule.getXLogP(molecule));
System.out.println(desc.toString());
}
}
public static void main(String[] args)
{
String file = "/home/vishal/charite/tox21/all_targets_sdf/nr-aromatase.smi";
try
{
forTrainingSet(file);
}
catch (FileNotFoundException ex)
{
Logger.getLogger(CalculateDescriptors.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment