Closed hainm closed 8 years ago
can you try again, I made some fixes lately and just updated dist/ngl.js
got the same error with the newest commit: eda4864d1688c9d2eef93d16e0d9cb13414b44b1
just clean my cache and your commit works for me. I will double-check.
uhm, try again and still get the same error. Weird.
You can try this branch: https://github.com/arose/nglview/pull/396
In console, I can see the function 'superpose' code but keep getting 'ReferenceError: NGL is not defined'.
In the error, can you see the code that throws it originally?
var C = e.getView(new NGL.Selection(r + " and .CA"))
(saw from minimized code)
Thanks! Fixed a whole bunch of similar bugs 7d6d3c9e32b08c1d684e41eaec718f71ffbcddaf.
new error in here
Exception in Comm callback TypeError: Cannot read property 'getAtomSet' of undefined(…) TypeError: Cannot read property 'getAtomSet' of undefined
getAtomSet: function(t, i) {
e.Debug && Cu.time("StructureView.getAtomSet");
var r = this.structure.getAtomSet(t);
return !i && this.atomSet && (r = r.new_intersection(this.atomSet)),
e.Debug && Cu.timeEnd("StructureView.getAtomSet"),
r
},
This is odd, it suggests the StructureView has no parent structure?! Can you give some context. How are you calling this. Does the error only occurs with the superpose method?
Can you give some context. How are you calling this
superpose: function(cindex0, cindex1){
// superpose two components
var component0 = this.stage.compList[cindex0];
var component1 = this.stage.compList[cindex1];
component0.superpose(component1);
},
view._remote_call('superpose', target='Widget',
args=[0, 1])
Does the error only occurs with the superpose method?
Yes
This is the output from
c = this.stage.compList[0]
for (var i in c){
console.log(i)
}
name
uuid
visible
signals
stage
viewer
reprList
structure
trajList
selection
structureView
defaultAssembly
constructor
type
initSelection
setSelection
setDefaultAssembly
rebuildRepresentations
rebuildTrajectories
addRepresentation
addTrajectory
removeTrajectory
dispose
centerView
getCenter
superpose
setVisibility
addBufferRepresentation
removeRepresentation
updateRepresentations
clearRepresentations
setStatus
setName
eachRepresentation
__getRepresentationComponent
very weird
If I wrote straight JS script, I can see the superposition. (Try to remove all cache to make sure I am using correct ngl.js file)
%%html
<script>
stage.setParameters({backgroundColor: 'white'})
stage.loadFile("./1crn.pdb", {defaultRepresentation: true})
stage.loadFile("./tz2.single.pdb", {defaultRepresentation: true})
</script>
%%html
<script>
var c0 = stage.compList[0];
var c1 = stage.compList[1];
</script>
%%html
<script>
console.log(stage.compList)
console.log(stage.compList[0])
c0.superpose(c1)
</script>
In JS script mode
NGL.superpose(c0, c1)
TypeError: Object #
BUT
c0.superpose(c1)
OK
LOL, weirder
If I specify
c1.superpose(c0)
: workc0.superpose(c1)
: got errorYou must make sure that both molecules actually have finished loading, looking at your code, this could be the problem.
I only hit enter to run my code if I saw two structures.
NGL.superpose(c0, c1)
that is not supposed to work, NGL.superpose expects Structure or StructureView objects.
c0.superpose(c1): got error
this should definitely work
I just did a new install from this repo and the following works for me:
import nglview
view = nglview.show_pdbid("3pqr") # load "3pqr" from RCSB PDB and display viewer widget
view
view.add_structure(nglview.PdbIdStructure("1gzm"))
view._remote_call('superpose', target='Widget', args=[0, 1])
indeed. cache is evil. thanks.
I am glad it is resolved, I was out of ideas. :-)
(I am using code from ngl dev, just pulled)
In console, I can see the function 'superpose' code but keep getting 'ReferenceError: NGL is not defined'.
Any idea how to fix it? thanks.