Acylation / obsidian-chem

Chemistry support for Obsidian. Rendering SMILES strings into chemistry structures.
MIT License
73 stars 4 forks source link

Render structure inside dataview query #76

Open stuarttravers opened 1 month ago

stuarttravers commented 1 month ago

What would you like to be added?

Is it possible to render a structure inside a dataview query? Instead of showing the smiles string for each result returned, display the structure instead. I don't know if this is even possible and sounds like it would be more for dataview to include the functionality. As someone working in the biotech sector, I make separate notes for each molecule I'm interested in and tag them by things like area and target. I use the meta-bind plugin to filter the query based on what I want and being able to render the structures along with other properties would be super useful. I currently have about 100 individual molecule pages and have the smiles strings as a property in each.

Here's my dataview query

TABLE without ID file.link AS "Name", Molecule_ID AS "ID", target as "Target", summary AS "Summary" FROM -"Templates" WHERE contains(tags, "molecule") AND contains(lower(target), lower(this.target_search)) AND ((contains(lower(file.name), lower(this.search_text))) OR (contains(lower(summary), lower(this.search_text)))) SORT Molecule_ID DESC

I'm currently rendering a single structure outside the dataview query using this code.

smiles $= dv.pages().where(p => p.Molecule_ID == dv.current().ID_search)[0].smiles

Being able to merge this into the dataview query would be super helpful

Why is this needed?

This would make dataview querying much more interactive

Acylation commented 1 month ago

Hi you can refer to #43 that @Alicecomma introduced using ~~~ in dataview blocks to simulates codeblocks.

stuarttravers commented 1 month ago

Amazing thanks. Apologies for not looking through the closed tickets first. That also fixes my other issue which was that the inline queries don't always refresh unless you navigate out and back in to the page. When the code is in a dataviewjs query, the table and structures all update at the same time.