molstar / molstar

A comprehensive macromolecular library

Home Page:https://molstar.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in `OpenFiles` Action When Extension is Not Given

frederickparsons-tandemai opened this issue · comments

I was trying to load a bcif file using a blob in memory. I tried creating an asset where I don't specify the extension in the name like this and specifying the type as mmcif manually. I would expect the loading of the file to work ok even if I don't give an extension

      const asset = Asset.File(new File([blob], '2ZZO'))
      
      const task = pluginUIContext.current.state.data.applyAction(OpenFiles, {
        files: [asset],
        format: {
          name: 'specific',
          params: 'mmcif',
        },
        visuals: true, // Create the visual representations
      });

See working example of the bug here:

edit: from asimards investigation, it appears that isBinary is only detected from the filename:
image

Sounds like the fix is just to add an additional parameter to this action so it can specify it when specific is used. I'll see next week if I can get a PR for this fix.

Technically speaking, you are providing a file and extension is a common way how to determine a format. The isBinary is only present in the "URL assets" as it is not common to use extensions there.

What exactly is preventing you when specifying the extension when creating the asset?

The use case is a bit unique here. I in fact have a url asset but I am doing the download of the file outside of Mol*.

In this case I am using the default mol-plugin-ui. The issue I have is that I can correctly specify filename.bcif but this will appear in the UI with the extension at the root of the tree. Instead, I just want filename to appear at the root.

Still an issue?