I am attempting to create a 3D structure building program, using
Rajarshi Guha's CDKstruct3D.java as a model. The code hangs up on
the .setTemplateHandler() call, eventually leading to an out of
memory exception from Java. CDKstruc3D gives the same problem. Does
anyone else have experience with this problem?
Thanks,
Dave Strumfels
________________________________________________________________________
Try Juno Platinum for Free! Then, only $9.95/month!
Unlimited Internet Access with 1GB of Email Storage.
Visit http://www.juno.com/value to sign up today!
import org.openscience.cdk.modeling.builder3d.ModelBuilder3D;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.io.*;
import org.openscience.cdk.smiles.SmilesParser;
import org.openscience.cdk.tools.HydrogenAdder;
import org.openscience.cdk.tools.MFAnalyser;
import org.openscience.cdk.exception.*;
import java.util.*;
import java.io.*;
public class ProcessSMILES3D
{
SmilesParser sp = null;
IMolecule mol = null;
HydrogenAdder hAdder = null;
ModelBuilder3D mb3d = null;
public ProcessSMILES3D()
{
try
{
sp = new SmilesParser();
mb3d = new ModelBuilder3D();
mb3d.setTemplateHandler();
mb3d.setForceField("mm2");
hAdder = new HydrogenAdder();
}
catch (Exception e)
{
System.out.println(e.toString());
System.exit(1);
}
}
public float[] doProcessing(String smiles, String outputFile)
{
try
{
mol = sp.parseSmiles(smiles);
mb3d.setMolecule(mol, false);
mb3d.generate3DCoordinates();
mol = mb3d.getMolecule();
FileWriter fw = new FileWriter(outputFile + ".mol");
MDLWriter mdlmw = new MDLWriter(fw);
System.out.print(" writing mol file ... ");
mdlmw.write(mol);
mdlmw.close();
fw.close();
fw = new FileWriter(outputFile + ".xml");
CMLWriter cmlmw = new CMLWriter(fw);
cmlmw.write(mol);
System.out.println("[ok]");
cmlmw.close();
fw.close();
hAdder.addExplicitHydrogensToSatisfyValency(mol);
MFAnalyser mfa = new MFAnalyser(mol);
float[] mw = new float[2];
mw[0] = mfa.getCanonicalMass();
mw[1] = mfa.getNaturalMass();
return mw;
}
catch (Exception e)
{
System.out.println(e.toString());
System.exit(1);
}
return null;
}
public static void main(String args[])
{
try
{
String inputLine, smiles, outputFile, tab = "\t";
String newLine = System.getProperty("line.separator");
StringTokenizer stk;
float[] mw;
BufferedReader br = new BufferedReader(new FileReader(args[0]));
FileWriter fw = new FileWriter(args[0] + ".mw");
ProcessSMILES3D processor = new ProcessSMILES3D();
while ((inputLine = br.readLine()) != null)
{
stk = new StringTokenizer(inputLine, tab);
smiles = stk.nextToken();
outputFile = stk.nextToken();
mw = processor.doProcessing(smiles, outputFile);
fw.write(smiles + tab + mw[0] + tab + mw[1] + newLine);
}
fw.flush();
fw.close();
br.close();
}
catch (Exception e)
{
System.out.println(e.toString());
System.exit(1);
}
}
}
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user