Open Raiyan-Rizwan opened 2 months ago
Hi @Raiyan-Rizwan,
Please see https://github.com/molstar/mol-view-spec/issues/18 for details. Local files aren't supported because the resulting MVS file wouldn't work on other machines. You can always upload your data to S3, Google Drive, Dropbox, ...
Best, Sebastian
Good Afternoon, So I am using Google Drive as a web platform to host the pdb files I am going to visualize on Molstar. I get the file from google drive and produce the download link using the following code:
def get_drive_download_link(drive_url): """ Converts a Google Drive sharing URL into a direct download link. """ file_id = drive_url.split('/')[-2] return f'https://drive.google.com/uc?export=download&id={file_id}'
Then I run the download link through the builder(made using molviewspec built in functions). However, I get the following error. Do you have any suggestions for fixing this error?
Thanks
Indeed, thanks for giving this a try. We'll look into this, though I'm not sure if this is fixable in Mol*/MolViewSpec or if this is a more general issue with how Google Drive decides to share files.
Good Afternoon, Were you guys able to get to what is causing the issue? Please let me know.
Thanks
@midlik Do you think this can be addressed in the Mol* code or is this a limitation of Google Drive?
Hi, this looks as a CORS problem. So there is no way of addressing this in Mol*. The files must be served with CORS enabled (and unfortunately I don't think GoogleDrive allows this, S3 might allow you to enable it).
If you have no possibility of hosting those structure files with CORS enabled, you can still use relative URL and pack you MVSJ + structure files into a MVSX file (https://molstar.org/mol-view-spec-docs/#mvsx). Something like this:
builder.download(url='./my-structure.cif')
...
builder.save_state(destination='example.mvsj')
import zipfile
with zipfile.ZipFile('example.mvsx', mode='w') as z:
z.write('example.mvsj', arcname='index.mvsj')
z.write('my-structure.cif', arcname='my-structure.cif')
It worked with S3. Thanks!
The following is an example from the code you guys provided within your Python Collab Notebook:
builder = mvs.create_builder() structure1 = ( builder.download(url="https://files.wwpdb.org/download/1oj6.cif") .parse(format="mmcif") .assembly_structure() )
structure1.component(selector='polymer').representation(type='cartoon').color(color='#e19039') structure1.component(selector='ligand').representation(type='ball_and_stick').color(color='#eec190')
structure2 = ( builder.download(url="https://files.wwpdb.org/download/5mjd.cif") .parse(format="mmcif") .assembly_structure()
.transform(
rotation=[-0.39652203922082313, 0.918022802798312, 0.002099036562725462, 0.9068461182538327, 0.39133670281585825, 0.1564790811487865, 0.14282993460796656, 0.06395090751149791, -0.9876790426086504],
translation=[-17.636085896690037, 7.970761314734439, 88.54613248028247]
)
)
structure2.component(selector='polymer').representation(type='cartoon').color(color='#4b7fcc') structure2.component(selector='ligand').representation(type='ball_and_stick').color(color='#9cb8e3')
print(builder.get_state())
Thanks
Hello, Can you guys please let me know what technique you used to convert the output of builder..get_state(), which is in JSON format to URL in this specific case? Would be very helpful.
Thanks
Hi Raiyan,
I understand that your question is about using the mvs-data
URL parameter. Unfortunately, URL length is limited in most browsers and only very simple MVS views fit into this limit. If you have a more complex view, you'll have to use a different method of sharing, e.g. host the file somewhere and use the mvs-url
parameter.
Find some documentation here: http://molstar.org/mol-view-spec-docs/mvs-molstar-extension/
Hi, I noticed that the API allows download via url, but what would I do if I am to use a pdb file within my machine's file system?