RenderableMolecule

Inherits Renderable

Used to render a single molecular system, which can be either static or dynamic. The rendering is done using the rendering engine of the ViaMD framework. Many of the parameters are described in greater detail on their Wiki page. It is possible to assign multiple representations to a molecular structure and specify individual settings per representation, including the ability to filter using ViaMD’s powerful filtering scripting language.

The current implementation supports the loading of “PDB”, “Gromacs”, “XYZ”, “XMOL”, and “ARC” files for the molecular structure and “PDB”, “XTC”, “TRR”, “XYZ”, “XMOL”, and “ARC” files for the optional trajectories.

If no trajectory file is provided only the structural information is shown.

Members

Name

Documentation

Type

Description

Optional

MoleculeFile

The path to the file from which the molecular structure is read.

File

Value of type ‘File’

No

AnimationBaseScale

Base scale for the animation. Tune this to sync up its animation with other trajectories.

Double

Value of type ‘Double’

Yes

AnimationRepeatMode

Controls how the animation should be repeated when the end of the animation is reached.

String

In list { PingPong, Wrap, Clamp }

Yes

AnimationSpeed

Playback speed of the animation (in frames per second).

Double

Value of type ‘Double’

Yes

ApplyPbcOnLoad

Applies Periodic Boundary Constraints upon loading trajectory frames.

Boolean

Value of type ‘Boolean’

Yes

ApplyPbcPerFrame

Applies Periodic Boundary Constraints for each interpolated frame (can be CPU-intensive).

Boolean

Value of type ‘Boolean’

Yes

CoarseGrained

Enable if the dataset should be interpreted as coarse grained.

Boolean

Value of type ‘Boolean’

Yes

DimInAtmosphere

Decides if the object should be dimmed (i.e. faded out) when the camera is in the sunny part of an atmosphere.

Boolean

Value of type ‘Boolean’

Yes

Enabled

Determines whether this object will be visible or not.

Boolean

Value of type ‘Boolean’

Yes

Opacity

This value determines the opacity of this renderable. A value of 0 means completely transparent.

Double

In range: ( 0, 1)

Yes

RenderBinMode

A value that specifies if the renderable should be rendered in the Background, Opaque, Pre-/PostDeferredTransparency, Overlay, or Sticker rendering step.

String

In list { Background, Opaque, PreDeferredTransparent, Overlay, PostDeferredTransparent, Sticker }

Yes

Representations

The list of representations that are used to render this molecular dataset. Each representation can consist of a representation type, a coloring method, and and optional filter and scaling that can be applied to each representation individually.

Table

Table parameters

Yes

Tag

A single tag or a list of tags that this renderable will respond to when setting properties.

Table, or String

Value of type ‘Table’, or Value of type ‘String’

Yes

TrajectoryFile

The path to the file from which the trajectory information is read.

File

Value of type ‘File’

Yes

Type

The type of the renderable.

String

Value of type ‘String’

Yes

Inherited members from Renderable

Name

Documentation

Type

Description

Optional

DimInAtmosphere

Decides if the object should be dimmed (i.e. faded out) when the camera is in the sunny part of an atmosphere.

Boolean

Value of type ‘Boolean’

Yes

Enabled

Determines whether this object will be visible or not.

Boolean

Value of type ‘Boolean’

Yes

Opacity

This value determines the opacity of this renderable. A value of 0 means completely transparent.

Double

In range: ( 0, 1)

Yes

RenderBinMode

A value that specifies if the renderable should be rendered in the Background, Opaque, Pre-/PostDeferredTransparency, Overlay, or Sticker rendering step.

String

In list { Background, Opaque, PreDeferredTransparent, Overlay, PostDeferredTransparent, Sticker }

Yes

Tag

A single tag or a list of tags that this renderable will respond to when setting properties.

Table, or String

Value of type ‘Table’, or Value of type ‘String’

Yes

Type

The type of the renderable.

String

Value of type ‘String’

Yes

Table parameters for Representations

The list of representations that are used to render this molecular dataset. Each representation can consist of a representation type, a coloring method, and and optional filter and scaling that can be applied to each representation individually.

  • Optional: Yes

Name

Documentation

Type

Description

Optional

*

This is a representation of a molecular dataset. Each representation is rendered independently and can contain different rendering and filtering parameters.

Table

Table parameters

Yes

Table parameters for *

This is a representation of a molecular dataset. Each representation is rendered independently and can contain different rendering and filtering parameters.

  • Optional: Yes

Name

Documentation

Type

Description

Optional

Color

The method by which the selected representation should be colored.

String

In list { Cpk, AtomIndex, ResId, ResIndex, ChainId, ChainIndex, SecondaryStructure, Uniform }

Yes

Filter

The ViaMD filter that can be used to filter atoms, residues, chains, and other primary or secondary structures.

String

Value of type ‘String’

Yes

Scale

A scaling factor that causes a different scaling effect depending on the selected representation type. In general, a larger value will cause the representation to be rendered larger and more prominently.

Double

Value of type ‘Double’

Yes

UniformColor

The uniform color that is used if not coloring method is selected.

Vector4<double>

Value of type ‘Vector4

Yes

Asset Examples

  1local moleculeDb = "https://home.thissma.fr/moldata/"
  2
  3
  4
  5local moleculeO2 = asset.resource({
  6  Name = "Molecule O2",
  7  Type = "HttpSynchronization",
  8  Identifier = "molecule_dynamics_o2",
  9  Version = 1
 10})
 11
 12local moleculeH2O = asset.resource({
 13  Name = "Molecule H2O",
 14  Type = "HttpSynchronization",
 15  Identifier = "molecule_dynamics_h2o",
 16  Version = 1
 17})
 18
 19local moleculeCO2 = asset.resource({
 20  Name = "Molecule CO2",
 21  Type = "HttpSynchronization",
 22  Identifier = "molecule_dynamics_co2",
 23  Version = 1
 24})
 25
 26local moleculeC60 = asset.resource({
 27  Name = "Molecule C60",
 28  Type = "HttpSynchronization",
 29  Identifier = "molecule_dynamics_c60",
 30  Version = 1
 31})
 32
 33local molecule1ala500 = asset.resource({
 34  Name = "Molecule 1ALA-500",
 35  Type = "HttpSynchronization",
 36  Identifier = "molecule_dynamics_1ala-500",
 37  Version = 1
 38})
 39
 40local molecule1bna = asset.resource({
 41  Name = "Molecule 1BNA",
 42  Type = "HttpSynchronization",
 43  Identifier = "molecule_dynamics_1bna",
 44  Version = 1
 45})
 46
 47local iceMelting = asset.resource({
 48  Name = "Ice Melting Simulation",
 49  Type = "HttpSynchronization",
 50  Identifier = "molecule_dynamics_ice-melting",
 51  Version = 1
 52})
 53
 54local aspirin = asset.resource({
 55  Name = "Molecule Aspirin",
 56  Type = "HttpSynchronization",
 57  Identifier = "molecule_dynamics_aspirin",
 58  Version = 1
 59})
 60
 61local amyloid = asset.resource({
 62  Name = "Molecule Amyloid",
 63  Type = "HttpSynchronization",
 64  Identifier = "molecule_dynamics_amyloid",
 65  Version = 1
 66})
 67
 68
 69local MoleculeMisc = {
 70  Identifier = "MoleculeMisc",
 71  Tag = { "molecule_visualization" },
 72  GUI = {
 73    Name = "Molecule Museum",
 74    Path = "/Microcosmos/Molecules/Misc",
 75    Hidden = true
 76  }
 77}
 78
 79local MoleculeO2 = {
 80  Identifier = "MoleculeMiscO2",
 81  Parent = MoleculeMisc.Identifier,
 82  Transform = {
 83    Translation = {
 84      Type = "StaticTranslation",
 85      Position = { 0.0, 0.0, 0.0 }
 86    }
 87  },
 88  Renderable = {
 89    Type = "RenderableMolecule",
 90    MoleculeFile = moleculeO2 .. "o2.arc",
 91    TrajectoryFile = moleculeO2 .. "o2.arc",
 92    AnimationSpeed = 5.0
 93  },
 94  Tag = { "molecule_visualization" },
 95  GUI = {
 96    Name = "Dioxygen (O2)",
 97    Path = "/Microcosmos/Molecules/Misc"
 98  }
 99}
100
101local MoleculeH2O = {
102  Identifier = "MoleculeMiscH2O",
103  Parent = MoleculeMisc.Identifier,
104  Transform = {
105    Translation = {
106      Type = "StaticTranslation",
107      Position = { 20.0, 0.0, 0.0 }
108    }
109  },
110  Renderable = {
111    Type = "RenderableMolecule",
112    MoleculeFile = moleculeH2O .. "h2o.arc"
113  },
114  Tag = { "molecule_visualization" },
115  GUI = {
116    Name = "Water (H2O)",
117    Path = "/Microcosmos/Molecules/Misc"
118  }
119}
120
121local MoleculeCO2 = {
122  Identifier = "MoleculeMiscCO2",
123  Parent = MoleculeMisc.Identifier,
124  Transform = {
125    Translation = {
126      Type = "StaticTranslation",
127      Position = { 40.0, 0.0, 0.0 }
128    }
129  },
130  Renderable = {
131    Type = "RenderableMolecule",
132    MoleculeFile = moleculeCO2 .. "co2.arc",
133    Representations = {
134      {
135        Type = "Licorice"
136      }
137    }
138  },
139  Tag = { "molecule_visualization" },
140  GUI = {
141    Name = "Carbon Dioxyde (CO2)",
142    Path = "/Microcosmos/Molecules/Misc"
143  }
144}
145
146local MoleculeC60 = {
147  Identifier = "MoleculeMiscC60",
148  Parent = MoleculeMisc.Identifier,
149  Transform = {
150    Translation = {
151      Type = "StaticTranslation",
152      Position = { 60.0, 0.0, 0.0 }
153    }
154  },
155  Renderable = {
156    Type = "RenderableMolecule",
157    MoleculeFile = moleculeC60 .. "c60.arc",
158    Representations = {
159      {
160        Type = "Licorice"
161      }
162    }
163  },
164  Tag = { "molecule_visualization" },
165  GUI = {
166    Name = "C60",
167    Path = "/Microcosmos/Molecules/Misc"
168  }
169}
170
171local MoleculeAlanin = {
172  Identifier = "MoleculeMiscAlanin",
173  Parent = MoleculeMisc.Identifier,
174  Transform = {
175    Translation = {
176      Type = "StaticTranslation",
177      Position = { 110.0, 0.0, 0.0 }
178    }
179  },
180  Renderable = {
181    Type = "RenderableMolecule",
182    MoleculeFile = molecule1ala500 .. "1ALA-500.pdb",
183    TrajectoryFile = molecule1ala500 .. "1ALA-500.pdb",
184    AnimationSpeed = 5.0
185  },
186  Tag = { "molecule_visualization" },
187  GUI = {
188    Name = "Alanin",
189    Path = "/Microcosmos/Molecules/Misc"
190  }
191}
192
193local MoleculeDNA = {
194  Identifier = "MoleculeMiscDNA",
195  Parent = MoleculeMisc.Identifier,
196  Transform = {
197    Translation = {
198      Type = "StaticTranslation",
199      Position = { 160.0, 0.0, 0.0 }
200    }
201  },
202  Renderable = {
203    Type = "RenderableMolecule",
204    MoleculeFile = molecule1bna .. "1bna.pdb",
205    Representations = {
206      {
207        Type = "Licorice"
208      }
209    }
210  },
211  Tag = { "molecule_visualization" },
212  GUI = {
213    Name = "DNA",
214    Path = "/Microcosmos/Molecules/Misc"
215  }
216}
217
218local MoleculeIce = {
219  Identifier = "MoleculeMiscIce",
220  Parent = MoleculeMisc.Identifier,
221  Transform = {
222    Translation = {
223      Type = "StaticTranslation",
224      Position = { 210.0, 0.0, 0.0 }
225    }
226  },
227  Renderable = {
228    Type = "RenderableMolecule",
229    MoleculeFile = iceMelting .. "ice.gro",
230    TrajectoryFile = iceMelting .. "ice.xtc",
231    AnimationSpeed = 10.0
232  },
233  Tag = { "molecule_visualization" },
234  GUI = {
235    Name = "Ice Melting",
236    Path = "/Microcosmos/Molecules/Misc"
237  }
238}
239
240local MoleculeAspirin = {
241  Identifier = "MoleculeMiscAspirin",
242  Parent = MoleculeMisc.Identifier,
243  Transform = {
244    Translation = {
245      Type = "StaticTranslation",
246      Position = { 310.0, 0.0, 0.0 }
247    }
248  },
249  Renderable = {
250    Type = "RenderableMolecule",
251    MoleculeFile = aspirin .. "aspirin.gro",
252    TrajectoryFile = aspirin .. "aspirin.xtc",
253    AnimationSpeed = 5.0,
254    Representations = {
255      {
256        Type = "Licorice",
257        Filter = "not water"
258      }
259    }
260  },
261  Tag = { "molecule_visualization" },
262  GUI = {
263    Name = "Aspirin",
264    Path = "/Microcosmos/Molecules/Misc"
265  }
266}
267
268local MoleculeAmyloidMarker = {
269  Identifier = "MoleculeMiscAmyloidMarker",
270  Parent = MoleculeMisc.Identifier,
271  Transform = {
272    Translation = {
273      Type = "StaticTranslation",
274      Position = { 510.0, 0.0, 0.0 }
275    }
276  },
277  Renderable = {
278    Type = "RenderableMolecule",
279    MoleculeFile = amyloid .. "60pft_in_tau.gro",
280    TrajectoryFile = amyloid .. "60pft_in_tau-traj-96-106ns.xtc",
281    AnimationSpeed = 0.1
282  },
283  Tag = { "molecule_visualization" },
284  GUI = {
285    Name = "Amyloid Marker",
286    Path = "/Microcosmos/Molecules/Misc"
287  }
288}
289
290
291asset.onInitialize(function()
292  openspace.addSceneGraphNode(MoleculeMisc)
293  openspace.addSceneGraphNode(MoleculeO2)
294  openspace.addSceneGraphNode(MoleculeH2O)
295  openspace.addSceneGraphNode(MoleculeCO2)
296  openspace.addSceneGraphNode(MoleculeC60)
297  openspace.addSceneGraphNode(MoleculeAlanin)
298  openspace.addSceneGraphNode(MoleculeDNA)
299  openspace.addSceneGraphNode(MoleculeIce)
300  openspace.addSceneGraphNode(MoleculeAspirin)
301  openspace.addSceneGraphNode(MoleculeAmyloidMarker)
302end)
303
304asset.onDeinitialize(function()
305  openspace.removeSceneGraphNode(MoleculeAmyloidMarker)
306  openspace.removeSceneGraphNode(MoleculeAspirin)
307  openspace.removeSceneGraphNode(MoleculeIce)
308  openspace.removeSceneGraphNode(MoleculeDNA)
309  openspace.removeSceneGraphNode(MoleculeAlanin)
310  openspace.removeSceneGraphNode(MoleculeC60)
311  openspace.removeSceneGraphNode(MoleculeCO2)
312  openspace.removeSceneGraphNode(MoleculeH2O)
313  openspace.removeSceneGraphNode(MoleculeO2)
314  openspace.removeSceneGraphNode(MoleculeMisc)
315end)
316
317asset.export(MoleculeMisc)
318asset.export(MoleculeO2)
319asset.export(MoleculeH2O)
320asset.export(MoleculeCO2)
321asset.export(MoleculeC60)
322asset.export(MoleculeAlanin)
323asset.export(MoleculeDNA)
324asset.export(MoleculeIce)
325asset.export(MoleculeAspirin)
326asset.export(MoleculeAmyloidMarker)
327
328
329
330asset.meta = {
331  Name = "Various Molecules",
332  Description = [[Visualizes a selection of different molecules to represent the
333    functionality of the MolVis rendering framework.]],
334  Author = "OpenSpace Team",
335  URL = "https://openspaceproject.com",
336  License = "MIT license"
337}