Closed Dave-Montgomery closed 5 years ago
Yes. Make a transform that parses the JSON from the downloaded string and returns the string with the PDB data. You can even make it “parametric” if a single Json contains more pdb structures. Similar to https://github.com/dsehnal/LiteMol/blob/master/src/Viewer/PDBe/Validation.ts#L184
The rest is just using the same transforms you would use with downloading, similar to say https://github.com/dsehnal/LiteMol/blob/master/examples/Channels/src/State.ts#L48
If you need more help let me know.
Hi David, We need more help on this. Dave would have to modify the LiteMol code to do this right? So you are proposing we use the loadData function as a template and modify it? I don't see how to do this without writing further code.
We'd need something like this:
export function loadData(plugin: Plugin.Controller, pdbId: string, pdbFileAsString: string) {
return new Promise
let model = plugin.createTransform()
.add(plugin.root, Transformer.Data.Download, { file: $pdbFileAsString, type: 'String', id: pdbId })
.then(Transformer.Molecule.CreateFromData, { format: Core.Formats.Molecule.SupportedFormats.PDB }, { isBinding: true })
// What does the isBinding doing? .then(Transformer.Molecule.CreateModel, { modelIndex: 0 }) .then(Transformer.Molecule.CreateMacromoleculeVisual, { polymer: true, polymerRef: 'polymer-visual', het: true })
Right, you already have the JSON parsed.
Then just replace the Download transform with this FromData one and it will work https://github.com/dsehnal/LiteMol/blob/master/src/lib/Bootstrap/Entity/Transformer/Data.ts#L126
Btw isBinding is a UI thing meaning the parent node will be hidden in the tree.
David
Thank you! Worked like a charm.
I have a database of over 160,000 entries with small pdb files that are returned as a part of a JSON object. Is there any way to feed the pdb file in from the JSON object without making a file first?