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

Import error on Google Colab #532

Closed
bcallen95 opened this issue Dec 7, 2021 · 2 comments
Closed

Import error on Google Colab #532

bcallen95 opened this issue Dec 7, 2021 · 2 comments

Comments

@bcallen95
Copy link

Hi there! I've been trying to run the "Alchemical Free Energy Calculations" Tutorial on the OpenMM Page. When I try to import openmmtools I get the following traceback:


AttributeError Traceback (most recent call last)
in ()
----> 1 import openmmtools

2 frames
/usr/local/envs/openmm/lib/python3.7/site-packages/openmmtools/init.py in ()
6 """
7
----> 8 from openmmtools import testsystems, integrators, alchemy, mcmc, states, cache, utils, constants, forces, forcefactories, storage, multistate
9
10 # Handle versioneer

/usr/local/envs/openmm/lib/python3.7/site-packages/openmmtools/multistate/init.py in ()
63
64 from openmmtools.multistate.multistatesampler import MultiStateSampler
---> 65 from openmmtools.multistate.multistatereporter import MultiStateReporter
66 from openmmtools.multistate.replicaexchange import ReplicaExchangeSampler, ReplicaExchangeAnalyzer
67 from openmmtools.multistate.paralleltempering import ParallelTemperingSampler, ParallelTemperingAnalyzer

/usr/local/envs/openmm/lib/python3.7/site-packages/openmmtools/multistate/multistatereporter.py in ()
1752 # ==============================================================================
1753
-> 1754 class _DictYamlLoader(yaml.CLoader):
1755 """PyYAML Loader that reads !Quantity tags."""
1756 def init(self, *args, **kwargs):

AttributeError: module 'yaml' has no attribute 'CLoader'

Do you have any thoughts/advice on how to go about fixing this issue? Thanks!

@bcallen95
Copy link
Author

bcallen95 commented Dec 7, 2021

It appears that my environment set-up was the issue. Alternatively setting up the Conda environment (in Google Colab) in the following way appears to fix all issues (with each separate "code block" representing a separate cell):

!pip install -q condacolab
import condacolab
condacolab.install()
import condacolab
condacolab.check()
!mamba install -q openmmtools

However, this does lead to a new issue in the "Analyzing the Data with MBAR" Section... Running the following code:

from pymbar import MBAR, timeseries
N_k = np.zeros([nstates], np.int32) # number of uncorrelated samples
for k in range(nstates):
      [nequil, g, Neff_max] = timeseries.detectEquilibration(u_kln[k,k,:])
      indices = timeseries.subsampleCorrelatedData(u_kln[k,k,:], g=g)
      N_k[k] = len(indices)
      u_kln[k,:,0:N_k[k]] = u_kln[k,:,indices].T
mbar = MBAR(u_kln, N_k)
[DeltaF_ij, dDeltaF_ij, Theta_ij] = mbar.getFreeEnergyDifferences()

Results in this traceback:


ParameterError Traceback (most recent call last)
in ()
10 # Compute the Free Energy Differences and Statistical Uncertainties
11 mbar = MBAR(u_kln, N_k)
---> 12 [DeltaF_ij, dDeltaF_ij, Theta_ij] = mbar.getFreeEnergyDifferences()

2 frames
/usr/local/lib/python3.7/site-packages/pymbar/utils.py in check_w_normalized(W, N_k, tolerance)
367 raise ParameterError(
368 'Warning: Should have \sum_k N_k W_nk = 1. Actual row sum for sample %d was %f. %d other rows have similar problems' %
--> 369 (firstbad, row_sums[firstbad], np.sum(badrows)))
370
371 return

ParameterError: Warning: Should have \sum_k N_k W_nk = 1. Actual row sum for sample 6 was 0.999696. 7 other rows have similar problems

@mikemhenry
Copy link
Contributor

@bcallen95 Sorry I just saw this, that error you are getting now is from pymbar, see this issue: choderalab/pymbar#419

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