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

3Dmol.js Error: 'Cannot read properties of undefined (reading 'atom')' #743

Closed
zongyangdu opened this issue Jan 4, 2024 · 2 comments
Closed

Comments

@zongyangdu
Copy link

I encountered an error while trying to render a molecule using 3Dmol.js. The console reports the following error:

Uncaught TypeError: Cannot read properties of undefined (reading 'atom')
at drawCartoon (3Dmol.js:28726:50)
at Object.defaultDrawCartoon [as drawCartoon] (3Dmol.js:28916:9)
at createMolObj (3Dmol.js:31086:24)
at GLModel.globj (3Dmol.js:32219:26)
at GLViewer.render (3Dmol.js:34892:31)
at Object.success (RTH000035/:182:18)
at fire (3Dmol.js:3317:31)
at Object.fireWith [as resolveWith] (3Dmol.js:3447:7)
at done (3Dmol.js:9272:14)
at XMLHttpRequest. (3Dmol.js:9514:9)

And the pdb file is as follows:
model5.txt

@zongyangdu
Copy link
Author

Here is my code:

<script src="/style/jquery-3.2.1.js"></script> <script type="text/javascript" src="/style/3Dmol.js"></script>
<div style="position:relative;left:30px;">
<table>

<tr><td align="middle">  
<script>
  glviewer = $3Dmol.createViewer("pdb_div", {});
      $(document).ready(function(){
         $(function(){
            $.ajax(
	{
	  url: "model.pdb",
	  dataType: "text",
	  success: function(data)
	  {
	      glviewer.setBackgroundColor(0xf8f8f8);
	      glviewer.addModel(data, "pdb");
	      glviewer.setStyle({cartoon:{color:"spectrum"}})
	       glviewer.zoomTo();
	      glviewer.render();
	  }
	});
      });
   });
 </script><br>
 </div>

 </td>

dkoes added a commit that referenced this issue Jan 13, 2024
The cartoon code was assuming DNA backbone atoms would always have a
certain order.  Now can deal with a partial residue at start.
@dkoes
Copy link
Contributor

dkoes commented Jan 13, 2024

Thank you for the bug report. The above commit fixes the issue. The code was making assumptions about atom ordering. A regression test has been added:
https://3dmol.org/tests/auto/generate_test.cgi?test=testdnacartoon

@dkoes dkoes closed this as completed Jul 31, 2024
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