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

Load topology and trajectory files in viewer? #547

Closed
MayurDange15 opened this issue Dec 20, 2021 · 6 comments
Closed

Load topology and trajectory files in viewer? #547

MayurDange15 opened this issue Dec 20, 2021 · 6 comments

Comments

@MayurDange15
Copy link

Hello 3Dmol.js team, I'm facing some issues. How to load multiple file types into a single viewer instance?

For e.g.
$(function() {
let element = $('#canvas');
let config = {backgroundColor: 'black'};
let viewer = $3Dmol.createViewer(element, config);
let topologyUri = topology.pdb;
let trajectoryUri = trajectory.netcdf;

jQuery.ajax(topologyUri, trajectoryUri, {
success: function(data) {
let v = viewer;
let m = v.addModel(); /* load data /
m.AddAtoms([topologyUri, "pdb"])
v.setStyle({}, {cartoon: {color: 'spectrum'}}); / style all atoms /
m.setCoordinates(trajectoryUri, 'netcdf')
v.zoomTo(); / set camera /
v.animate({loop: "forward", reps: 1});
v.render(); / Want to show both files in the same viewer render scene /
v.zoom(1.2, 1000); / slight zoom */
},
error: function(hdr, status, err) {
console.error("Failed to load PDB " + pdbUri + ": " + err);
},
});

Ideally, this would work as I'm passing topology files first and then trajectory files later. But I'm getting only blank screen. Is it because I'm passing the files data and not putting it in textarea tag? Please help. I tried with issue #416 solution but still, I'm only getting blank screen

@dkoes
Copy link
Contributor

dkoes commented Dec 21, 2021

You aren't calling jQuery.ajax properly, you aren't using the data it fetches, you are providing (presumably) URLs instead of molecular data, there is not GLModel.AddAtoms method (and you should provide the data when you create the model).

@dkoes
Copy link
Contributor

dkoes commented Dec 21, 2021

Here is an example of loading a netcdf:
https://3dmol.org/tests/auto/generate_test.cgi?test=test91

@MayurDange15
Copy link
Author

@dkoes Thank you sir, I'll take a look at it...

@MayurDange15
Copy link
Author

@dkoes Sir, one question I'd like to ask, by any other methods we can use some different file formats, like XTC, DCD, etc?

@dkoes
Copy link
Contributor

dkoes commented Dec 21, 2021

Currently, the only trajectory formats supported are mdcrd, inpcrd, pdb, netcdf, or a raw array of coordinates.

@MayurDange15
Copy link
Author

@dkoes Thank you so much sir, for such a quick response.

@dkoes dkoes closed this as completed Jan 4, 2023
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