Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: joelib/io/types/cml/MoleculeFileCDO.java


1   ///////////////////////////////////////////////////////////////////////////////
2   //Filename: $RCSfile: MoleculeFileCDO.java,v $
3   //Purpose:  Chemical Markup Language.
4   //Language: Java
5   //Compiler: JDK 1.4
6   //Authors:  steinbeck@ice.mpg.de, gezelter@maul.chem.nd.edu,
7   //      egonw@sci.kun.nl, wegnerj@informatik.uni-tuebingen.de
8   //Version:  $Revision: 1.21 $
9   //      $Date: 2003/08/22 15:56:18 $
10  //      $Author: wegner $
11  //
12  //Copyright (C) 1997-2003  The Chemistry Development Kit (CDK) project
13  //Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
14  //
15  //This program is free software; you can redistribute it and/or
16  //modify it under the terms of the GNU Lesser General Public License
17  //as published by the Free Software Foundation; either version 2.1
18  //of the License, or (at your option) any later version.
19  //All we ask is that proper credit is given for our work, which includes
20  //- but is not limited to - adding the above copyright notice to the beginning
21  //of your source code files, and to any copyright notice that you may distribute
22  //with programs based on this work.
23  //
24  //This program is distributed in the hope that it will be useful,
25  //but WITHOUT ANY WARRANTY; without even the implied warranty of
26  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  //GNU Lesser General Public License for more details.
28  //
29  //You should have received a copy of the GNU Lesser General Public License
30  //along with this program; if not, write to the Free Software
31  //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
32  ///////////////////////////////////////////////////////////////////////////////
33  package joelib.io.types.cml;
34  
35  import joelib.data.JOEDataType;
36  import joelib.data.JOEElementTable;
37  import joelib.data.JOEGenericData;
38  import joelib.data.JOEPairData;
39  
40  import joelib.desc.result.AtomDoubleResult;
41  import joelib.desc.result.BitArrayResult;
42  import joelib.desc.result.BooleanResult;
43  import joelib.desc.result.DoubleArrayResult;
44  import joelib.desc.result.DoubleMatrixResult;
45  import joelib.desc.result.DoubleResult;
46  import joelib.desc.result.IntArrayResult;
47  import joelib.desc.result.IntMatrixResult;
48  import joelib.desc.result.IntResult;
49  import joelib.desc.result.StringResult;
50  
51  import joelib.io.IOTypeHolder;
52  
53  import joelib.molecule.JOEAtom;
54  import joelib.molecule.JOEBond;
55  import joelib.molecule.JOEMol;
56  
57  import joelib.util.IsomerismDetection;
58  
59  import joelib.util.types.BondInt;
60  
61  /*==========================================================================*
62   * IMPORTS
63   *========================================================================== */
64  import java.util.Enumeration;
65  import java.util.Hashtable;
66  import java.util.Vector;
67  
68  import org.apache.log4j.Category;
69  
70  
71  /*==========================================================================*
72   * CLASS DECLARATION
73   *========================================================================== */
74  
75  /**
76   * CDO object needed as interface with the JCFL library for reading CML
77   * encoded data.
78   *
79   * @author    egonw
80   * @author     wegnerj
81   * @license LGPL
82   * @cvsversion    $Revision: 1.21 $, $Date: 2003/08/22 15:56:18 $
83   * @cite rr99b
84   * @cite mr01
85   * @cite gmrw01
86   * @cite wil01
87   */
88  public class MoleculeFileCDO implements CDOInterface
89  {
90      //~ Static fields/initializers /////////////////////////////////////////////
91  
92      /*-------------------------------------------------------------------------*
93       * private static member variables
94       *------------------------------------------------------------------------- */
95  
96      /**
97       * Obtain a suitable logger.
98       */
99      private static Category logger = Category.getInstance(
100             "joelib.io.types.cml.MoleculeFileCDO");
101 
102     //~ Instance fields ////////////////////////////////////////////////////////
103 
104     private Hashtable atomEnumeration = new Hashtable();
105     private Hashtable strings = new Hashtable(10);
106     private Hashtable unparsed = new Hashtable(10);
107     private JOEAtom currentAtom;
108 
109     /*-------------------------------------------------------------------------*
110      * private member variables
111      *------------------------------------------------------------------------- */
112     private JOEMol currentMolecule;
113     private Vector c2Dx = new Vector();
114     private Vector c2Dy = new Vector();
115     private Vector c3Dx = new Vector();
116     private Vector c3Dy = new Vector();
117     private Vector c3Dz = new Vector();
118 
119     /**
120      * Of type {@link joelib.util.types.BondInt}
121          */
122     private Vector ezInformations = new Vector(10);
123     private double x_2D;
124     private double x_3D;
125     private double y_2D;
126     private double y_3D;
127     private double z_3D;
128     private int bond_EZ;
129     private int bond_a1;
130     private int bond_a2;
131     private int bond_order;
132     private int bond_stereo;
133     private int molIndex;
134     private int numberOfAtoms;
135 
136     //~ Methods ////////////////////////////////////////////////////////////////
137 
138     /**
139      * Procedure required by the CDOInterface. This methodName is only
140      * supposed to be called by the JCFL library
141      *
142      * @param type   The new documentProperty value
143      * @param value  The new documentProperty value
144      */
145     public void setDocumentProperty(String type, Object value)
146     {
147     }
148 
149     /*-------------------------------------------------------------------------*
150      * constructor
151      *------------------------------------------------------------------------- */
152 
153     /**
154      * Basic contructor
155      */
156 
157     //    public MoleculeFileCDO(JOEMol mol)
158     //    {
159     //      currentMolecule = mol;
160     //    }
161 
162     /*-------------------------------------------------------------------------*
163      * public variables
164      *------------------------------------------------------------------------- */
165     public void setMolecule(JOEMol mol)
166     {
167         currentMolecule = mol;
168     }
169 
170     /**
171      * Procedure required by the CDOInterface. This methodName is only
172      * supposed to be called by the JCFL library
173      *
174      * @param objectType     The new objectProperty value
175      * @param propertyType   The new objectProperty value
176      * @param propertyValue  The new objectProperty value
177      */
178     public void setObjectProperty(String objectType, String propertyType,
179         Object propertyValue)
180     {
181         if (logger.isDebugEnabled())
182         {
183             logger.debug("objectType: " + objectType);
184             logger.debug("propType: " + propertyType);
185             logger.debug("property: " + propertyValue);
186         }
187 
188         String stringValue = null;
189 
190         if (propertyValue instanceof String)
191         {
192             stringValue = (String) propertyValue;
193         }
194 
195         if (objectType.equals("Atom"))
196         {
197             Double dTmp;
198 
199             if (propertyType.equals("type"))
200             {
201                 currentAtom.setType(stringValue);
202                 currentAtom.setAtomicNum(JOEElementTable.instance()
203                                                         .getAtomicNum(stringValue));
204             }
205             else if (propertyType.equals("x2"))
206             {
207                 dTmp = new Double(stringValue);
208                 x_2D = dTmp.doubleValue();
209                 c2Dx.add(dTmp);
210             }
211             else if (propertyType.equals("y2"))
212             {
213                 dTmp = new Double(stringValue);
214                 y_2D = dTmp.doubleValue();
215                 c2Dy.add(dTmp);
216             }
217             else if (propertyType.equals("x3"))
218             {
219                 dTmp = new Double(stringValue);
220                 x_3D = dTmp.doubleValue();
221                 c3Dx.add(dTmp);
222             }
223             else if (propertyType.equals("y3"))
224             {
225                 dTmp = new Double(stringValue);
226                 y_3D = dTmp.doubleValue();
227                 c3Dy.add(dTmp);
228             }
229             else if (propertyType.equals("z3"))
230             {
231                 dTmp = new Double(stringValue);
232                 z_3D = dTmp.doubleValue();
233                 c3Dz.add(dTmp);
234             }
235             else if (propertyType.equals("formalCharge"))
236             {
237                 currentAtom.setFormalCharge(new Integer(stringValue).intValue());
238             }
239             else if (propertyType.equals("charge"))
240             {
241                 currentAtom.setPartialCharge(new Double(stringValue).doubleValue());
242             }
243             else if (propertyType.equals("hydrogenCount"))
244             {
245                 currentAtom.setImplicitValence(new Integer(stringValue).intValue());
246             }
247             else if (propertyType.equals("isotope"))
248             {
249                 //System.out.println("SET ISOTOPE: "+stringValue);
250                 currentAtom.setIsotope(new Integer(stringValue).intValue());
251             }
252             else if (propertyType.equals("id"))
253             {
254                 if (logger.isDebugEnabled())
255                 {
256                     logger.debug("id" + stringValue);
257                 }
258 
259                 atomEnumeration.put(stringValue, new Integer(numberOfAtoms));
260             }
261         }
262         else if (objectType.equals("Bond"))
263         {
264             //System.out.println(propertyType+"="+stringValue);
265             if (propertyType.equals("atom1"))
266             {
267                 bond_a1 = new Integer(stringValue).intValue() + 1;
268 
269                 //                System.out.println("atom1:"+bond_a1);
270             }
271             else if (propertyType.equals("atom2"))
272             {
273                 bond_a2 = new Integer(stringValue).intValue() + 1;
274             }
275             else if (propertyType.equals("order"))
276             {
277                 double BO = 1.0;
278                 bond_order = (int) BO;
279 
280                 //bond_order = new Integer(propertyValue).intValue();
281                 try
282                 {
283                     bond_order = (int) Double.parseDouble(stringValue);
284                 }
285                  catch (Exception e)
286                 {
287                     logger.error("Cannot convert to double: " + stringValue);
288                 }
289 
290                 if (BO == 1.5)
291                 {
292                     bond_order = 4;
293                 }
294 
295                 //System.out.println("CDO BO="+bond_order);
296             }
297             else if (propertyType.equals("stereo"))
298             {
299                 //System.out.println("Bond: stereo "+stringValue);
300                 bond_stereo = 0;
301                 bond_EZ = IsomerismDetection.EZ_ISOMERISM_UNDEFINED;
302 
303                 if (stringValue.equalsIgnoreCase("H"))
304                 {
305                     bond_stereo |= JOEBond.JOE_HASH_BOND;
306                 }
307                 else if (stringValue.equalsIgnoreCase("W"))
308                 {
309                     bond_stereo |= JOEBond.JOE_HASH_BOND;
310                 }
311                 else if (stringValue.equalsIgnoreCase("T"))
312                 {
313                     bond_EZ = IsomerismDetection.E_ISOMERISM;
314                 }
315                 else if (stringValue.equalsIgnoreCase("C"))
316                 {
317                     bond_EZ = IsomerismDetection.Z_ISOMERISM;
318                 }
319             }
320         }
321         else if (objectType.equals("scalar"))
322         {
323             if (propertyValue instanceof DoubleResult)
324             {
325                 DoubleResult dr;
326 
327                 //System.out.println(propertyType+"="+propertyValue);
328                 dr = (DoubleResult) propertyValue;
329 
330                 //      if (ir.value == null)
331                 //      {
332                 //        logger.error(
333                 //          "Double entry " + propertyType + "=" + propertyValue + " was not successfully parsed.");
334                 //      }
335                 //      else
336                 //      {
337                 JOEPairData dp = new JOEPairData();
338                 dp.setAttribute(propertyType);
339                 dp.setValue(dr);
340                 currentMolecule.addData(dp);
341 
342                 //      }
343             }
344             else if (propertyValue instanceof IntResult)
345             {
346                 IntResult ir;
347 
348                 //System.out.println(propertyType+"="+propertyValue);
349                 ir = (IntResult) propertyValue;
350 
351                 //      if (ir.value == null)
352                 //      {
353                 //        logger.error(
354                 //          "Integer entry " + propertyType + "=" + propertyValue + " was not successfully parsed.");
355                 //      }
356                 //      else
357                 //      {
358                 JOEPairData dp = new JOEPairData();
359                 dp.setAttribute(propertyType);
360                 dp.setValue(ir);
361                 currentMolecule.addData(dp);
362 
363                 //      }
364             }
365             else if (propertyValue instanceof StringResult)
366             {
367                 StringResult sr;
368 
369                 //System.out.println("SR:"+propertyType+"="+propertyValue);
370                 sr = (StringResult) propertyValue;
371 
372                 if (propertyType.length() != 0)
373                 {
374                     // use Hashtable to combine the String pieces
375                     if (currentMolecule.hasData(propertyType))
376                     {
377                         JOEGenericData genericData = currentMolecule.getData(propertyType,
378                                 false);
379                         JOEPairData pairData;
380 
381                         if (genericData.getDataType() == JOEDataType.JOE_PAIR_DATA)
382                         {
383                             pairData = (JOEPairData) genericData;
384 
385                             StringResult previous = (StringResult) pairData.getValue();
386                             StringBuffer sb = new StringBuffer(previous.value.length() +
387                                     100);
388                             sb.append(previous.value);
389                             sb.append(sr.value);
390                             previous.value = sb.toString();
391 
392                             //System.out.println(propertyType+"="+sb.toString());
393                         }
394                     }
395                     else
396                     {
397                         JOEPairData dp = new JOEPairData();
398                         dp.setAttribute(propertyType);
399                         dp.setValue(sr);
400                         currentMolecule.addData(dp);
401                         strings.put(propertyType, "");
402                     }
403                 }
404             }
405             else if (propertyValue instanceof BooleanResult)
406             {
407                 BooleanResult br;
408 
409                 //System.out.println(propertyType+"="+propertyValue);
410                 br = (BooleanResult) propertyValue;
411 
412                 //      if (ir.value == null)
413                 //      {
414                 //        logger.error(
415                 //          "Boolean entry " + propertyType + "=" + propertyValue + " was not successfully parsed.");
416                 //      }
417                 //      else
418                 //      {
419                 JOEPairData dp = new JOEPairData();
420                 dp.setAttribute(propertyType);
421                 dp.setValue(br);
422                 currentMolecule.addData(dp);
423 
424                 //      }
425             }
426         }
427         else if (objectType.equals("String"))
428         {
429             //System.out.println("propertyType:"+propertyType);
430             //System.out.println("stringValue:"+stringValue);
431             if (propertyType.length() != 0)
432             {
433                 // use Hashtable to combine the String pieces
434                 if (currentMolecule.hasData(propertyType))
435                 {
436                     JOEGenericData genericData = currentMolecule.getData(propertyType,
437                             false);
438                     JOEPairData pairData;
439 
440                     if (genericData.getDataType() == JOEDataType.JOE_PAIR_DATA)
441                     {
442                         pairData = (JOEPairData) genericData;
443 
444                         StringBuffer sb = (StringBuffer) pairData.getValue();
445                         sb.append(stringValue);
446 
447                         //System.out.println(propertyType+"="+sb.toString());
448                     }
449                 }
450                 else
451                 {
452                     JOEPairData dp = new JOEPairData();
453                     dp.setAttribute(propertyType);
454 
455                     // use StringBuffer instead of String to be more efficient
456                     // The StringBuffer will be replaced by String, when
457                     // Molecule-End-Tag occurs
458                     StringBuffer sb = new StringBuffer(200);
459                     sb.append(stringValue);
460                     dp.setValue(sb);
461                     currentMolecule.addData(dp);
462                 }
463 
464                 unparsed.put(propertyType, "");
465             }
466             else
467             {
468                 logger.error("No title defined for String entry: " +
469                     stringValue);
470             }
471         }
472         else if (objectType.equals("array"))
473         {
474             if (propertyValue instanceof DoubleArrayResult)
475             {
476                 DoubleArrayResult dar;
477                 dar = (DoubleArrayResult) propertyValue;
478 
479                 if (dar.getDoubleArray() == null)
480                 {
481                     logger.error("Double array entry " + propertyType + "=" +
482                         propertyValue + " was not successfully parsed.");
483                 }
484                 else
485                 {
486                     JOEPairData dp = new JOEPairData();
487                     dp.setAttribute(propertyType);
488                     dp.setValue(dar);
489                     currentMolecule.addData(dp);
490                 }
491             }
492             else if (propertyValue instanceof IntArrayResult)
493             {
494                 IntArrayResult iar;
495                 iar = (IntArrayResult) propertyValue;
496 
497                 if (iar.getIntArray() == null)
498                 {
499                     logger.error("Integer array entry " + propertyType + "=" +
500                         propertyValue + " was not successfully parsed.");
501                 }
502                 else
503                 {
504                     JOEPairData dp = new JOEPairData();
505                     dp.setAttribute(propertyType);
506                     dp.setValue(iar);
507                     currentMolecule.addData(dp);
508                 }
509             }
510             else if (propertyValue instanceof BitArrayResult)
511             {
512                 BitArrayResult bar;
513                 bar = (BitArrayResult) propertyValue;
514 
515                 if (bar.value == null)
516                 {
517                     logger.error("Boolean array entry " + propertyType + "=" +
518                         propertyValue + " was not successfully parsed.");
519                 }
520                 else
521                 {
522                     JOEPairData dp = new JOEPairData();
523                     dp.setAttribute(propertyType);
524                     dp.setValue(bar);
525                     currentMolecule.addData(dp);
526                 }
527             }
528         }
529         else if (objectType.equals("matrix"))
530         {
531             if (propertyValue instanceof DoubleMatrixResult)
532             {
533                 DoubleMatrixResult dmr;
534 
535                 //System.out.println(propertyValue.getClass().getName());
536                 dmr = (DoubleMatrixResult) propertyValue;
537 
538                 if (dmr.value == null)
539                 {
540                     logger.error("Float matrix entry " + propertyType + "=" +
541                         propertyValue + " was not successfully parsed.");
542                 }
543                 else
544                 {
545                     JOEPairData dp = new JOEPairData();
546                     dp.setAttribute(propertyType);
547                     dp.setValue(dmr);
548                     currentMolecule.addData(dp);
549                 }
550 
551                 //System.out.println("SDF"+dmr.toString(IOTypeHolder.instance().getIOType("SDF")));
552                 //System.out.println("CML"+dmr.toString(IOTypeHolder.instance().getIOType("CML")));
553             }
554             else if (propertyValue instanceof IntMatrixResult)
555             {
556                 IntMatrixResult dmr;
557 
558                 //System.out.println(propertyType+"="+propertyValue);
559                 dmr = (IntMatrixResult) propertyValue;
560 
561                 if (dmr.value == null)
562                 {
563                     logger.error("Integer matrix entry " + propertyType + "=" +
564                         propertyValue + " was not successfully parsed.");
565                 }
566                 else
567                 {
568                     JOEPairData dp = new JOEPairData();
569                     dp.setAttribute(propertyType);
570                     dp.setValue(dmr);
571                     currentMolecule.addData(dp);
572                 }
573             }
574 
575             //System.out.println("Set object:"+objectType+" pType:"+propertyType+" pValue:"+propertyValue);
576             if (logger.isDebugEnabled())
577             {
578                 System.out.println("Set object:" + objectType + " pType:" +
579                     propertyType + " pValue:" + propertyValue);
580             }
581         }
582         else if (objectType.equals("Molecule"))
583         {
584             if (propertyType.equals("title"))
585             {
586                 currentMolecule.setTitle((String) propertyValue);
587             }
588         }
589     }
590 
591     /**
592      * Procedure required by the CDOInterface. This methodName is only
593      * supposed to be called by the JCFL library
594      *
595      * @return   Description of the Return Value
596      */
597     public CDOAcceptedObjects acceptObjects()
598     {
599         CDOAcceptedObjects objects = new CDOAcceptedObjects();
600         objects.add("Molecule");
601         objects.add("Fragment");
602         objects.add("Atom");
603         objects.add("Bond");
604         objects.add("scalar");
605         objects.add("String");
606         objects.add("array");
607         objects.add("matrix");
608 
609         /*objects.add("Animation");
610         objects.add("Frame");
611         objects.add("Crystal");
612         objects.add("a-axis");
613         objects.add("b-axis");
614         objects.add("c-axis");
615         objects.add("SetOfReactions");
616         objects.add("Reactions");
617         objects.add("Reactant");
618         objects.add("Product");*/
619         return objects;
620     }
621 
622     /**
623      * Procedure required by the CDOInterface. This methodName is only
624      * supposed to be called by the JCFL library
625      */
626     public void endDocument()
627     {
628         if (logger.isDebugEnabled())
629         {
630             logger.debug("CML molecule added:" + currentMolecule);
631         }
632     }
633 
634     /**
635      * Procedure required by the CDOInterface. This methodName is only
636      * supposed to be called by the JCFL library
637      *
638      * @param objectType  Description of the Parameter
639      */
640     public void endObject(String objectType)
641     {
642         if (logger.isDebugEnabled())
643         {
644             logger.debug("END: " + objectType);
645         }
646 
647         if (objectType.equals("Molecule"))
648         {
649             currentMolecule.endModify();
650             currentMolecule.setOutputType(IOTypeHolder.instance().getIOType("SDF"));
651 
652             //System.out.println(""+currentMolecule.toString() );
653             if (logger.isDebugEnabled())
654             {
655                 logger.debug("Molecule added: \n" + currentMolecule.toString());
656             }
657 
658             if (currentMolecule.has2D())
659             {
660                 // are 3D coordinates also available ?
661                 // should never happen !!!!!!!!!
662                 if ((c3Dx.size() != 0) && (c3Dy.size() != 0) &&
663                         (c3Dz.size() != 0))
664                 {
665                     // o.k., available
666                     if ((c3Dx.size() != c3Dy.size()) &&
667                             (c3Dy.size() != c3Dz.size()))
668                     {
669                         logger.error("3D coordinats are inconsistent (x=" +
670                             c3Dx.size() + ",y=" + c3Dy.size() + ",z=" +
671                             c3Dz.size() + ").");
672                     }
673                     else
674                     {
675                         double[] c3DxArray = new double[c3Dx.size()];
676                         double[] c3DyArray = new double[c3Dy.size()];
677                         double[] c3DzArray = new double[c3Dz.size()];
678 
679                         for (int i = 0; i < c3DxArray.length; i++)
680                         {
681                             c3DxArray[i] = ((Double) c3Dx.get(i)).doubleValue();
682                             c3DyArray[i] = ((Double) c3Dy.get(i)).doubleValue();
683                             c3DzArray[i] = ((Double) c3Dz.get(i)).doubleValue();
684                         }
685 
686                         AtomDoubleResult adr = new AtomDoubleResult();
687                         adr.setDoubleArray(c3DxArray);
688 
689                         JOEPairData dp = new JOEPairData();
690                         dp.setAttribute("coordinates3Dx");
691                         dp.setValue(adr);
692                         currentMolecule.addData(dp);
693                         adr = new AtomDoubleResult();
694                         adr.setDoubleArray(c3DyArray);
695                         dp = new JOEPairData();
696                         dp.setAttribute("coordinates3Dy");
697                         dp.setValue(adr);
698                         currentMolecule.addData(dp);
699                         adr = new AtomDoubleResult();
700                         adr.setDoubleArray(c3DzArray);
701                         dp = new JOEPairData();
702                         dp.setAttribute("coordinates3Dy");
703                         dp.setValue(adr);
704                         currentMolecule.addData(dp);
705                     }
706                 }
707             }
708 
709             if (currentMolecule.has3D())
710             {
711                 // are 2D coordinates also available ?
712                 if ((c2Dx.size() != 0) && (c2Dy.size() != 0))
713                 {
714                     // o.k., available
715                     if (c2Dx.size() != c2Dy.size())
716                     {
717                         logger.error("2D coordinats are inconsistent (x=" +
718                             c3Dx.size() + ",y=" + c3Dy.size() + ").");
719                     }
720                     else
721                     {
722                         double[] c2DxArray = new double[c2Dx.size()];
723                         double[] c2DyArray = new double[c2Dy.size()];
724 
725                         for (int i = 0; i < c2DxArray.length; i++)
726                         {
727                             c2DxArray[i] = ((Double) c2Dx.get(i)).doubleValue();
728                             c2DyArray[i] = ((Double) c2Dy.get(i)).doubleValue();
729                         }
730 
731                         AtomDoubleResult adr = new AtomDoubleResult();
732                         adr.setDoubleArray(c2DxArray);
733 
734                         JOEPairData dp = new JOEPairData();
735                         dp.setAttribute("coordinates2Dx");
736                         dp.setValue(adr);
737                         currentMolecule.addData(dp);
738                         adr = new AtomDoubleResult();
739                         adr.setDoubleArray(c2DyArray);
740                         dp = new JOEPairData();
741                         dp.setAttribute("coordinates2Dy");
742                         dp.setValue(adr);
743                         currentMolecule.addData(dp);
744                     }
745                 }
746             }
747 
748             // resolve cis/trans isomerism informations
749             BondInt bi = null;
750 
751             for (int i = 0; i < ezInformations.size(); i++)
752             {
753                 bi = (BondInt) ezInformations.get(i);
754 
755                 //System.out.println("Bond isomerism: "+bi.bond+" "+ bi.i);
756                 IsomerismDetection.setCisTransBond(bi.bond, bi.i);
757             }
758 
759             // try to parse string entries, to check format and
760             // enable correct storage functionality for other output
761             // formats
762             String tmpS;
763             JOEGenericData genericData;
764 
765             for (Enumeration e = unparsed.keys(); e.hasMoreElements();)
766             {
767                 tmpS = (String) e.nextElement();
768 
769                 // convert descriptor entry from StringBuffer to String
770                 genericData = currentMolecule.getData(tmpS, false);
771 
772                 JOEPairData pairData;
773 
774                 if (genericData.getDataType() == JOEDataType.JOE_PAIR_DATA)
775                 {
776                     pairData = (JOEPairData) genericData;
777 
778                     StringBuffer sb = (StringBuffer) pairData.getValue();
779                     pairData.setValue(sb.toString());
780 
781                     //System.out.println(pairData.getAttribute()+"="+sb.toString());
782                 }
783 
784                 // parse descriptor entry
785                 //System.out.println("Try parsing: "+currentMolecule.getData(tmpS, false));
786                 try
787                 {
788                     genericData = currentMolecule.getData(tmpS, true);
789                 }
790                  catch (Exception pe)
791                 {
792                     logger.error("Error in parsing '" + tmpS + "': " +
793                         currentMolecule.getData(tmpS, false));
794                     pe.printStackTrace();
795                 }
796             }
797 
798             for (Enumeration e = strings.keys(); e.hasMoreElements();)
799             {
800                 tmpS = (String) e.nextElement();
801 
802                 // parse descriptor entry
803                 //        System.out.println("Try parsing: "+currentMolecule.getData(tmpS, false));
804                 try
805                 {
806                     genericData = currentMolecule.getData(tmpS, true);
807 
808                     JOEPairData pairData;
809                     pairData = (JOEPairData) genericData;
810 
811                     //System.out.println(pairData.getValue().getClass().getName());
812                     //System.out.println("parsed: "+((DescResult)pairData.getValue()).toString(IOTypeHolder.instance().getIOType("SDF")));
813                 }
814                  catch (Exception pe)
815                 {
816                     logger.error("Error in parsing '" + tmpS + "': " +
817                         currentMolecule.getData(tmpS, false));
818                     pe.printStackTrace();
819                 }
820             }
821         }
822         else if (objectType.equals("Frame"))
823         {
824         }
825         else if (objectType.equals("Animation"))
826         {
827         }
828         else if (objectType.equals("Atom"))
829         {
830             if (!Double.isNaN(z_3D))
831             {
832                 currentAtom.setVector(x_3D, y_3D, z_3D);
833             }
834             else
835             {
836                 currentAtom.setVector(x_2D, y_2D, 0.0);
837             }
838 
839             //System.out.println("currentAtom:"+currentAtom.getIdx()+" "+currentAtom);
840             //currentMolecule.addAtom(currentAtom);
841         }
842         else if (objectType.equals("Bond"))
843         {
844             if (logger.isDebugEnabled())
845             {
846                 logger.debug("Bond: " + bond_a1 + ", " + bond_a2 + ", " +
847                     bond_order + ", " + bond_stereo);
848             }
849 
850             currentMolecule.addBond(bond_a1, bond_a2, bond_order, bond_stereo);
851 
852             //System.out.println("bond_a1:"+bond_a1+" bond_a2:"+bond_a2+" bond_order:"+bond_order+" "+bond_stereo);
853             if (bond_EZ != IsomerismDetection.EZ_ISOMERISM_UNDEFINED)
854             {
855                 JOEBond bond = currentMolecule.getBond(currentMolecule.numBonds() -
856                         1);
857                 ezInformations.add(new BondInt(bond, bond_EZ));
858             }
859         }
860     }
861 
862     // procedures required by CDOInterface
863 
864     /**
865      * Procedure required by the CDOInterface. This methodName is only
866      * supposed to be called by the JCFL library
867      */
868     public void startDocument()
869     {
870         if (logger.isDebugEnabled())
871         {
872             logger.debug("Start new CML document");
873         }
874     }
875 
876     /**
877      * Procedure required by the CDOInterface. This methodName is only
878      * supposed to be called by the JCFL library
879      *
880      * @param objectType  Description of the Parameter
881      */
882     public void startObject(String objectType)
883     {
884         if (logger.isDebugEnabled())
885         {
886             logger.debug("START:" + objectType);
887         }
888 
889         if (objectType.equals("Molecule"))
890         {
891             molIndex++;
892 
893             if (currentMolecule == null)
894             {
895                 logger.error(
896                     "No molecule initialized. Use setMolecule(JOEMol mol).");
897                 currentMolecule = new JOEMol();
898             }
899 
900             //          if(molIndex!=1)   currentMolecule = new JOEMol();
901             //currentMolecule = new JOEMol();
902             atomEnumeration.clear();
903             currentMolecule.beginModify();
904             x_2D = y_2D = x_3D = y_3D = z_3D = Double.NaN;
905         }
906         else if (objectType.equals("Atom"))
907         {
908             currentAtom = currentMolecule.newAtom();
909 
910             // set H atom
911             currentAtom.setAtomicNum(1);
912             currentAtom.setType(JOEElementTable.instance().getSymbol(1));
913 
914             if (logger.isDebugEnabled())
915             {
916                 logger.debug("Atom # " + numberOfAtoms);
917             }
918 
919             numberOfAtoms++;
920         }
921         else if (objectType.equals("Bond"))
922         {
923         }
924         else if (objectType.equals("Animation"))
925         {
926         }
927         else if (objectType.equals("Frame"))
928         {
929         }
930         else if (objectType.equals("Crystal"))
931         {
932         }
933     }
934 }
935 ///////////////////////////////////////////////////////////////////////////////
936 //  END OF FILE.
937 ///////////////////////////////////////////////////////////////////////////////