From: Javi M. Z. <i12...@uc...> - 2007-11-21 17:44:06
|
Hi again, I've tried to apply smiles to store and retrieve molecules from = database, and it work right. The problem now is that when I'm going to display a molecule that come = from a smiles of database, itsn't possible due an error like this: Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 2 at org.openscience.cdk.geometry.GeometryToolsInternalCoordinates.distanceCal= cul ator(GeometryToolsInternalCoordinates.java:590) at org.openscience.cdk.geometry.GeometryTools.distanceCalculator(GeometryToo= ls. java:734) at org.openscience.cdk.renderer.AbstractRenderer2D.paintInnerBond(AbstractRe= nde rer2D.java:1247) at org.openscience.cdk.renderer.AbstractRenderer2D.paintRingBond(AbstractRen= der er2D.java:1086) at org.openscience.cdk.renderer.AbstractRenderer2D.paintBonds(AbstractRender= er2 D.java:967) at org.openscience.cdk.renderer.SimpleRenderer2D.paintMolecule(SimpleRendere= r2D .java:147) at org.openscience.cdk.applications.swing.MoleculeViewer2D.paint(MoleculeVie= wer 2D.java:284) The code I use to convert the Molecule to smiles and vice versa is this: public static String structureToSmiles(Molecule m){ SmilesGenerator generadorSmiles =3D new SmilesGenerator(); String smiles =3D new String(); smiles =3D generadorSmiles.createSMILES(m); =09 return smiles; } =20 public static Molecule smilesToStructure(String smiles){ SmilesParser sp =3D new SmilesParser(DefaultChemObjectBuilder.getInstance()); Molecule m =3D null; try { m =3D (Molecule)sp.parseSmiles(smiles); } catch (InvalidSmilesException e) { System.out.println(" ERROR: "+e); } =09 MoleculeViewer2D mv =3D new MoleculeViewer2D(m); mv.display(m, false, true, 2, " MCS para el smiles "+smiles); =09 return m; } There isn't any way to display molecules converted from a smiles?? Thanks a lot! -----Mensaje original----- De: sushil ronghe [mailto:ron...@gm...]=20 Enviado el: mi=E9rcoles, 21 de noviembre de 2007 14:11 Para: Javi Muriel Zafra Asunto: Re: [Cdk-user] Store molecules in a database You can read the molecule from .mol get the atom container convert it = to smile and then store in your DB (mysql or what ever you have). When you have to retrieve molecule then get the smile parse it by smile parser program you will get the AtomContainer back. I think this is the best way when you have to store large number of molecules and do some operation on them. On Nov 21, 2007 6:15 PM, Javi Muriel Zafra <i12...@uc...> wrote: > > Hi Rajarshi, I need store a molecule what come from a .mol file, but I = > store it from memory in a Molecule (or AtomContainer) object, as I = said. > So, I'll take a look about your information. > > Thanks again !! > > > -----Mensaje original----- > De: Rajarshi Guha [mailto:rg...@in...] Enviado el: mi=E9rcoles, = 21=20 > de noviembre de 2007 13:31 > Para: Javi Muriel Zafra > CC: cdk...@li... > Asunto: Re: [Cdk-user] Store molecules in a database > > > > On Nov 21, 2007, at 6:42 AM, Javi Muriel Zafra wrote: > > > Hi. > > > > I'm working with molecules in an application, and I want to store=20 > > them in a database. So, I would like to know how I can to store a=20 > > molecule what I have in a Molecule (or AtomContainer) object. The=20 > > type in which I store the molecule in the database table is a Long=20 > > Row, so I need to use the method PreparedStatement.setBinaryStream (JDBC). > > > > To read a molecule from de db I use the following code: > > > > ResultSet rset =3D stmt.executeQuery(" .... "); > > > > ... > > > > IChemObjectReader reader =3D new ReaderFactory().createReader( > > > > rset.getBinaryStream("structure")); > > > > ChemObject cmol =3D (ChemObject) reader.read( new=20 > > org.openscience.cdk.Molecule()); > > > > IAtomContainer iaTemp =3D (IAtomContainer) cmol; > > > > I've tried to "reverse" the code to adapt for write a molecule, but=20 > > I've not obtained it. Any idea?? > > You could store molecules in a variety of ways > > * SMILES > * SDF > * a binary object (Postgres+Tigress supports this) > > On the hand, it looks like you want Java object serialization. See > http://www.devx.com/tips/Tip/12439 for an example > > ------------------------------------------------------------------- > Rajarshi Guha <rg...@in...> > GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE > ------------------------------------------------------------------- > > Q: What is a dyslexic, agnostic, insomniac? > A: Someone who lays awake at night wondering if there really is a dog! > > > > > ---------------------------------------------------------------------- > --- This SF.net email is sponsored by: Microsoft Defy all challenges.=20 > Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Cdk-user mailing list > Cdk...@li... > https://lists.sourceforge.net/lists/listinfo/cdk-user > -- ******************************** sushil ronghe ********************************* |