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

Integrate MolQL transpilers in Mol* #4

Open
ptourlas opened this issue Dec 16, 2021 · 2 comments
Open

Integrate MolQL transpilers in Mol* #4

ptourlas opened this issue Dec 16, 2021 · 2 comments

Comments

@ptourlas
Copy link

Greetings!

I have seen the examples offered at http://molql.org/explorer.html and I would like to integrate the PyMol and VMD transpilers in a Molstar fork that I have. My goal is to allow selections from any language the user prefers, just like in the MolQL explorer. From what I understand, the transpilers produce something pretty close to what Molstar "speaks". For example,
StructureSelectionQueries.water.expression() (see https://github.com/molstar/molstar/blob/704a9a111dff82e3566276068b1c33505570ccb7/src/mol-plugin-state/helpers/structure-selection-query.ts#L276)
returns:

{
    head: {
      name: "structure-query.modifier.union",
    },
    args: [
      {
        head: {
          name: "structure-query.generator.atom-groups",
        },
        args: {
          "entity-test": {
            head: {
              name: "core.rel.eq",
            },
            args: [
              {
                head: {
                  name: "structure-query.atom-property.macromolecular.entity-type",
                },
              },
              "water",
            ],
          },
        },
      },
    ],
  }

which I can use to add a representation for the waters in a given structure.

On the other hand, water selection in the MolQL explorer yields:

{
  "source": "molql-explorer",
  "version": "0.1.0",
  "expression": {
    "head": "structure.generator.atom-groups",
    "args": {
      "residue-test": {
        "head": "core.set.has",
        "args": [
          {
            "head": "core.type.set",
            "args": [
              "H2O",
              "HH0",
              "OHH",
              "HOH",
              "OH2",
              "SOL",
              "WAT",
              "TIP",
              "TIP2",
              "TIP3",
              "TIP4"
            ]
          },
          {
            "head": "structure.atom-property.macromolecular.label_comp_id"
          }
        ]
      }
    }
  }
}

I tried to substitute the first query with the expression part of the second, but Molstar greeted me with an Error: Can only apply symbols message.
Any hints on how to approach this?

@dsehnal
Copy link
Collaborator

dsehnal commented Dec 16, 2021

Hi, this should be possible without too many changes. The example you provided is "broken" because the structure namespace has been renamed to structure-query in Mol*, but mostly the language is the same.

Just getting the source from https://github.com/MolQL/molql/tree/master/src/transpilers/pymol and vmd folders and placing it in https://github.com/molstar/molstar/tree/master/src/mol-script should get you most of the way.

Notable replacements are parsimmon => mol-util/monadic-parser and /molql/builder => mol-script/language/builder's MolScriptBuilder.

Would you be willing to make a PR to the Mol* repository with this and we can make it work there? I am sure other people would appreciate this as well!

@ptourlas
Copy link
Author

As a handy reference to anyone interested, the relevant PR is molstar/molstar#325

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