hydrogenize() bug

User 870ab5b546

09-04-2007 02:52:20

This code:





Code:
        println("ChemUtils.addImplicitH: starting with \n"


                + mol.toFormat("mrv"));


        mol.hydrogenize(true); // modifies the given molecule


        println("ChemUtils.addImplicitH: mol.hydrogenize(true) returned \n"


                + mol.toFormat("mrv"));








gives this output:





Code:
ChemUtils.addImplicitH: starting with


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="2" />


        <bond atomRefs2="a11 a15" order="1" />


        <bond atomRefs2="a11 a16" order="2" />


        <bond atomRefs2="a16 a17" order="1" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





ChemUtils.addImplicitH: mol.hydrogenize(true) returned


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C H H H H H H H H H H H"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783 -19.298124313354492 -21.965462995451006 -19.298124313354492 -15.503427387322377 -16.630785631042798 -13.963427387601907 -11.29608870550539 -8.412573027628413 -22.735472776230782 -21.195472776230783 -23.299151898058817"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325 5.005033833434365 0.3849660711982036 -1.1550339288017968 3.465004491417808 1.9249660710739673 -1.1550339288017968 3.4650338334343633 0.10986631568256344 2.1313377710472903 4.79869601470336 4.235016892875326"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a11 a15" order="1" />


        <bond atomRefs2="a11 a16" order="2" />


        <bond atomRefs2="a16 a17" order="1" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a1 a24" order="1" />


        <bond atomRefs2="a3 a25" order="1" />


        <bond atomRefs2="a4 a26" order="1" />


        <bond atomRefs2="a11 a27" order="1" />


        <bond atomRefs2="a12 a28" order="1" />


        <bond atomRefs2="a13 a29" order="1" />


        <bond atomRefs2="a15 a30" order="1" />


        <bond atomRefs2="a21 a31" order="1" />


        <bond atomRefs2="a23 a32" order="1" />


        <bond atomRefs2="a23 a33" order="1" />


        <bond atomRefs2="a23 a34" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>








Note the addition of two H atoms to atoms that should not gain additional H atoms.





It looks like the method is confused by the presence of pentavalent N atoms. Yet Marvin is usually OK with them.

User 870ab5b546

09-04-2007 03:18:26

Here's one more piece of information: The following behavior is proper, but the starting compound also has pentavalent N. So now it's not clear to me at all why the previous structure gave a bad result but this one doesn't.








Code:
ChemUtils.addImplicitH: starting with


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a11 a15" order="2" />


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a14 a20" order="2" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a20 a21" order="1" />


        <bond atomRefs2="a20 a22" order="2" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





ChemUtils.addImplicitH: mol.hydrogenize(true) returned


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C H H H H H H H H H"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783 -19.298124313354492 -21.965462995451006 -19.298124313354492 -16.630785631042798 -13.963427387601907 -11.29608870550539 -22.735472776230782 -21.195472776230783 -23.299151898058817"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325 5.005033833434365 0.3849660711982036 -1.1550339288017968 1.9249660710739673 -1.1550339288017968 3.4650338334343633 2.1313377710472903 4.79869601470336 4.235016892875326"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a11 a15" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a14 a20" order="2" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a20 a21" order="1" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a1 a24" order="1" />


        <bond atomRefs2="a3 a25" order="1" />


        <bond atomRefs2="a4 a26" order="1" />


        <bond atomRefs2="a12 a27" order="1" />


        <bond atomRefs2="a13 a28" order="1" />


        <bond atomRefs2="a15 a29" order="1" />


        <bond atomRefs2="a23 a30" order="1" />


        <bond atomRefs2="a23 a31" order="1" />


        <bond atomRefs2="a23 a32" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>








Here's another structure that behaves badly, similar to the first one:





Code:
ChemUtils.addImplicitH: starting with


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="1" />


        <bond atomRefs2="a13 a14" order="2" />


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a11 a15" order="2" />


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





ChemUtils.addImplicitH: mol.hydrogenize(true) returned


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C H H H H H H H H H H H"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783 -19.298124313354492 -21.965462995451006 -19.298124313354492 -16.630785631042798 -13.963427387601907 -11.29608870550539 -11.296069143945836 -8.412573027628413 -22.735472776230782 -21.195472776230783 -23.299151898058817"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325 5.005033833434365 0.3849660711982036 -1.1550339288017968 1.9249660710739673 -1.1550339288017968 3.4650338334343633 5.005033833434364 0.10986631568256344 2.1313377710472903 4.79869601470336 4.235016892875326"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="1" />


        <bond atomRefs2="a13 a14" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a11 a15" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a1 a24" order="1" />


        <bond atomRefs2="a3 a25" order="1" />


        <bond atomRefs2="a4 a26" order="1" />


        <bond atomRefs2="a12 a27" order="1" />


        <bond atomRefs2="a13 a28" order="1" />


        <bond atomRefs2="a15 a29" order="1" />


        <bond atomRefs2="a17 a30" order="1" />


        <bond atomRefs2="a21 a31" order="1" />


        <bond atomRefs2="a23 a32" order="1" />


        <bond atomRefs2="a23 a33" order="1" />


        <bond atomRefs2="a23 a34" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>


ChemAxon 25dcd765a3

10-04-2007 09:13:54

Dear Bob,





I cannot reproduce the bug.


I have tried the latest Marvin 4.1.6. version, with the following simple code:





Code:
public class Test {


    public static void main(String[] args) throws Exception {


   


        String s = (String)args[0];


        InputStream is = new BufferedInputStream( new FileInputStream( args[ 0 ]


 ) );


        MolImporter molimp = new MolImporter( new MolInputStream( is ) );





      Molecule mol = new Molecule();


      molimp.read(mol);


      mol.hydrogenize(true); // modifies the given molecule


      System.out.print(mol.toFormat("mrv"));


     


    }


}








Which Marvin version are you using?








Andras

User 870ab5b546

11-04-2007 02:25:17

JChem 3.2.3, Marvin 4.1.6.





I don't know what your MolImporter.read() method does to the input molecule. Perhaps you should print out the molecule's MRV code immediately before you hydrogenize as well as immediately afterward.





(And also, I don't understand your code. The API says that MolImporter.read(Molecule) returns a boolean, but you have it as a void method. And why is mol a parameter for read() when the value of mol has not yet been set?)

ChemAxon 25dcd765a3

12-04-2007 19:28:37

I still cannot reproduce the problem.





Some more comment on the code:





Code:



public class Test {


    public static void main(String[] args) throws Exception {


   


        String s = (String)args[0]; // the first argument must be a molecule file name


        InputStream is = new BufferedInputStream( new FileInputStream( args[ 0 ] ) );  // create a new imputstream for the file


        MolImporter molimp = new MolImporter( new MolInputStream( is ) ); // molecules will be imported from this stream





      Molecule mol = new Molecule();  // create a  new empty molecule


      molimp.read(mol); // read the first molecule from the file and fill the previously created empty mol molecule with atoms and bonds


      // return value not checked I suspect that the filename is correct and contains at least one molecule


       System.out.println("before ");


      System.out.println(mol.toFormat("mrv"));


      mol.hydrogenize(true); // modifies the given molecule


      System.out.println("after ");


      System.out.println(mol.toFormat("mrv"));     


    }


}






I have done the following


java Test bob.mrv





the output is also attached...

User 870ab5b546

12-04-2007 21:15:43

The molecule in bob.mrv is the one that works properly, not one of the two that don't. Please try again with these two compounds:





Code:
<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="2" />


        <bond atomRefs2="a11 a15" order="1" />


        <bond atomRefs2="a11 a16" order="2" />


        <bond atomRefs2="a16 a17" order="1" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>








and





Code:
<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="1" />


        <bond atomRefs2="a13 a14" order="2" />


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a11 a15" order="2" />


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>


ChemAxon 25dcd765a3

14-04-2007 19:47:50

With the new molecules I got the following result:


java Test bob1.mrv > out1.mrv


java Test bob2.mrv > out2.mrv





(I have commented out some printout lines in Test.java and kept the last one.)





Still without any problem with 4.1.6.





Have you tested this molecules with Test.java?


What is your result?

User 870ab5b546

14-04-2007 21:23:11

When I enter





java Test bob1.mrv





on two different computers (one Mac, one Linux), I get this message:





Exception in thread "main" java.lang.NoClassDefFoundError: Test





What should I do?





-- Bob





P.S. Your documentation for Molimporter.read(Molecule) says,
Quote:
read





public boolean read(Molecule mol)


throws java.io.IOException


Read the next molecule. All the nodes, edges, and properties are removed from mol before reading.





Parameters:


mol - target molecule object
From this information, it is not clear that the MolImporter object is read, and the output is placed in mol. I suggest you modify the documentation to make this point more clear.

User 870ab5b546

14-04-2007 22:52:03

OK, now I'm really confused. I wrote my own jsp page that calls the same method, ChemUtils.addImplicitH(), that was causing the problem before. So, here are two examples of the log output from ChemUtils.addImplicitH().





Called from my new jsp page, no bad behavior:





Code:
ChemUtils.addImplicitH: starting with


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="2" />


        <bond atomRefs2="a11 a15" order="1" />


        <bond atomRefs2="a11 a16" order="2" />


        <bond atomRefs2="a16 a17" order="1" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





ChemUtils.addImplicitH: mol.hydrogenize(true) returned


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C H H H H H H H H H"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783 -19.298124313354492 -21.965462995451006 -19.298124313354492 -16.630785631042798 -13.963427387601907 -11.29608870550539 -22.735472776230782 -21.195472776230783 -23.299151898058817"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325 5.005033833434365 0.3849660711982036 -1.1550339288017968 1.9249660710739673 -1.1550339288017968 3.4650338334343633 2.1313377710472903 4.79869601470336 4.235016892875326"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a11 a15" order="1" />


        <bond atomRefs2="a11 a16" order="2" />


        <bond atomRefs2="a16 a17" order="1" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a1 a24" order="1" />


        <bond atomRefs2="a3 a25" order="1" />


        <bond atomRefs2="a4 a26" order="1" />


        <bond atomRefs2="a12 a27" order="1" />


        <bond atomRefs2="a13 a28" order="1" />


        <bond atomRefs2="a15 a29" order="1" />


        <bond atomRefs2="a23 a30" order="1" />


        <bond atomRefs2="a23 a31" order="1" />


        <bond atomRefs2="a23 a32" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>






Called via ACE, bad behavior:





Code:
ChemUtils.addImplicitH: starting with


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="2" />


        <bond atomRefs2="a11 a15" order="1" />


        <bond atomRefs2="a11 a16" order="2" />


        <bond atomRefs2="a16 a17" order="1" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





ChemUtils.addImplicitH: mol.hydrogenize(true) returned


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C H H H H H H H H H H H"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783 -19.298124313354492 -21.965462995451006 -19.298124313354492 -15.503427387322377 -16.630785631042798 -13.963427387601907 -11.29608870550539 -8.412573027628413 -22.735472776230782 -21.195472776230783 -23.299151898058817"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325 5.005033833434365 0.3849660711982036 -1.1550339288017968 3.465004491417808 1.9249660710739673 -1.1550339288017968 3.4650338334343633 0.10986631568256344 2.1313377710472903 4.79869601470336 4.235016892875326"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="2" />


        <bond atomRefs2="a13 a14" order="1" />


        <bond atomRefs2="a14 a15" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a11 a15" order="1" />


        <bond atomRefs2="a11 a16" order="2" />


        <bond atomRefs2="a16 a17" order="1" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a1 a24" order="1" />


        <bond atomRefs2="a3 a25" order="1" />


        <bond atomRefs2="a4 a26" order="1" />


        <bond atomRefs2="a11 a27" order="1" />


        <bond atomRefs2="a12 a28" order="1" />


        <bond atomRefs2="a13 a29" order="1" />


        <bond atomRefs2="a15 a30" order="1" />


        <bond atomRefs2="a21 a31" order="1" />


        <bond atomRefs2="a23 a32" order="1" />


        <bond atomRefs2="a23 a33" order="1" />


        <bond atomRefs2="a23 a34" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>






In both cases, addImplicitH(String) converts the String to a Molecule and passes it on to addImplicitH(Molecule), which clones the Molecule, then passes the clone on to addImplictHnoClone(). Here is the relevant code:





Code:
    public static String addImplicitH(String molStruct) {


        try {


            MolHandler mh = new MolHandler(molStruct); 


            // mh.addHydrogens();


            Molecule mol = mh.getMolecule();


            mol = addImplicitH(mol);


            return mol.toFormat("mrv");


        } catch (Exception e) {


            println("ChemUtils.addImplicitH: "


                    + "Not a recognized format; returning molStruct");


            return molStruct;


        }           


    } // addImplicitH(String)


               


    // copied from K Joiner's Mechanism.hydrogenizeNoSquigs()


    // needed to undo the damage of a bug in JChem


    public static Molecule addImplicitH(Molecule origMol) {


        Molecule mol = (Molecule) origMol.clone();


        return addImplicitHnoClone(mol);


    } // addImplicitH(Molecule)


           


    public static Molecule addImplicitHnoClone(Molecule mol) {


        int MOLBOND_WAVY = 24; // taken from MolFunctions.java


        int origNumBonds = mol.getBondCount();


        Molecule origMol = (Molecule) mol.clone();


        println("ChemUtils.addImplicitH: starting with \n"


                + mol.toFormat("mrv"));


        mol.hydrogenize(true); // modifies the given molecule


        println("ChemUtils.addImplicitH: mol.hydrogenize(true) returned \n"


                + mol.toFormat("mrv"));


        for (int bIndex = 0; bIndex<origNumBonds; bIndex++) {


            MolBond mb = (MolBond) mol.getEdge(bIndex);


            int type = mb.getType();


            MolBond origmb = (MolBond) origMol.getEdge(bIndex);


            int origType = origmb.getType();


            if (type != origType) {


                println("ChemUtils.addImplicitH: "


                        + "resetting a " + mb.getAtom1().getSymbol()


                        + "-" + mb.getAtom2().getSymbol()


                        + " bond from type " + type


                        + " back to original type " + origType);


                mb.setType(origType);


            } // if stereo has been changed by hydrogenizing   


        } // for each original bond in mol


        for (int bIndex = origNumBonds; bIndex<mol.getBondCount(); bIndex++) {


            MolBond mb = (MolBond) mol.getEdge(bIndex);


            int stereo = mb.getFlags() & MolBond.STEREO_MASK;


            if (stereo == MOLBOND_WAVY) {


                println("ChemUtils.addImplicitH: "


                        + "straightening a new wavy bond to H...");


                mb.setType(1);


            } // if the new bond (to H) is wavy


        } // for each new bond in mol


        return mol;


    } // addImplictHnoClone(Molecule)








I'm attaching hydrogenize.jsp so you can see what it does. Interestingly, the AJAX procedures, which require some processing of the MRV file delivered back to the jsp page, clean up the file so the excess H atoms don't reappear.





So, I can understand why you can't reproduce it with Test.java, because I can't reproduce it when the method is called from a different page, either. But I can definitely repeat it when I call it from ACE. But how could the provenance of the MRV affect it?





Note, BTW, that addImplicitH(String) uses MolHandler, not MolImporter, to convert String to Molecule. I don't know why, and I don't know whether there is a big difference between MolHandler and MolImporter. Can you explain?

ChemAxon 25dcd765a3

15-04-2007 06:45:38

So the attached hydrogenize.jsp will generate the problem?

User 870ab5b546

15-04-2007 13:16:21

No, addImplicitH(), whose code I have pasted above, sometimes generates the problem, and sometimes not. When ACE calls it, the problem is generated. When hydrogenize.jsp calls it, the problem is not generated. (There would be different xy coordinates in the MRV file when hydrogenize.jsp does the calling.)

ChemAxon 25dcd765a3

16-04-2007 20:07:56

So, could you please attach a code which definitely generates the problem.


If we can reproduce the problem we can work on the solution.

User 870ab5b546

16-04-2007 22:07:39

I would like to send you code that duplicates the hydrogenize() error, but our ACE code involves so many different files that I am afraid it would be impossible.





I think the easiest thing to do would be for you to look at our operating code and see if you see anything wrong.





Do you have a login into the ACE server? If you don't have a login, let me know off-forum and I will get you one.





If you do, the log file is /home/aceorg/tomcat5/logs/svn_log.`date +%Y-%m-%d`.txt . The source code can be found in /home/aceorg/aceorg/SVN-1.5/epoch-plugin/src/com/prenhall/epoch . In particular, the Web interface calls .../problem/Problem.evaluateResponse(), which calls .../answer/Evaluator. matchResponse(), which calls .../answer/impl/Is.isResponseMatching(), which calls .../chem/MolFunctions.normalize() and then .../answer/impl/Is.is(), which calls .../chem/MolFunctions.matchSigmaNetwork(), which calls .../chem/ChemUtils.addImplicitH().





To duplicate the error in the Web app, go to http://epoch.chem.uky.edu:9182/lite and log in as guest, pwd guest. Click on ACE Organic Demo Course and click on Question Bank. Enter 3428 in the text box and press Go. Press Preview at the bottom. In the new window, press Submit.





There seems to be no rhyme or reason to when the error is triggered and when not. Check out the log output below. The two input files look like exactly the same molecule, but one is hydrogenized properly and the other not. !!!





Code:
ChemUtils.addImplicitH: starting with


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298160000000003 -20.63170666666667 -20.63170666666667 -19.298160000000003 -17.964426666666668 -17.964426666666668 -16.630693333333337 -17.719706666666667 -15.860693333333336 -15.29714666666667 -13.963413333333335 -15.29714666666667 -13.963413333333335 -12.629680000000002 -12.629680000000002 -13.963413333333335 -12.629680000000002 -15.052426666666669 -16.47688 -11.296133333333335 -9.625466666666668 -11.296133333333335 -21.965440000000005"


          y2="3.465093333333334 2.695093333333334 1.154906666666667 0.38490666666666673 1.154906666666667 2.695093333333334 3.465093333333334 4.553920000000001 4.798640000000001 2.695093333333334 3.465093333333334 1.154906666666667 0.38490666666666673 1.154906666666667 2.695093333333334 5.005093333333334 5.775093333333334 6.093920000000002 0.7563733333333335 0.38490666666666673 1.0587733333333336 -1.1550933333333335 3.465093333333334"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a11 a15" order="2" />


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a12 a13" order="1" />


        <bond atomRefs2="a13 a14" order="2" />


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





ChemUtils.addImplicitH: mol.hydrogenize(true) returned


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C H H H H H H H H H"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298160000000003 -20.63170666666667 -20.63170666666667 -19.298160000000003 -17.964426666666668 -17.964426666666668 -16.630693333333337 -17.719706666666667 -15.860693333333336 -15.29714666666667 -13.963413333333335 -15.29714666666667 -13.963413333333335 -12.629680000000002 -12.629680000000002 -13.963413333333335 -12.629680000000002 -15.052426666666669 -16.47688 -11.296133333333335 -9.625466666666668 -11.296133333333335 -21.965440000000005 -19.298346666665296 -21.965271829483846 -19.298346666665296 -16.630893053438445 -13.963413333333335 -11.296068153294897 -22.735416526325974 -21.195463473674035 -23.29913267408463"


          y2="3.465093333333334 2.695093333333334 1.154906666666667 0.38490666666666673 1.154906666666667 2.695093333333334 3.465093333333334 4.553920000000001 4.798640000000001 2.695093333333334 3.465093333333334 1.154906666666667 0.38490666666666673 1.154906666666667 2.695093333333334 5.005093333333334 5.775093333333334 6.093920000000002 0.7563733333333335 0.38490666666666673 1.0587733333333336 -1.1550933333333335 3.465093333333334 5.005093322020203 0.38470931759280824 -1.1550933220202022 1.9247901486126269 -1.1550933333333333 3.4652098455104188 2.1314006592487114 4.798786007417957 4.235069859659305"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a11 a15" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a12 a13" order="1" />


        <bond atomRefs2="a13 a14" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a1 a24" order="1" />


        <bond atomRefs2="a3 a25" order="1" />


        <bond atomRefs2="a4 a26" order="1" />


        <bond atomRefs2="a12 a27" order="1" />


        <bond atomRefs2="a13 a28" order="1" />


        <bond atomRefs2="a15 a29" order="1" />


        <bond atomRefs2="a23 a30" order="1" />


        <bond atomRefs2="a23 a31" order="1" />


        <bond atomRefs2="a23 a32" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





ChemUtils.addImplicitH: starting with


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="1" />


        <bond atomRefs2="a13 a14" order="2" />


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a11 a15" order="2" />


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>





ChemUtils.addImplicitH: mol.hydrogenize(true) returned


<?xml version="1.0" ?>


<MDocument>


  <MChemicalStruct>


    <molecule molID="m1">


      <atomArray


          atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34"


          elementType="C C C C C C S O O C C C C C C N O O O N O O C H H H H H H H H H H H"


          formalCharge="0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"


          x2="-19.298124313354492 -20.63179365440275 -20.63179365440275 -19.298124313354492 -17.964454972306235 -17.964454972306235 -16.6307758504782 -17.719720293505485 -15.860775850478202 -15.297096728650166 -13.963427387601907 -15.297096728650166 -13.963427387601907 -12.629758046553649 -12.629758046553649 -13.963427387601907 -12.629748265773872 -15.052371830629191 -16.476929199821072 -11.296078924725613 -9.62552484104455 -11.296078924725613 -21.965472776230783 -19.298124313354492 -21.965462995451006 -19.298124313354492 -16.630785631042798 -13.963427387601907 -11.29608870550539 -11.296069143945836 -8.412573027628413 -22.735472776230782 -21.195472776230783 -23.299151898058817"


          y2="3.465033833434365 2.6950168928753246 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 3.4650168928753247 4.553961335902608 4.79869601470336 2.6950168928753246 3.465033833434365 1.1549830117572437 0.38496607119820325 1.1549830117572437 2.6950168928753246 5.005033833434365 5.775033833434365 6.093978276461648 0.7564016822993618 0.3849830117572438 1.0587329545367847 -1.1550169882427563 3.465016892875325 5.005033833434365 0.3849660711982036 -1.1550339288017968 1.9249660710739673 -1.1550339288017968 3.4650338334343633 5.005033833434364 0.10986631568256344 2.1313377710472903 4.79869601470336 4.235016892875326"


          />


      <bondArray>


        <bond atomRefs2="a1 a2" order="A" />


        <bond atomRefs2="a2 a3" order="A" />


        <bond atomRefs2="a3 a4" order="A" />


        <bond atomRefs2="a4 a5" order="A" />


        <bond atomRefs2="a5 a6" order="A" />


        <bond atomRefs2="a1 a6" order="A" />


        <bond atomRefs2="a6 a7" order="1" />


        <bond atomRefs2="a7 a8" order="2" />


        <bond atomRefs2="a7 a9" order="2" />


        <bond atomRefs2="a7 a10" order="1" />


        <bond atomRefs2="a11 a10" order="1" />


        <bond atomRefs2="a10 a12" order="1" />


        <bond atomRefs2="a12 a13" order="1" />


        <bond atomRefs2="a13 a14" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a14 a15" order="1" />


        <bond atomRefs2="a11 a15" order="2">


          <bondStereo>C</bondStereo>


        </bond>


        <bond atomRefs2="a11 a16" order="1" />


        <bond atomRefs2="a16 a17" order="2" />


        <bond atomRefs2="a16 a18" order="2" />


        <bond atomRefs2="a5 a19" order="1" />


        <bond atomRefs2="a19 a10" order="1" />


        <bond atomRefs2="a14 a20" order="1" />


        <bond atomRefs2="a20 a21" order="2" />


        <bond atomRefs2="a20 a22" order="2" />


        <bond atomRefs2="a2 a23" order="1" />


        <bond atomRefs2="a1 a24" order="1" />


        <bond atomRefs2="a3 a25" order="1" />


        <bond atomRefs2="a4 a26" order="1" />


        <bond atomRefs2="a12 a27" order="1" />


        <bond atomRefs2="a13 a28" order="1" />


        <bond atomRefs2="a15 a29" order="1" />


        <bond atomRefs2="a17 a30" order="1" />


        <bond atomRefs2="a21 a31" order="1" />


        <bond atomRefs2="a23 a32" order="1" />


        <bond atomRefs2="a23 a33" order="1" />


        <bond atomRefs2="a23 a34" order="1" />


      </bondArray>


    </molecule>


  </MChemicalStruct>


</MDocument>


User 870ab5b546

17-04-2007 01:32:05

Hooray! I figured it out. We do a standardization, converting all ylides X(+)-Y(-) into X=Y, as in a nitro group. After that, we need to do molecule.valenceCheck() to reset the implicit H counts. We were failing to do so.





Not sure why it failed sometimes and not other times, but doing the valenceCheck() every time solves the problem.

ChemAxon 25dcd765a3

17-04-2007 07:01:20

Great!