MolFormatException- on Macintosh Firefox but not PC firefox

User 956e0ca334

25-01-2010 16:15:22

Hi there,


I hope you can give me some help on some mol file recognition.  I have put an applet on a page, where 'structureText' is a hidden field holding a structure that had been previously generated using marvin sketch. (Marvin applets version 5.1.3)  I try to reload inot the Marvin sketch.  This page works perfectly on IE or Firefox on a PC. But on a mac gives the following error message shown below saying it does not recognise the file format. 


The hidden value is read into marvin using your function    
     msketch_param("mol",local2unix(MarvinForm.structureText.value))


Rather implies   local2unix function is not working correctly on a Mac?


Could you tell me exactly how I should change the contents of this hidden field so I can get it to be recognized on both platforms.


Thanks


Megan


++++++++++++++++ERROR MESSAGE+++++++++++++++++++++++++++++++++


chemaxon.formats.MolFormatException: Cannot recognize format (?)
Unrecognized file contents:


  Marvin  01251015022D         



 10 11  0  0  0  0            999 V2000

...
    at chemaxon.formats.recognizer.RecognitionSubsystem.getFormat(Unknown Source)
    at chemaxon.formats.MolInputStream.b(Unknown Source)
    at chemaxon.formats.MolInputStream.a(Unknown Source)
    at chemaxon.formats.MolInputStream.<init>(Unknown Source)
    at chemaxon.marvin.util.MolLoader.a(Unknown Source)
    at chemaxon.marvin.util.MolLoader.run(Unknown Source)
    at chemaxon.marvin.common.swing.MolPanel.startLoader(Unknown Source)
    at chemaxon.marvin.sketch.swing.SketchPanel.molStart(Unknown Source)
    at chemaxon.marvin.common.swing.MolPanel.init(Unknown Source)
    at chemaxon.marvin.common.swing.MolPanel.init(Unknown Source)
    at JMSketch.a(Unknown Source)
    at JMSketch.a(Unknown Source)
    at JMSketch$1.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at jep.MySimpleEventQueue.dispatchEvent(MySimpleEventQueue.java:59)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


 


+++++++++++++++++++++++++++++++++++++++++


<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="util" uri="/WEB-INF/tfi-util.tld" %>
<%@taglib prefix="c" uri="/WEB-INF/c.tld" %>
<%@taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %>
<%@taglib prefix="tiles" uri="/WEB-INF/struts-tiles.tld" %>
<%@taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %>


<!-- find the product type by looking at the url -->
 <jsp:useBean id="productDeployment" class="com.tfi.deployment.ProductDeployment" scope="request" />


   <jsp:setProperty name="productDeployment"   property="platform"  value="<%= getServletConfig().getServletContext().getInitParameter(\"platform\") %>" />


<bean:define id="platform"><jsp:getProperty name="productDeployment" property="platform" /></bean:define>


<c:set var="chemAxonPath">
    <util:string name="${platform}.chemAxonPath"/>
</c:set>


<html>
    <head>
        

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Structure Sketch</title>
        <script type="text/javascript" language="JavaScript">
       
       function submitIfLoaded(whatToDo)
{


 MarvinForm.structureText.value = document.MSketch.getMol('mol');



 if(opener.document.MView != null) {
 
  var s = MarvinForm.structureText.value ;
                var opts=null;
                                //copy to the marvin view window so users can edit
  opener.document.MView.setMol(s, opts);


 opener.document.savePropertiesForm.structureText.value=s;

 } else {
  alert("Cannot import molecule:\n"+
        "no JavaScript to Java communication in your browser.\n");
 }



 }


  </script>



    </head>
    <body>
       
            <c:url value="/marvin.do" var="saveStructure">
                 <c:param name="id" value="${search.id}"/>
      <c:param name="method" value="saveStructure"/>
      </c:url>


 
           
<form id="MarvinForm" name="MarvinForm" method="POST" action="${saveStructure}" >


              <input type="hidden" name="structureText" value="
  Marvin  01251015022D


 10 11  0  0  0  0            999 V2000
   -1.4143   -0.2652    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.1287    0.1473    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.8433   -0.2652    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.8433   -1.0902    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.1287   -1.5027    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.4143   -1.0902    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6998   -1.5027    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    0.0147   -1.0902    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0147   -0.2652    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6998    0.1473    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  1  6  2  0  0  0  0
  1 10  1  0  0  0  0
  2  3  2  0  0  0  0
  3  4  1  0  0  0  0
  4  5  2  0  0  0  0
  5  6  1  0  0  0  0
  6  7  1  0  0  0  0
  7  8  2  0  0  0  0
  8  9  1  0  0  0  0
  9 10  2  0  0  0  0
M  END
"/>


    <input type="hidden" name="chemAxonPath" value="${chemAxonPath}"/>
   
      <script LANGUAGE="JavaScript1.1" SRC="${chemAxonPath}marvin/marvin.js"></script>
    <script LANGUAGE="JavaScript1.1">
    <!--
    function undo() {
        if(document.MSketch != null) {
            document.MSketch.undo();
        }
    }


    function redo() {
        if(document.MSketch != null) {
            document.MSketch.redo();
        }
    }



    
    
        
    msketch_name = "MSketch";

    msketch_begin(MarvinForm.chemAxonPath.value +'marvin', 540, 480);
   
     msketch_param("mol",local2unix(MarvinForm.structureText.value));
    msketch_end();
   


     //-->
   
       
</script>
<table cellspacing="10" border=0 cellpadding="2"><tr><td>
<a href="#" onClick="javascript:submitIfLoaded('');document.MarvinForm.submit();self.close();">


<img src="<c:url value='/common/images/GreenArrow.gif'/>" width="193" height="28" align="top" border="0"></a>
</td><td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Click here to add structure to search query </font>


</td></tr>


</table>
 



    </form>



      </body>
</html>


+++++++++++++++++++++++++++++++++++++++++++++++++++++++ i

ChemAxon 7c2d26e5cf

26-01-2010 14:21:12

Hi Megan,


I do not understand exactly your post.


Under Mac, first time the applet loads fine but after reloading of the page, the applet throws an exception that could not load the molecule.


If not, please give a detailed scenario how this error is invoked.


Please also give some information about your software environment (OS X version, java version, browser type).

User 956e0ca334

26-01-2010 15:37:29

Basically the MSketch is used to let the user draw a structure, which is written to a database.  When the jsp page is loaded again the strcuture string is held in a hidden field. called structureText.


 


This is an example of what is held in the hidden field is:


<input type="hidden" name="structureText" value="
  Marvin  01251015022D

 10 11  0  0  0  0            999 V2000
   -1.4143   -0.2652    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.1287    0.1473    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.8433   -0.2652    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.8433   -1.0902    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.1287   -1.5027    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.4143   -1.0902    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6998   -1.5027    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    0.0147   -1.0902    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0147   -0.2652    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6998    0.1473    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  1  6  2  0  0  0  0
  1 10  1  0  0  0  0
  2  3  2  0  0  0  0
  3  4  1  0  0  0  0
  4  5  2  0  0  0  0
  5  6  1  0  0  0  0
  6  7  1  0  0  0  0
  7  8  2  0  0  0  0
  8  9  1  0  0  0  0
  9 10  2  0  0  0  0
M  END
"/>


This string is loaded into marvin sketch using the following:


+++++++++++++++++++++++++++++++++++++++++++++++++



msketch_name = "MSketch";

    msketch_begin(MarvinForm.chemAxonPath.value +'marvin', 540, 480);
   
     msketch_param("mol",local2unix(MarvinForm.structureText.value));
    msketch_end();


+++++++++++++++++++++++++++++++++++++++++++++++++


I have ring 4 or 5 people with macs  to try on their versions of FIREFOX- all are getting exactly the same problem so it appears to be somethign to do with the local2unix function which is in Marvin which is not translating the text properly for the applet to read the file.  I need for this to work on a PC and  a mac could you please tell me what I should do to solve this problem.   I am ruunin Firefox 3.6 and OS10.  Don't know how to get java verion on a mac but seeing as these is repeatable across may users in different sites, thsi cannot be the issue!


If you would like to see my live test site youself , go to yyy.chemnetbase.com.  Click 'Draw Query' then draw  strucutre, click the green arrow to transfer on to the main page then click 'draw query' again and you will see it is trying to reload the structure into Marvin but will not load the string.  Please note this works fine on PC for the firefox and IE


It seem likely it is something to do with the local2unix function.


Regards


Megan

ChemAxon 7c2d26e5cf

26-01-2010 17:38:50

You are right, the problem may be in the implementation of the local2unix method in marvin.js.


function local2unix(s) {
    var strvalue = "" + s;
    var v = navigator.appVersion;
    if(v.indexOf("Win") > 0) {
        return strvalue.split("\r").join("");
    } else if(v.indexOf("Mac") > 0) { // Macintosh
        return strvalue.split("\r").join("\n");

    } else { // Unix
        return strvalue;
    }
}


Please remove condition for Mac (see bold highlighted code in the above block) in marvin.js. In contrary of ancient Mac OS versions, OS X behaves like Unix: use \n as EOL character.


After the modification of marvin.js, the local2unix method should looks like this:


function local2unix(s) {
    var strvalue = "" + s;
    var v = navigator.appVersion;
    if(v.indexOf("Win") > 0) {
        return strvalue.split("\r").join("");
    } else { // Unix
        return strvalue;
    }
}


Of course, the updated marvin.js will be available in the next release.

User 956e0ca334

27-01-2010 13:37:21

Thanks very much this appears to have worked.  I have been looking and it does not appear practical to identify OSX mac in all browse, so I take it we will have to say this system can only be OSX compatable?


Thanks again


M

ChemAxon 7c2d26e5cf

27-01-2010 22:39:04

Actually, in a browser, the identification of MS-Window system can be important, since certain Windows applications still use \r\n EOL characters that is not a cross-platform solution (\n).

User 956e0ca334

28-01-2010 11:10:47

Sorry did not make myself clear, I mean windows, unix and mac OSX but not earlier versions of the mac operating system!

ChemAxon 7c2d26e5cf

28-01-2010 17:22:29

Do you think it solved your problem?

User 956e0ca334

29-01-2010 09:02:18

yes thank you!