<div dir="ltr"><div>Hi Tristan,</div><div><br></div><div>That's very helpful. Your repository has been a valuable resource for me already, yet somehow I overlooked your initialize hook.<br><br></div><div>Using the loadPluginsDirectory() method I haven't had to worry *yet* about when I import openmm but doing it as early as possible, as you do, makes sense.<br><br></div><div>I'm sure I'll have plenty of questions as I make headway.<br><br></div><div>Cheers,<br><br></div><div>Tom</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 15, 2020 at 11:50 AM Tristan Croll <<a href="mailto:tic20@cam.ac.uk" target="_blank">tic20@cam.ac.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-size:10pt">
<p>Yes, this is a current limitation. At the moment, if ISOLDE is installed then everything gets set up automatically when ChimeraX starts. Essentially, the environment variable OPENMM_PLUGIN_DIR needs to be set before you `import openmm` for the first time. The easiest way to ensure this happens is to put the necessary code into your bundle's `initialize` method (which is guaranteed to be called on ChimeraX startup if you set `custom_init=true` in the BundleInfo tag in your bundle_info.xml). To see an example of this in ISOLDE:</p>
<p>initialize_openmm() method: <a href="https://github.com/tristanic/isolde/blob/a9f976c34affbe917de9e1f6a6062ea423e49054/isolde/src/__init__.py#L10" target="_blank">https://github.com/tristanic/isolde/blob/a9f976c34affbe917de9e1f6a6062ea423e49054/isolde/src/__init__.py#L10</a></p>
<p>... gets called by BundleAPI.initialize(): <a href="https://github.com/tristanic/isolde/blob/a9f976c34affbe917de9e1f6a6062ea423e49054/isolde/src/__init__.py#L44" target="_blank">https://github.com/tristanic/isolde/blob/a9f976c34affbe917de9e1f6a6062ea423e49054/isolde/src/__init__.py#L44</a></p>
<p>... which is called because of the property set in bundle_info.xml: <a href="https://github.com/tristanic/isolde/blob/a9f976c34affbe917de9e1f6a6062ea423e49054/isolde/bundle_info.xml#L14" target="_blank">https://github.com/tristanic/isolde/blob/a9f976c34affbe917de9e1f6a6062ea423e49054/isolde/bundle_info.xml#L14</a>. </p>
<p>Feel free to get in touch if you want any other tips about working with OpenMM in ChimeraX.</p>
<div id="gmail-m_3623849251782358833gmail-m_983733124796225976signature"> </div>
<p><br></p>
<p id="gmail-m_3623849251782358833gmail-m_983733124796225976reply-intro">On 2020-09-15 11:28, Thomas Mulvaney wrote:</p>
<blockquote type="cite" style="padding:0px 0.4em;border-left:2px solid rgb(16,16,255);margin:0px">
<div id="gmail-m_3623849251782358833gmail-m_983733124796225976replybody1">
<div dir="ltr">
<div><span style="font-family:arial,sans-serif">Hi,<br><br></span></div>
<div><span style="font-family:arial,sans-serif">I've been having fun developing a plugin for ChimeraX and want to firstly thank</span></div>
<div><span style="font-family:arial,sans-serif">everyone involved for such a great platform to build upon.<br><br></span></div>
<div><span style="font-family:arial,sans-serif">I'm starting to introduce a molecular dynamics component and was excited to see that<br></span></div>
<div><span style="font-family:arial,sans-serif">ChimeraX ships with OpenMM support.<br><br></span></div>
<div><span style="font-family:arial,sans-serif">Unfortunately, the OpenMM Platform plugins (which add CPU, CUDA, OpenCL etc) functionality, do<br></span></div>
<div><span style="font-family:arial,sans-serif">not seem to be loaded by default at least in ChimeraX 1.1 on macOS.<br><br></span></div>
<div><span style="font-family:arial,sans-serif">I couldn't see any documentation about how to load these plugins, <br>but for anyone running into this issue, the following code got things working for me:</span></div>
<div><span style="font-family:arial,sans-serif"> </span></div>
<div><span style="font-family:monospace">------<br></span></div>
<div><span style="font-family:monospace">import chimerax</span></div>
<div><span style="font-family:monospace">openmm_plugins_dir = os.path.join(chimerax.app_lib_dir, 'plugins')</span></div>
<div><span style="font-family:monospace">Platform.loadPluginsFromDirectory(openmm_plugins_dir)</span></div>
<div><span style="font-family:arial,sans-serif"><span style="font-family:monospace">------</span><br><br></span></div>
<div><span style="font-family:arial,sans-serif"> </span></div>
<div><span style="font-family:monospace"><span style="font-family:arial,sans-serif">Kind regards,<br></span><br></span></div>
<div><span style="font-family:arial,sans-serif">Tom</span>
<div><br><br></div>
</div>
</div>
</div>
<br>
<div style="margin:0px;padding:0px;font-family:monospace">_______________________________________________<br>ChimeraX-users mailing list<br><a href="mailto:ChimeraX-users@cgl.ucsf.edu" target="_blank">ChimeraX-users@cgl.ucsf.edu</a><br>Manage subscription:<br><a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users" rel="noopener noreferrer" target="_blank">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</a></div>
</blockquote>
</div>
</blockquote></div>