Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flat model crashes inchi.js #1

Open
BobHanson opened this issue Mar 9, 2016 · 13 comments
Open

flat model crashes inchi.js #1

BobHanson opened this issue Mar 9, 2016 · 13 comments

Comments

@BobHanson
Copy link

Entry of the (albeit inappropriately) flat 2D taxol structure found at NCI/CADD http://cactus.nci.nih.gov/chemical/structure/taxol/file?format=sdf&get3d=True crashes or in some way permanently disables inchi.js. This is observable at http://chemapps.stolaf.edu/jmol/jsmol/inchi.htm if you put "taxol" into the search box and then press [Search]. An inchi is created:

InChI=1S/C47H51NO14/c1-25-31(60-43(56)36(52)35(28-16-10-7-11-17-28)48-41(54)29-18-12-8-13-19-29)23-47(57)40(61-42(55)30-20-14-9-15-21-30)38-45(6,32(51)22-33-46(38,24-58-33)62-27(3)50)39(53)37(59-26(2)49)34(25)44(47,4)5/h7-21,31-33,35-38,40,51-52,57H,22-24H2,1-6H3,(H,48,54) Omitted undefined stereo

but then if any additional model -- morphine, for example -- is loaded, the error

TypeError: a is undefined

is thrown from then on.

@rapodaca
Copy link
Collaborator

rapodaca commented Mar 9, 2016

Using the online InChI.js test here:

http://metamolecular.com/inchi-js/

I'm not able to reproduce the problem you see. Does the same test work at the above link?

@BobHanson
Copy link
Author

You can't reproduce it at my site? It does not have the problem at your
site. For whatever reason.

On Wed, Mar 9, 2016 at 12:17 PM, Richard Apodaca [email protected]
wrote:

Using the online InChI.js test here:

http://metamolecular.com/inchi-js/

I'm not able to reproduce the problem you see. Does the same test work at
the above link?


Reply to this email directly or view it on GitHub
#1 (comment)
.

Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr

If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

@rapodaca
Copy link
Collaborator

rapodaca commented Mar 9, 2016

I did try on the site I linked, but not your site. If you're not seeing the error on:

http://metamolecular.com/inchi-js/

then chances are the issue lies on your site. One way to debug this would be to start with the test page, which is included in the inchi.js repository. Then add the JS dependencies you're using on your site, one by one (just add the script tags, don't activate the libraries). If that doesn't trigger the error, then the problem could be elsewhere.

@BobHanson
Copy link
Author

Yes, OK. I have tracked one problem down to Jmol, in that I see that
java2script hijacks Error(). Correcting that, I see now:

uncaught exception: abort() at Clazz.declareTypeError/f@j2s
/core/corejmol.z.js:1993:12
Ja@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:57:21
Ia@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:55:22
C@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:455:101
d.T._abort
@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:105:195
Kn@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:288:56470
Mn@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:288:69727
xk@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:110:16885
wk@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:110:13358
tg@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:287:30399
Uf@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:195:19770
$f@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:287:2973
_f@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:225:3
Sb@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:420:7
Eb@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:308:8
cb@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js:298:3
@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi/inchi.js line 39 >
eval:1:130
dotest@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi.htm:29:16
getInChI/<@file:///C:/jmol-dev/workspace/JSmol/site/jsmol/inchi.htm:13:26

On Wed, Mar 9, 2016 at 1:10 PM, Richard Apodaca [email protected]
wrote:

I did try on the site I linked, but not your site. If you're not seeing
the error on:

http://metamolecular.com/inchi-js/

then chances are the issue lies on your site. One way to debug this would
be to start with the test page, which is included in the inchi.js
repository. Then add the JS dependencies you're using on your site, one by
one (just add the script tags, don't activate the libraries). If that
doesn't trigger the error, then the problem could be elsewhere.


Reply to this email directly or view it on GitHub
#1 (comment)
.

Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr

If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

@BobHanson
Copy link
Author

BobHanson commented Mar 10, 2016 via email

@rapodaca
Copy link
Collaborator

That's odd - I can't seem to reproduce the error. Browsing to:

http://metamolecular.com/inchi-js/

I click the document button and paste the molfile from:

http://cactus.nci.nih.gov/chemical/structure/taxol/file?format=sdf&get3d=True

I repeated 10x in a row without error. Running Chrome 48.0.2564.116 on OSX. Also tried on Firefox 43.0.4 OSX without a problem.

If I get a chance, I can try this with your exact configuration. What version of Windows and browsers were you using?

@BobHanson
Copy link
Author

I just tried http://chemapps.stolaf.edu/jmol/jsmol/i.htm on my Mac using
Safari -- same issue exactly.
And my collaborator Otis Rotherberger has reported the same thing.

It looks to me to be some sort of memory caching issue.

Note that i.htm is a very clean file. Just:

<title>JSmol-InChI test</title> <script> InChI = { memoryInitializerPrefixURL: 'inchi/', onRuntimeInitialized: function () {InChI.fromMolfile = InChI.cwrap('get_inchi', 'string', ['string']);} }; function dotest(name) { var mol = document.body.innerHTML.split(name)[2].trim() document.getElementById("log").innerHTML=(Error().message) document.getElementById("inchi1div").innerHTML=("??????") var calc = InChI.fromMolfile(mol).trim() document.getElementById("inchi1div").innerHTML=(calc) } </script> <script async src="inchi/inchi.js"></script>

Bob

On Wed, Mar 9, 2016 at 6:21 PM, Richard Apodaca [email protected]
wrote:

That's odd - I can't seem to reproduce the error. Browsing to:

http://metamolecular.com/inchi-js/

I click the document button and past the molfile from:

http://cactus.nci.nih.gov/chemical/structure/taxol/file?format=sdf&get3d=True

I repeated 10x in a row without error. Running Chrome 48.0.2564.116 on
OSX. Also tried on Firefox 43.0.4 OSX without a problem.

If I get a chance, I can try this with your exact configuration. What
version of Windows and browsers were you using?


Reply to this email directly or view it on GitHub
#1 (comment)
.

Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr

If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

@rapodaca
Copy link
Collaborator

I just tried http://chemapps.stolaf.edu/jmol/jsmol/i.htm on my Mac using
Safari -- same issue exactly.

Just to be clear...

When you try the test I outlined in my previous message (using the page http://metamolecular.com/inchi-js/), what do you see?

I ask because it wasn't clear whether you're reporting results for your page or the one I linked to.

I looked at your HTML file and can see the issue you refer to. However, there are a few oddities, including the way you store/load the molfile via DOM element. Here's a cleaner test:

https://gist.github.com/rapodaca/4070c58b466ce285a200

Copy this file into a directory, then replace the parts on lines 19 and 23 with links to the inchi.js.mem and inchi.js file. You should be able to click the button repeatedly without a problem.

Comparison of the gist I posted with the HTML you're using will probably provide clues to what is triggering the problem.

@BobHanson
Copy link
Author

BobHanson commented Mar 10, 2016 via email

@rapodaca
Copy link
Collaborator

OK, that's it. So, for whatever reason, inchi.c crashes some odd time after
given a 2D file that has no stereochemical descriptors.

I don't follow. So far I haven't been able to reproduce your bug on a clean HTML file.

Did you run the demo I posted? If so, with which file and what was the outcome?

Actually, that's a very clean
way to do this - direct transfer of the file, none of this \n business.

If you're not in favor of JavaScript variables a cleaner way is to put the data into a script tag:

When used to include data blocks (as opposed to scripts), the data must be embedded inline, the format of the data must be given using the type attribute, the src attribute must not be specified, and the contents of the script element must conform to the requirements defined for the format used.

https://www.w3.org/TR/html5/scripting-1.html#the-script-element

Alternatively, you can load the file with an XMLHttpRequest object.

It's still not clear to me that the method in which you stored data in your demo wasn't the cause of the problem.

@BobHanson
Copy link
Author

On Thu, Mar 10, 2016 at 8:54 AM, Richard Apodaca [email protected]
wrote:

OK, that's it. So, for whatever reason, inchi.c crashes some odd time after
given a 2D file that has no stereochemical descriptors.

I don't follow. So far I haven't been able to reproduce your bug on a
clean HTML file.

Sorry - Everything is fine. What I am saying is that it is no concern to
you. My bad. I was using a 2D MOL file with no stereochemical descriptors,
and that is garbage. I was using that; you were not. So that is why the
problem occurred.

Did you run the demo I posted? If so, with which file and what was the
outcome?

Actually, that's a very clean
way to do this - direct transfer of the file, none of this \n business.

If you're not in favor of JavaScript variables a cleaner way is to put the
data into a script tag:

When used to include data blocks (as opposed to scripts), the data must be
embedded inline, the format of the data must be given using the type
attribute, the src attribute must not be specified, and the contents of the
script element must conform to the requirements defined for the format used.

https://www.w3.org/TR/html5/scripting-1.html#the-script-element

Alternatively, you can load the file with an XMLHttpRequest object.

I use all these methods all sorts of times. This was just so I could
quickly put this together as simply as possible.

It's still not clear to me that the method in which you stored data in
your demo wasn't the cause of the problem.

I can verify that it was not -- I have used this for years, and also when
I popped in the file from NCI, it works perfectly. Seriously, it works
fantastically. It is easy for a server to insert a file between two tags in
the HTML comment, and then just this tiny bit of JavaScript to pull it out.

Bob

@rapodaca
Copy link
Collaborator

My bad. I was using a 2D MOL file with no stereochemical descriptors,
and that is garbage.

Which molfile was that? I consider any indeterminate state to be a bug, regardless of whether the input is legal or not. I'd like to try the "2D MOL file with no stereochemical descriptors" you found in the test harness I linked to, to see that an error actually occurs, and hopefully, fix it.

@BobHanson
Copy link
Author

That's the one that is embedded in the HTML file:
http://chemapps.stolaf.edu/jmol/jsmol/i.htm

On Thu, Mar 10, 2016 at 9:23 AM, Richard Apodaca [email protected]
wrote:

My bad. I was using a 2D MOL file with no stereochemical descriptors,
and that is garbage.

Which molfile was that? I consider any indeterminate state to be a bug,
regardless of whether the input is legal or not. I'd like to try the "2D
MOL file with no stereochemical descriptors" you found in the test harness
I linked to, to see that an error actually occurs, and hopefully, fix it.


Reply to this email directly or view it on GitHub
#1 (comment)
.

Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr

If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants