Problem with Molfile format in JChem

User dfeb81947d

16-03-2010 16:24:48

Dear support,


I tried an old molecule sketcher that some customers use sometimes. I used to work with the example below until recently. Unfortunatly I can't say with which version it started to fail but with the current version it failed (see code below).


The sketcher is JME from Peter Ert,l Novartis: http://www.molinspiration.com/jme/


When I get the molfile generated by his applet I get the following StackTrace:


chemaxon.formats.MolFormatException: Cannot recognize format (?)
Unrecognized file contents:
JME 2002.05 Tue Mar 02 16:41:45 CET 2010

 18 19                            V2000
    4.6662   -8.3962    0.0000 C                               
    3.4157   -6.3154    0.0000 C                               
    8.2377   -4.8348    0.0000 O           ...
...
    at chemaxon.formats.recognizer.RecognitionSubsystem.getFormat(RecognitionSubsystem.java:203)
    at chemaxon.formats.MolInputStream.initTextFormat(MolInputStream.java:235)
    at chemaxon.formats.MolInputStream.init(MolInputStream.java:134)
    at chemaxon.formats.MolInputStream.<init>(MolInputStream.java:116)
    at chemaxon.formats.MolInputStream.<init>(MolInputStream.java:58)
    at chemaxon.util.MolHandler.importMol(MolHandler.java:652)
    at chemaxon.util.MolHandler.setMolecule(MolHandler.java:146)
    at chemaxon.jchem.db.JChemSearch.readQuery(JChemSearch.java:3314)
    at chemaxon.jchem.db.JChemSearch.search(JChemSearch.java:2192)
    at chemaxon.jchem.db.JChemSearch.setRunning(JChemSearch.java:2037)
    at chemaxon.jchem.db.JChemSearch.run(JChemSearch.java:2064)
    at com.aurtools.test.TestSSSearch.main(TestSSSearch.java:81)

Here is my test code (it works if I change the molfile with a smiles)


import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

import chemaxon.jchem.VersionInfo;
import chemaxon.jchem.db.JChemSearch;
import chemaxon.sss.SearchConstants;
import chemaxon.sss.search.JChemSearchOptions;
import chemaxon.util.ConnectionHandler;

public class TestSSSearch {

    public static void main(String[] args) {
        System.out.println(VersionInfo.JCHEM_VERSION);
        String molfile = "JME 2002.05 Tue Mar 02 16:41:45 CET 2010\n"+
        "\n"+
        " 18 19                            V2000\n"+
        "    4.6662   -8.3962    0.0000 C                               \n"+
        "    3.4157   -6.3154    0.0000 C                               \n"+
        "    8.2377   -4.8348    0.0000 O                               \n"+
        "   13.1697   -8.9465    0.0000 C                               \n"+
        "   14.7704   -4.6047    0.0000 C                               \n"+
        "   11.9392   -8.2662    0.0000 C                               \n"+
        "   14.3702   -8.2262    0.0000 C                               \n"+
        "   13.3798   -4.7747    0.0000 C                               \n"+
        "    7.0672   -6.9556    0.0000 C                               \n"+
        "    9.4882   -6.9156    0.0000 C                               \n"+
        "    5.8367   -6.2754    0.0000 N                               \n"+
        "   15.3606   -5.8752    0.0000 N                               \n"+
        "   10.6887   -6.1953    0.0000 O                               \n"+
        "   11.9192   -6.8656    0.0000 C                               \n"+
        "   14.3402   -6.8256    0.0000 C                               \n"+
        "   13.1197   -6.1453    0.0000 C                               \n"+
        "    4.6362   -6.9957    0.0000 C                               \n"+
        "    8.2677   -6.2353    0.0000 C                               \n"+
        "  1 17  1  0         \n"+
        "  2 17  1  0         \n"+
        "  3 18  1  0         \n"+
        "  4  6  2  0         \n"+
        "  4  7  1  0         \n"+
        "  5  8  2  0         \n"+
        "  5 12  1  0         \n"+
        "  6 14  1  0         \n"+
        "  7 15  2  0         \n"+
        "  8 16  1  0         \n"+
        "  9 11  1  0         \n"+
        "  9 18  1  0         \n"+
        " 10 13  1  0         \n"+
        " 10 18  1  0         \n"+
        " 11 17  1  0         \n"+
        " 12 15  1  0         \n"+
        " 13 14  1  0         \n"+
        " 14 16  2  0         \n"+
        " 15 16  1  0         \n"+
        "M  END";
        try {
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
            /** connexion avec la base Oracle*/
            Properties props = new Properties();
            props.put("user", "scott");
            props.put("password", "tiger");
            props.put("SetBigStringTryClob", "true");
            Connection contact = DriverManager.getConnection ("jdbc:oracle:thin:@heman:1521:db1", props);
            contact.setAutoCommit(false);
            JChemSearchOptions searchOptions = new JChemSearchOptions();
            searchOptions.setSearchType(SearchConstants.SUBSTRUCTURE);
            searchOptions.setStereoSearchType(SearchConstants.STEREO_EXACT);
            searchOptions.setMaxResultCount(0);
            JChemSearch searcher = new JChemSearch();
            ConnectionHandler ch = new ConnectionHandler();
            ch.setConnection(contact);
            searcher.setConnectionHandler(ch);
            searcher.setStructureTable("JCHEM_CSMOL_TABLE");
            searcher.setResultTableMode(JChemSearch.NO_RESULT_TABLE);
            searcher.setInfoToStdError(true);
            searcher.setRunMode(JChemSearch.RUN_MODE_SYNCH_COMPLETE);
            searcher.setQueryStructure(molfile);
            searcher.setSearchOptions(searchOptions);
            searcher.run();
            System.out.println("Number of results: "+searcher.getResults().length);
            ch.close();
            contact.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

If I use the webpage: http://www.molinspiration.com/jme/doc/jme_ex1.htm to generate a molfile I have the following Exception


chemaxon.formats.MolFormatException: Invalid energy specification in molfile header: "T 2010"
    at chemaxon.marvin.io.formats.mdl.MolImport.readHeader(MolImport.java:707)
    at chemaxon.marvin.io.formats.mdl.MolImport.readMol0(MolImport.java:638)
    at chemaxon.marvin.io.formats.mdl.MolImport.readMol(MolImport.java:294)
    at chemaxon.marvin.io.MRecordImporter.readMol(MRecordImporter.java:335)
    at chemaxon.marvin.io.MRecordImporter.readMol(MRecordImporter.java:301)
    at chemaxon.marvin.io.MRecordImporter.readMol(MRecordImporter.java:187)
    at chemaxon.formats.MolImporter.readMol(MolImporter.java:770)
    at chemaxon.formats.MolImporter.read(MolImporter.java:661)
    at chemaxon.formats.MolImporter.read(MolImporter.java:631)
    at chemaxon.util.MolHandler.importMol(MolHandler.java:655)
    at chemaxon.util.MolHandler.setMolecule(MolHandler.java:146)
    at chemaxon.jchem.db.JChemSearch.readQuery(JChemSearch.java:3314)
    at chemaxon.jchem.db.JChemSearch.search(JChemSearch.java:2192)
    at chemaxon.jchem.db.JChemSearch.setRunning(JChemSearch.java:2037)
    at chemaxon.jchem.db.JChemSearch.run(JChemSearch.java:2064)

Molfile is


c1ccccc1
JME 2004.10 Tue Mar 16 17:09:17 CET 2010

  6  6  0  0  0  0  0  0  0  0999 V2000
    0.0000    2.1000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.7000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.2124    2.8000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.2124    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.4249    2.1000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.4249    0.7000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  2  0  0  0  0
  1  3  1  0  0  0  0
  2  4  1  0  0  0  0
  3  5  2  0  0  0  0
  4  6  2  0  0  0  0
  5  6  1  0  0  0  0
M  END

In that case the molfile header has the wrong number of line. But If I remove the first line or the second, I come back to the first problem.


I can't see where the problem could be, since it used to work with older version of JChem (at least before 5.2).


If you can drive me to an explanation it would be great.


Thank you in advance for your help.


Best Regards,


Jack

User dfeb81947d

17-03-2010 08:58:33

I understood where the problem is.


In the first example, a line is missing in the header of the molecule.


In the second example, the line



JME 2004.10 Tue Mar 16 17:09:17 CET 2010


is wrong since "CET" is interpreted as a measure of energy.


To make it work I just need to replace this line with a blank line.


 


But I wonder why it used to work with ancient version of JChem?


 


Apologies for any inconveniences and sorry if I have troubled you with such a basic problem...

ChemAxon a3d59b832c

17-03-2010 11:40:30

Dear Jacques,


 


This seems to be a problem with our mol import module. I will ask our local expert to have a look.


 


Thanks,


Szabolcs

ChemAxon 5433b8e56b

17-03-2010 14:30:32

Hi Jacques,


regarding to the CT file specification the second line in a molfile has to be in the following format:


IIPPPPPPPPMMDDYYHHmmddSSssssssssssEEEEEEEEEEEERRRRRR


User's first and last initials (l), program name (P), date/time (M/D/Y,H:m), dimensional codes (d), scaling factors (S, s), energy (E) if modeling program input, internal registry number (R) if input through MDL form.
A blank line can be substituted for line 2.
If the internal registry number is more than 6 digits long, it is stored in an M REG line (described in Chapter 3).


the line in the JME output is failing this specification, because the date/time field inserted to the output of JME in wrong format.


Before Marvin 5.1.3 the energy field was not imported by Marvin, since then we import the energy field, the JME header import is failing, because we are waiting for a valid number in the energy field.


I hope this information is useful for you.


Best regards,
Istvan

ChemAxon 5433b8e56b

17-03-2010 17:43:48

Hi Jacques,


we have discussed your issue with my collagues, and decided to change the behavior, from the next patch release which will be the 5.3.2 version of Marvin. After that the importer should not fail, and will simply ignore the wrong energy values.


Best regards,
Istvan

User dfeb81947d

19-03-2010 10:16:25

Thank you very much, it totally clear to me. It confirms what I thought.


Thank you very much for your help. It helps a lot.


 


Best Regards


Jacques