markovmodel / PyEMMA

šŸš‚ Python API for Emma's Markov Model Algorithms šŸš‚
http://pyemma.org
GNU Lesser General Public License v3.0
306 stars 119 forks source link

Unable to import pyemma after installation using jupyter notebook #1575

Open debanjansen48 opened 1 year ago

debanjansen48 commented 1 year ago

Thanks for submitting an issue!

Here's a quick checklist in what to include:

  1. I created a conda env
  2. activated conda env
  3. using conda installed pyemma, mdshare, nglview, jupyter notebook.
  4. inside the activated pyemma env I opend jupyter notebook 5.After issuing the command import pyemma it returns ModuleNotFoundError Traceback (most recent call last) /tmp/ipykernel_2239/684328617.py in ----> 1 import pyemma

ModuleNotFoundError: No module named 'pyemma'

  1. after issuing the command !pip install pyemma

Requirement already satisfied: pyemma in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (2.5.11) Requirement already satisfied: tqdm>=4.23 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (4.64.1) Requirement already satisfied: h5py>=2.7.1 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (3.7.0) Requirement already satisfied: matplotlib in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (3.5.3) Requirement already satisfied: scipy>=0.11 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (1.9.1) Requirement already satisfied: numpy>=1.8.0 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (1.23.2) Requirement already satisfied: mdtraj>=1.9.2 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (1.9.7) Requirement already satisfied: pathos in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (0.2.9) Requirement already satisfied: psutil>=3.1.1 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (5.9.2) Requirement already satisfied: decorator>=4.0.0 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (5.1.1) Requirement already satisfied: msmtools>=1.2 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (1.2.6) Requirement already satisfied: pyyaml in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (6.0) Requirement already satisfied: deeptime in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (0.4.3) Requirement already satisfied: bhmm<0.7,>=0.6 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pyemma) (0.6.3) Requirement already satisfied: six in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from bhmm<0.7,>=0.6->pyemma) (1.16.0) Requirement already satisfied: pyparsing in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from mdtraj>=1.9.2->pyemma) (3.0.9) Requirement already satisfied: astunparse in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from mdtraj>=1.9.2->pyemma) (1.6.3) Requirement already satisfied: scikit-learn>=0.14.1 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from deeptime->pyemma) (1.1.2) Requirement already satisfied: threadpoolctl>=2.0.0 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from deeptime->pyemma) (3.1.0) Requirement already satisfied: python-dateutil>=2.7 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from matplotlib->pyemma) (2.8.2) Requirement already satisfied: fonttools>=4.22.0 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from matplotlib->pyemma) (4.37.1) Requirement already satisfied: kiwisolver>=1.0.1 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from matplotlib->pyemma) (1.4.4) Requirement already satisfied: pillow>=6.2.0 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from matplotlib->pyemma) (9.2.0) Requirement already satisfied: cycler>=0.10 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from matplotlib->pyemma) (0.11.0) Requirement already satisfied: packaging>=20.0 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from matplotlib->pyemma) (21.3) Requirement already satisfied: ppft>=1.7.6.5 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pathos->pyemma) (1.7.6.5) Requirement already satisfied: multiprocess>=0.70.13 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pathos->pyemma) (0.70.13) Requirement already satisfied: pox>=0.3.1 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pathos->pyemma) (0.3.1) Requirement already satisfied: dill>=0.3.5.1 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from pathos->pyemma) (0.3.5.1) Requirement already satisfied: joblib>=1.0.0 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from scikit-learn>=0.14.1->deeptime->pyemma) (1.1.0) Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/debanjan/anaconda3/envs/pyemma/lib/python3.9/site-packages (from astunparse->mdtraj>=1.9.2->pyemma) (0.37.1)

Unable to figure out.. kindly help me out thanks

clonker commented 1 year ago

Hi, have you activated the correct environment before starting the server? Also please make sure your jupyter kernel is pointing to the right path (see eg here https://ipython.readthedocs.io/en/stable/install/kernel_install.htm)

debanjansen48 commented 1 year ago

[image: image.png] unable to open the given page.

On Sun, Sep 11, 2022 at 11:55 PM Moritz Hoffmann @.***> wrote:

Hi, have you activated the correct environment before starting the server? Also please make sure your jupyter kernel is pointing to the right path (see eg here https://ipython.readthedocs.io/en/stable/install/kernel_install.htm)

ā€” Reply to this email directly, view it on GitHub https://github.com/markovmodel/PyEMMA/issues/1575#issuecomment-1243017332, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOJ7Q4Q55UBAYS724M4RVMTV5YPZBANCNFSM6AAAAAAQJU5NXA . You are receiving this because you authored the thread.Message ID: @.***>

debanjansen48 commented 1 year ago

after exploring the tutorial section I did the following things

  1. conda activate pyemma to activate the env in side the working folder
  2. conda activate pyemma jupyter nbextension enable toc2/main jupyter nbextension enable exercise2/main jupyter-notebook --browser=firefox 3.I am able to import pyemma successfully
  3. but when i started the tutorial I am encountering the following issues. (installed conda install -c conda-forge pyemma mdshare nglview nbexamples jupyter_contrib_nbextensions)

**%matplotlib inline import matplotlib.pyplot as plt import numpy as np import mdshare

for visualization of molecular structures:

import nglview import mdtraj from threading import * from nglview.player import ** AttributeError Traceback (most recent call last) Cell In [8], line 6 4 import mdshare 5 # for visualization of molecular structures: ----> 6 import nglview 7 import mdtraj 8 from threading import

File ~/anaconda3/envs/pyemma/lib/python3.9/site-packages/nglview/init.py:4 1 import warnings 3 # for doc ----> 4 from . import adaptor, datafiles, show, widget 5 from ._version import get_versions 6 from .adaptor import *

File ~/anaconda3/envs/pyemma/lib/python3.9/site-packages/nglview/show.py:13 3 from . import datafiles 4 from .adaptor import (ASEStructure, ASETrajectory, BiopythonStructure, 5 FileStructure, HTMDTrajectory, IODataStructure, 6 IOTBXStructure, MDAnalysisTrajectory, MDTrajTrajectory, (...) 11 RdkitStructure, 12 TextStructure) ---> 13 from .widget import NGLWidget 15 all = [ 16 'demo', 17 'show_pdbid', (...) 40 'show_biopython', 41 ] 44 def show_pdbid(pdbid, **kwargs):

File ~/anaconda3/envs/pyemma/lib/python3.9/site-packages/nglview/widget.py:19 15 from traitlets import (Bool, CaselessStrEnum, Dict, Instance, Int, Integer, 16 List, Unicode, observe, validate) 17 import traitlets ---> 19 from . import color, interpolate 20 from .adaptor import Structure, Trajectory 21 from .component import ComponentViewer

File ~/anaconda3/envs/pyemma/lib/python3.9/site-packages/nglview/color.py:114 110 else: 111 raise ValueError(f"{obj} must be either list of list or string") --> 114 ColormakerRegistry = _ColormakerRegistry()

File ~/anaconda3/envs/pyemma/lib/python3.9/site-packages/nglview/base.py:10, in _singleton..getinstance() 8 def getinstance(): 9 if cls not in instances: ---> 10 instances[cls] = cls() 11 return instances[cls]

File ~/anaconda3/envs/pyemma/lib/python3.9/site-packages/nglview/color.py:47, in _ColormakerRegistry.init(self, *args, **kwargs) 45 try: 46 get_ipython() # only display in notebook ---> 47 self._ipythondisplay() 48 except NameError: 49 pass

File ~/anaconda3/envs/pyemma/lib/python3.9/site-packages/nglview/color.py:54, in _ColormakerRegistry._ipythondisplay(self, kwargs) 52 if self._ready: 53 return ---> 54 super()._ipythondisplay(kwargs)

AttributeError: 'super' object has no attribute '_ipythondisplay'

**In the tutorial i found

file = mdshare.fetch('hmm-doublewell-2d-100k.npz', working_directory='data') or pdb = mdshare.fetch('alanine-dipeptide-nowater.pdb', working_directory='data') files = mdshare.fetch('alanine-dipeptide-*-250ns-nowater.xtc', working_directory='data') print(pdb) print(files)

I have three 100ns gromacs MD trajectory entitled md_100ns-0.xtc,md_100ns-1.xtc,md_100ns-2.xtc and md_100ns.gro files. how to load them. each trajectory contains 10k snapshots. kindly help**

debanjansen48 commented 1 year ago

i think issues are associated with nglview..

clonker commented 1 year ago

Hi, yes, the error message suggests that there is something wrong with your nglview / ipython setup. It is however not crucial to work with NGLView, you can also use, e.g., VMD. :slightly_smiling_face:

debanjansen48 commented 1 year ago

**In the tutorial i found

file = mdshare.fetch('hmm-doublewell-2d-100k.npz', working_directory='data') or pdb = mdshare.fetch('alanine-dipeptide-nowater.pdb', working_directory='data') files = mdshare.fetch('alanine-dipeptide-*-250ns-nowater.xtc', working_directory='data') print(pdb) print(files)

I have three 100ns gromacs MD trajectory entitled md_100ns-0.xtc,md_100ns-1.xtc,md_100ns-2.xtc and md_100ns.gro files. how to load them. each trajectory contains 10k snapshots. kindly help**

clonker commented 1 year ago

You can use pyemma.coordinates.source for that. Please see to the [relevant documentation](http://www.emma-project.org/latest/tutorials/notebooks/01-data-io-and-featurization.html#load()-versus-source()).

debanjansen48 commented 1 year ago

%matplotlib inline import matplotlib.pyplot as plt import numpy as np import mdshare import pyemma

for visualization of molecular structures:

import mdtraj from threading import Timer from pyemma import pdb = pyemma.coordinates.source(md_100.pdb, features=feat) files = pyemma.coordinates.source(md_100-.xtc, features=feat)

NameError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_5568/2736778055.py in 1 from pyemma import * ----> 2 pdb = pyemma.coordinates.source(md_100.pdb, features=feat) 3 files = pyemma.coordinates.source(md_100.xtc, features=feat)

NameError: name 'md_100' is not defined

it returns above error.

clonker commented 1 year ago

Hi, you can't use it like that :) PyEMMA does not support wildcards and strings should also be declared as such: use "md_100.pdb" over just md_100.pdb. For lists of files use a Python list of strings like ["a.xtc", "b.xtc"].

debanjansen48 commented 1 year ago

files=pyemma.coordinates.source("md_100.xtc",top="md_100.pdb") print(files)

output:-<pyemma.coordinates.data.feature_reader.FeatureReader object at 0x000001D9CB806100>

feat = pyemma.coordinates.featurizer(files)

---------------------------------------------------------------------------ValueError Traceback (most recent call last)~\AppData\Local\Temp/ipykernel_5568/3492995895.py in

----> 1 feat = pyemma.coordinates.featurizer(files) C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\api.py in featurizer(topfile) 142 """ 143 from pyemma.coordinates.data.featurization.featurizer import MDFeaturizer--> 144 return MDFeaturizer(topfile) 145 146 C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\data\featurization\featurizer.py in __init__(self, topfile, **kwargs) 59 """ 60 self.topology = None---> 61 self.topologyfile = topfile 62 self.active_features = [] 63 C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\data\featurization\featurizer.py in topologyfile(self, topfile) 77 self.topology = topfile.topology 78 else:---> 79 raise ValueError("no valid topfile arg: type was %s, " 80 "but only string or mdtraj.Topology allowed." % type(topfile)) 81 ValueError: no valid topfile arg: type was , but only string or mdtraj.Topology allowed. **My trajectory is raw. contains water, ions and apo protein. It creating problem?i converted the md_100.gro to md_100.pdb utilizing pymol. As it says topol.top file not supported.** data = pyemma.coordinates.load(files, features=feat) print('type of data:', type(data)) print('lengths:', len(data)) print('shape of elements:', data[0].shape) print('n_atoms:', feat.topology.n_atoms) NameError Traceback (most recent call last)~\AppData\Local\Temp/ipykernel_5568/2508888573.py in ----> 1 data = pyemma.coordinates.load(files, features=feat) 2 print('type of data:', type(data)) 3 print('lengths:', len(data)) 4 print('shape of elements:', data[0].shape) 5 print('n_atoms:', feat.topology.n_atoms) NameError: name 'feat' is not defined Is there any straight forward protocol? I want to study the conformational changes of a apo protein and holoprotein. I am sorry, actually I am from Organic medicinal chemistry background and have limited idea about python coding. On Mon, Sep 12, 2022 at 6:56 PM Moritz Hoffmann ***@***.***> wrote: > Hi, you can't use it like that :) PyEMMA does not support wildcards and > strings should also be declared as such: use "md_100.pdb" over just > md_100.pdb. For lists of files use a Python list of strings like ["a.xtc", > "b.xtc"]. > > ā€” > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > You are receiving this because you modified the open/close state.Message > ID: ***@***.***> >
hai-schrodinger commented 1 year ago

AttributeError: 'super' object has no attribute 'ipython_display'

FYI: Downgrading to ipywidgets 7 would help.

debanjansen48 commented 1 year ago

:( Downgrading to ipywidgets 7 would help.??

hai-schrodinger commented 1 year ago

:( Downgrading to ipywidgets 7 would help.??

Why do you need to use double ??

But yes, downgrading helps. v8 breaks a lot of things that requires time to migrate.

debanjansen48 commented 1 year ago

Sir, actually I am unable to get your suggestions... I want to.build msm model...not.double... during execution as per protocol given in tutorial. I am getting those errors..I have limited idea about python

clonker commented 1 year ago

I would like to remind all of you that this is an open and collaborative platform, so please remain civil with each other and exercise yourselves in leniency.

Thanks @hai-schrodinger for the hint to downgrade ipywidgets.

@debanjansen48 assuming you use conda for dependency management, running conda remove jupyter and conda install jupyter "ipywidgets<8" should fix things. Be aware that it might take a while for the conda dependency solver to figure things out.

debanjansen48 commented 1 year ago

Apologies If I say something wrong....as a non native English speaker...I may not used correct words. With limited python knowledge I did not understood ipywdget things.... However, I am installing things as per your guidance...thanks

clonker commented 1 year ago

Not a problem, let us know how it goes!

debanjansen48 commented 1 year ago

it takes long....but able to install successfully. During my learning with my trajectory. "http://www.emma-project.org/latest/tutorials/notebooks/00-pentapeptide-showcase.html" getting following error.

%matplotlib inline import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np import mdshare import mdtraj import pyemma from pyemma.util.contexts import settings

pdb =pyemma.coordinates.featurizer('md_100.pdb') pdb.add_backbone_torsions() files = pyemma.coordinates.source("md_100.xtc", features=pdb) traj = mdtraj.load('md_100.pdb')

print(pdb) print(files) MDFeaturizer with features: MDFeaturizer with features: ['PHI 0 TRP 2', 'PSI 0 MET 1', 'PHI 0 PRO 3', 'PSI 0 TRP 2', 'PHI 0 PHE 4', 'PSI 0 PRO 3', 'PHI 0 VAL 5', 'PSI 0 PHE 4', 'PHI 0 SER 6', 'PSI 0 VAL 5', ...] <pyemma.coordinates.data.feature_reader.FeatureReader object at 0x000001D709D1B7F0>

torsions_feat = pyemma.coordinates.featurizer(pdb) torsions_feat.add_backbone_torsions(cossin=True, periodic=False) torsions_data = pyemma.coordinates.load(files, features=torsions_feat) labels = ['backbone\ntorsions']


ValueError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_7948/2952867051.py in ----> 1 torsions_feat = pyemma.coordinates.featurizer(pdb) 2 torsions_feat.add_backbone_torsions(cossin=True, periodic=False) 3 torsions_data = pyemma.coordinates.load(files, features=torsions_feat) 4 labels = ['backbone\ntorsions']

C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\api.py in featurizer(topfile) 142 """ 143 from pyemma.coordinates.data.featurization.featurizer import MDFeaturizer --> 144 return MDFeaturizer(topfile) 145 146

C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\data\featurization\featurizer.py in init(self, topfile, **kwargs) 59 """ 60 self.topology = None ---> 61 self.topologyfile = topfile 62 self.active_features = [] 63

C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\data\featurization\featurizer.py in topologyfile(self, topfile) 77 self.topology = topfile.topology 78 else: ---> 79 raise ValueError("no valid topfile arg: type was %s, " 80 "but only string or mdtraj.Topology allowed." % type(topfile)) 81

ValueError: no valid topfile arg: type was <class 'pyemma.coordinates.data.featurization.featurizer.MDFeaturizer'>, but only string or mdtraj.Topology allowed.

clonker commented 1 year ago

Hi, it should work if you use torsions_feat = pyemma.coordinates.featurizer("md_100.pdb") instead.

debanjansen48 commented 1 year ago

Sir, again error torsions_feat = pyemma.coordinates.featurizer("md_100.pdb") torsions_feat.add_backbone_torsions(cossin=True, periodic=False) torsions_data = pyemma.coordinates.load(files, features=torsions_feat) labels = ['backbone\ntorsions']


ValueError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_7948/3503107185.py in 1 torsions_feat = pyemma.coordinates.featurizer("md_100.pdb") 2 torsions_feat.add_backbone_torsions(cossin=True, periodic=False) ----> 3 torsions_data = pyemma.coordinates.load(files, features=torsions_feat) 4 labels = ['backbone\ntorsions']

C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\api.py in load(trajfiles, features, top, stride, chunksize, **kw) 250 return trajs 251 else: --> 252 raise ValueError('unsupported type (%s) of input' % type(trajfiles)) 253 254

ValueError: unsupported type (<class 'pyemma.coordinates.data.feature_reader.FeatureReader'>) of input

debanjansen48 commented 1 year ago

i converted md_100.gro file to md_100.pdb using pymol. It contain TIP3P water ions

clonker commented 1 year ago

Hey sorry, the problem is that files in your case is the result of pyemma.coordinates.source, which is a feature reader, not a list of file names :-) If you provide a list of file names instead, the call to pyemma.coordinates.load should work as expected.

debanjansen48 commented 1 year ago

Ok sir

On Tue, 13 Sept 2022, 5:44 pm Moritz Hoffmann, @.***> wrote:

Hey sorry, the problem is that files in your case is the result of pyemma.coordinates.source, which is a feature reader, not a list of file names :-) If you provide a list of file names instead, the call to pyemma.coordinates.load should work as expected.

ā€” Reply to this email directly, view it on GitHub https://github.com/markovmodel/PyEMMA/issues/1575#issuecomment-1245327313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOJ7Q4X7P6RM2MV6PLSMAR3V6BV23ANCNFSM6AAAAAAQJU5NXA . You are receiving this because you were mentioned.Message ID: @.***>

debanjansen48 commented 1 year ago

Same error pdb =pyemma.coordinates.featurizer('md_100.pdb') pdb.add_backbone_torsions() files = pyemma.coordinates.load("md_100.xtc", features=pdb) print(pdb) print(files)

MDFeaturizer with features: ['PHI 0 TRP 2', 'PSI 0 MET 1', 'PHI 0 PRO 3', 'PSI 0 TRP 2', 'PHI 0 PHE 4', 'PSI 0 PRO 3', 'PHI 0 VAL 5', 'PSI 0 PHE 4', 'PHI 0 SER 6', 'PSI 0 VAL 5', ...] [[-2.7803931 -0.55992097 0.8125005 ... -0.9663092 3.060793 -2.0096664 ] [-3.1387906 -0.52576107 0.9709076 ... -1.2261833 2.9609232 -2.078714 ] [-2.8843434 -0.5206821 1.4275188 ... -1.1710676 -3.0772657 -1.4840003 ] ... [ 2.7466419 -0.40174305 0.8194104 ... -1.8518398 3.0417266 -1.8356031 ] [ 2.8462875 -0.851876 1.1383928 ... -2.0212262 -3.139257 -1.0744576 ] [ 2.9985669 -0.5661735 0.97182405 ... -1.1841456 -2.9308317 -0.67333 ]]

torsions_feat = pyemma.coordinates.featurizer(pdb) torsions_feat.add_backbone_torsions(cossin=True, periodic=False) torsions_data = pyemma.coordinates.load(files, features=torsions_feat) labels = ['backbone\ntorsions']

---------------------------------------------------------------------------ValueError Traceback (most recent call last)~\AppData\Local\Temp/ipykernel_7160/857609899.py in ----> 1 torsions_feat = pyemma.coordinates.featurizer(files) 2 torsions_feat.add_backbone_torsions(cossin=True, periodic=False) 3 torsions_data = pyemma.coordinates.load(files, features=torsions_feat) 4 labels = ['backbone\ntorsions'] C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\api.py in featurizer(topfile) 142 """ 143 from pyemma.coordinates.data.featurization.featurizer import MDFeaturizer--> 144 return MDFeaturizer(topfile) 145 146 C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\data\featurization\featurizer.py in init(self, topfile, **kwargs) 59 """ 60 self.topology = None---> 61 self.topologyfile = topfile 62 self.active_features = [] 63 C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\data\featurization\featurizer.py in topologyfile(self, topfile) 77 self.topology = topfile.topology 78 else:---> 79 raise ValueError("no valid topfile arg: type was %s, " 80 "but only string or mdtraj.Topology allowed." % type(topfile)) 81 ValueError: no valid topfile arg: type was <class 'numpy.ndarray'>, but only string or mdtraj.Topology allowed.

On Tue, Sep 13, 2022 at 6:26 PM Debanjan Sen @.***> wrote:

Ok sir

On Tue, 13 Sept 2022, 5:44 pm Moritz Hoffmann, @.***> wrote:

Hey sorry, the problem is that files in your case is the result of pyemma.coordinates.source, which is a feature reader, not a list of file names :-) If you provide a list of file names instead, the call to pyemma.coordinates.load should work as expected.

ā€” Reply to this email directly, view it on GitHub https://github.com/markovmodel/PyEMMA/issues/1575#issuecomment-1245327313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOJ7Q4X7P6RM2MV6PLSMAR3V6BV23ANCNFSM6AAAAAAQJU5NXA . You are receiving this because you were mentioned.Message ID: @.***>

debanjansen48 commented 1 year ago

Hi Sir, gradually I am getting success.. pdb =pyemma.coordinates.featurizer('md_100.pdb') files = pyemma.coordinates.source(["md_100.xtc","md_100-1.xtc","md_100-2.xtc"], features=pdb) torsions_feat = pyemma.coordinates.featurizer("md_100.pdb") torsions_feat.add_backbone_torsions(cossin=True, periodic=False) torsions_data = pyemma.coordinates.source(files, features=torsions_feat) labels = ['backbone\ntorsions'] positions_feat = pyemma.coordinates.featurizer("md_100.pdb") positions_feat.add_selection(positions_feat.select_Backbone()) positions_data = pyemma.coordinates.source(files, features=positions_feat) labels += ['backbone atom\npositions'] distances_feat = pyemma.coordinates.featurizer("md_100.pdb") distances_feat.add_distances( distances_feat.pairs(distances_feat.select_Backbone(), excluded_neighbors=2), periodic=False) distances_data = pyemma.coordinates.source(files, features=distances_feat) labels += ['backbone atom\ndistances']

upto above code it returns no error however def score_cv(data, dim, lag, number_of_splits=10, validation_fraction=0.5): with pyemma.util.contexts.settings(show_progress_bars=False): nval = int(len(data) * validation_fraction) scores = np.zeros(number_of_splits) for n in range(number_of_splits): ival = np.random.choice(len(data), size=nval, replace=False) vamp = pyemma.coordinates.vamp( [d for i, d in enumerate(data) if i not in ival], lag=lag, dim=dim) scores[n] = vamp.score([d for i, d in enumerate(data) if i in ival]) return scores dim = 15

fig, axes = plt.subplots(1, 3, figsize=(12, 3), sharey=True) for ax, lag in zip(axes.flat, [5, 10, 20]): torsions_scores = score_cv(files, lag=lag, dim=dim) scores = [torsions_scores.mean()] errors = [torsions_scores.std()] positions_scores = score_cv(positions_data, lag=lag, dim=dim) scores += [positions_scores.mean()] errors += [positions_scores.std()] distances_scores = score_cv(distances_data, lag=lag, dim=dim) scores += [distances_scores.mean()] errors += [distances_scores.std()] ax.bar(labels, scores, yerr=errors, color=['C0', 'C1', 'C2']) ax.set_title(r'lag time $\tau$={:.1f}ns'.format(lag * 0.1)) if lag == 5:

save for later

    vamp_bars_plot = dict(
        labels=labels, scores=scores, errors=errors, dim=dim, lag=lag)

axes[0].set_ylabel('VAMP2 score') fig.tight_layout()

returns len error TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_4636/4284533947.py in 13 fig, axes = plt.subplots(1, 3, figsize=(12, 3), sharey=True) 14 for ax, lag in zip(axes.flat, [5, 10, 20]): ---> 15 torsions_scores = score_cv(files, lag=lag, dim=dim) 16 scores = [torsions_scores.mean()] 17 errors = [torsions_scores.std()]

~\AppData\Local\Temp/ipykernel_4636/4284533947.py in score_cv(data, dim, lag, number_of_splits, validation_fraction) 1 def score_cv(data, dim, lag, number_of_splits=10, validation_fraction=0.5): 2 with pyemma.util.contexts.settings(show_progress_bars=False): ----> 3 nval = int(len(data) * validation_fraction) 4 scores = np.zeros(number_of_splits) 5 for n in range(number_of_splits):

TypeError: object of type 'FeatureReader' has no len()

shall i need to install some tools?

On Wed, Sep 14, 2022 at 12:53 AM Debanjan Sen @.***> wrote:

Same error pdb =pyemma.coordinates.featurizer('md_100.pdb') pdb.add_backbone_torsions() files = pyemma.coordinates.load("md_100.xtc", features=pdb) print(pdb) print(files)

MDFeaturizer with features: ['PHI 0 TRP 2', 'PSI 0 MET 1', 'PHI 0 PRO 3', 'PSI 0 TRP 2', 'PHI 0 PHE 4', 'PSI 0 PRO 3', 'PHI 0 VAL 5', 'PSI 0 PHE 4', 'PHI 0 SER 6', 'PSI 0 VAL 5', ...] [[-2.7803931 -0.55992097 0.8125005 ... -0.9663092 3.060793 -2.0096664 ] [-3.1387906 -0.52576107 0.9709076 ... -1.2261833 2.9609232 -2.078714 ] [-2.8843434 -0.5206821 1.4275188 ... -1.1710676 -3.0772657 -1.4840003 ] ... [ 2.7466419 -0.40174305 0.8194104 ... -1.8518398 3.0417266 -1.8356031 ] [ 2.8462875 -0.851876 1.1383928 ... -2.0212262 -3.139257 -1.0744576 ] [ 2.9985669 -0.5661735 0.97182405 ... -1.1841456 -2.9308317 -0.67333 ]]

torsions_feat = pyemma.coordinates.featurizer(pdb) torsions_feat.add_backbone_torsions(cossin=True, periodic=False) torsions_data = pyemma.coordinates.load(files, features=torsions_feat) labels = ['backbone\ntorsions']

---------------------------------------------------------------------------ValueError Traceback (most recent call last)~\AppData\Local\Temp/ipykernel_7160/857609899.py in ----> 1 torsions_feat = pyemma.coordinates.featurizer(files) 2 torsions_feat.add_backbone_torsions(cossin=True, periodic=False) 3 torsions_data = pyemma.coordinates.load(files, features=torsions_feat) 4 labels = ['backbone\ntorsions'] C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\api.py in featurizer(topfile) 142 """ 143 from pyemma.coordinates.data.featurization.featurizer import MDFeaturizer--> 144 return MDFeaturizer(topfile) 145 146 C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\data\featurization\featurizer.py in init(self, topfile, **kwargs) 59 """ 60 self.topology = None---> 61 self.topologyfile = topfile 62 self.active_features = [] 63 C:\ProgramData\Miniconda3\envs\pyemma\lib\site-packages\pyemma\coordinates\data\featurization\featurizer.py in topologyfile(self, topfile) 77 self.topology = topfile.topology 78 else:---> 79 raise ValueError("no valid topfile arg: type was %s, " 80 "but only string or mdtraj.Topology allowed." % type(topfile)) 81 ValueError: no valid topfile arg: type was <class 'numpy.ndarray'>, but only string or mdtraj.Topology allowed.

On Tue, Sep 13, 2022 at 6:26 PM Debanjan Sen @.***> wrote:

Ok sir

On Tue, 13 Sept 2022, 5:44 pm Moritz Hoffmann, @.***> wrote:

Hey sorry, the problem is that files in your case is the result of pyemma.coordinates.source, which is a feature reader, not a list of file names :-) If you provide a list of file names instead, the call to pyemma.coordinates.load should work as expected.

ā€” Reply to this email directly, view it on GitHub https://github.com/markovmodel/PyEMMA/issues/1575#issuecomment-1245327313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOJ7Q4X7P6RM2MV6PLSMAR3V6BV23ANCNFSM6AAAAAAQJU5NXA . You are receiving this because you were mentioned.Message ID: @.***>

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.