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

add_sidechain_torsions produces an error #1607

Open hima111997 opened 1 year ago

hima111997 commented 1 year ago

Here's a quick checklist in what to include:

when i use add_sidechain_torsions it produces an error:

TypeError                                 Traceback (most recent call last)
Cell In[62], line 8
      5 xtc = [i for i in os.listdir(path) if i.endswith('.trr')]
      7 feat.add_backbone_torsions(periodic=False, selstr = 'index 0 to 6090', cossin=True) # 
----> 8 feat.add_sidechain_torsions(periodic=False, selstr = 'index 0 to 6090', cossin=True, which='all') # which means to add different dihedrals of siechains (chi1, 2, etc)
      9 data = pyemma.coordinates.source(xtc[0], features=feat)
     11 #feat.active_features = [] # this removes the previous features
     12 #
     13 #feat.add_selection(feat.select_Ca())
   (...)
     16 
     17 #feat.add_all() # XYZ coords

File ~/miniconda3/envs/emma/lib/python3.11/site-packages/pyemma/coordinates/data/featurization/featurizer.py:772, in MDFeaturizer.add_sidechain_torsions(self, selstr, deg, cossin, periodic, which)
    749 """
    750 Adds all side chain torsion angles or the ones specified in :obj:`selstr` to the feature list.
    751 
   (...)
    769     one or combination of ('all', 'chi1', 'chi2', 'chi3', 'chi4', 'chi5')
    770 """
    771 from .angles import SideChainTorsions
--> 772 f = SideChainTorsions(self.topology, selstr=selstr, deg=deg, cossin=cossin, periodic=periodic, which=which)
    773 self.__add_feature(f)

File ~/miniconda3/envs/emma/lib/python3.11/site-packages/pyemma/coordinates/data/featurization/angles.py:211, in SideChainTorsions.__init__(self, top, selstr, deg, cossin, periodic, which)
    209     raise ValueError('Could not determine any side chain dihedrals for your topology!')
    210 self._prefix_label_lengths = np.array([len(indices_dict[k]) if k in which else 0 for k in self.options])
--> 211 indices = np.vstack(valid.values())
    213 super(SideChainTorsions, self).__init__(top=top, dih_indexes=indices, deg=deg, cossin=cossin, periodic=periodic)

File ~/miniconda3/envs/emma/lib/python3.11/site-packages/numpy/core/shape_base.py:216, in _vhstack_dispatcher(tup, dtype, casting)
    215 def _vhstack_dispatcher(tup, *, dtype=None, casting=None):
--> 216     return _arrays_for_stack_dispatcher(tup)

File ~/miniconda3/envs/emma/lib/python3.11/site-packages/numpy/core/shape_base.py:209, in _arrays_for_stack_dispatcher(arrays)
    207 def _arrays_for_stack_dispatcher(arrays):
    208     if not hasattr(arrays, "__getitem__"):
--> 209         raise TypeError('arrays to stack must be passed as a "sequence" type '
    210                         'such as list or tuple.')
    212     return tuple(arrays)

TypeError: arrays to stack must be passed as a "sequence" type such as list or tuple.

i use pyemma 2.5.12 and this is the code i use is:

top = 'step1_pdbreader.psf'
feat = pyemma.coordinates.featurizer(top)
trr = 'trr file'
feat.add_backbone_torsions(periodic=False, selstr = 'index 0 to 6090', cossin=True) 
feat.add_sidechain_torsions(periodic=False, selstr = 'index 0 to 6090', cossin=True, which='all') 
data = pyemma.coordinates.source(trr, features=feat)